-
Notifications
You must be signed in to change notification settings - Fork 451
fix: NetworkTransform initial synchronization, parenting, smooth transitions between transform spaces, and UI updates #3013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NoelStephensUnity
merged 36 commits into
develop-2.0.0
from
fix/owner-object-parenting-no-sync-transform-option
Sep 5, 2024
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
7d5073a
fix
NoelStephensUnity cd158f7
fix
NoelStephensUnity 1fe5a95
wip
NoelStephensUnity 7099d55
fix
NoelStephensUnity f574314
update
NoelStephensUnity ee03337
fix
NoelStephensUnity e521c2a
test fix
NoelStephensUnity 1965056
fix
NoelStephensUnity 3a50f7f
fix
NoelStephensUnity 4af00c1
test
NoelStephensUnity 73c0e05
fix
NoelStephensUnity 7343471
test
NoelStephensUnity ef5f8ec
update
NoelStephensUnity 3cd9210
Merge branch 'develop-2.0.0' into fix/nested-networktransforms-not-up…
NoelStephensUnity f60c29e
update
NoelStephensUnity ba770e4
test
NoelStephensUnity dd01870
Merge branch 'fix/nested-networktransforms-not-updating' into fix/own…
NoelStephensUnity 074710c
update
NoelStephensUnity c943803
Merge branch 'develop-2.0.0' into fix/owner-object-parenting-no-sync-…
NoelStephensUnity 5da0a92
update
NoelStephensUnity 9cb8f06
update
NoelStephensUnity 4c02ab0
update
NoelStephensUnity e5d2603
update
NoelStephensUnity e9673e8
update
NoelStephensUnity a2ee9c0
update
NoelStephensUnity d500bc9
fix
NoelStephensUnity eb94b5e
style
NoelStephensUnity dc1be1f
update
NoelStephensUnity ff21e36
fix
NoelStephensUnity 542f9ab
test
NoelStephensUnity bc940ef
Merge branch 'develop-2.0.0' into fix/owner-object-parenting-no-sync-…
NoelStephensUnity e033bf5
update
NoelStephensUnity 2ede073
fix
NoelStephensUnity e1b0046
fix
NoelStephensUnity 337376d
Merge branch 'develop-2.0.0' into fix/owner-object-parenting-no-sync-…
NoelStephensUnity c1e9615
update
NoelStephensUnity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Unity.Netcode.Editor | ||
{ | ||
/// <summary> | ||
/// The base Netcode Editor helper class to display derived <see cref="MonoBehaviour"/> based components <br /> | ||
/// where each child generation's properties will be displayed within a FoldoutHeaderGroup. | ||
/// </summary> | ||
[CanEditMultipleObjects] | ||
public partial class NetcodeEditorBase<TT> : UnityEditor.Editor where TT : MonoBehaviour | ||
{ | ||
/// <inheritdoc/> | ||
public virtual void OnEnable() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Helper method to draw the properties of the specified child type <typeparamref name="T"/> component within a FoldoutHeaderGroup. | ||
/// </summary> | ||
/// <typeparam name="T">The specific child type that should have its properties drawn.</typeparam> | ||
/// <param name="type">The component type of the <see cref="UnityEditor.Editor.target"/>.</param> | ||
/// <param name="displayProperties">The <see cref="Action"/> to invoke that will draw the type <typeparamref name="T"/> properties.</param> | ||
/// <param name="expanded">The <typeparamref name="T"/> current expanded property value</param> | ||
/// <param name="setExpandedProperty">The <see cref="Action{bool}"/> invoked to apply the updated <paramref name="expanded"/> value.</param> | ||
protected void DrawFoldOutGroup<T>(Type type, Action displayProperties, bool expanded, Action<bool> setExpandedProperty) | ||
{ | ||
var baseClass = target as TT; | ||
EditorGUI.BeginChangeCheck(); | ||
serializedObject.Update(); | ||
var currentClass = typeof(T); | ||
if (type.IsSubclassOf(currentClass) || (!type.IsSubclassOf(currentClass) && currentClass.IsSubclassOf(typeof(TT)))) | ||
{ | ||
var expandedValue = EditorGUILayout.BeginFoldoutHeaderGroup(expanded, $"{currentClass.Name} Properties"); | ||
if (expandedValue) | ||
{ | ||
EditorGUILayout.EndFoldoutHeaderGroup(); | ||
displayProperties.Invoke(); | ||
} | ||
else | ||
{ | ||
EditorGUILayout.EndFoldoutHeaderGroup(); | ||
} | ||
EditorGUILayout.Space(); | ||
setExpandedProperty.Invoke(expandedValue); | ||
} | ||
else | ||
{ | ||
displayProperties.Invoke(); | ||
} | ||
serializedObject.ApplyModifiedProperties(); | ||
EditorGUI.EndChangeCheck(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override void OnInspectorGUI() | ||
{ | ||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
com.unity.netcode.gameobjects/Editor/NetcodeEditorBase.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
com.unity.netcode.gameobjects/Editor/NetworkRigidbodyBaseEditor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#if COM_UNITY_MODULES_PHYSICS || COM_UNITY_MODULES_PHYSICS2D | ||
using Unity.Netcode.Components; | ||
using UnityEditor; | ||
|
||
namespace Unity.Netcode.Editor | ||
{ | ||
[CustomEditor(typeof(NetworkRigidbodyBase), true)] | ||
[CanEditMultipleObjects] | ||
public class NetworkRigidbodyBaseEditor : NetcodeEditorBase<NetworkBehaviour> | ||
{ | ||
private SerializedProperty m_UseRigidBodyForMotion; | ||
private SerializedProperty m_AutoUpdateKinematicState; | ||
private SerializedProperty m_AutoSetKinematicOnDespawn; | ||
|
||
|
||
public override void OnEnable() | ||
{ | ||
m_UseRigidBodyForMotion = serializedObject.FindProperty(nameof(NetworkRigidbodyBase.UseRigidBodyForMotion)); | ||
m_AutoUpdateKinematicState = serializedObject.FindProperty(nameof(NetworkRigidbodyBase.AutoUpdateKinematicState)); | ||
m_AutoSetKinematicOnDespawn = serializedObject.FindProperty(nameof(NetworkRigidbodyBase.AutoSetKinematicOnDespawn)); | ||
|
||
base.OnEnable(); | ||
} | ||
|
||
private void DisplayNetworkRigidbodyProperties() | ||
{ | ||
EditorGUILayout.PropertyField(m_UseRigidBodyForMotion); | ||
EditorGUILayout.PropertyField(m_AutoUpdateKinematicState); | ||
EditorGUILayout.PropertyField(m_AutoSetKinematicOnDespawn); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override void OnInspectorGUI() | ||
{ | ||
var networkRigidbodyBase = target as NetworkRigidbodyBase; | ||
void SetExpanded(bool expanded) { networkRigidbodyBase.NetworkRigidbodyBaseExpanded = expanded; }; | ||
DrawFoldOutGroup<NetworkRigidbodyBase>(networkRigidbodyBase.GetType(), DisplayNetworkRigidbodyProperties, networkRigidbodyBase.NetworkRigidbodyBaseExpanded, SetExpanded); | ||
base.OnInspectorGUI(); | ||
} | ||
} | ||
} | ||
#endif |
2 changes: 2 additions & 0 deletions
2
com.unity.netcode.gameobjects/Editor/NetworkRigidbodyBaseEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a little comment here. I like the foldout idea, but I think maybe we can take the call-to-action buttons out so users can access them without expanding the foldout content, especially during runtime when there's nothing much within the foldout section. I made a quick mock here! Please lemme know if this makes sense!
Side note: would it make sense to show network manager properties during runtime? will people need this information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome feedback... and good points.
Made the suggested changes and pushed the update.
👍