Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 39 additions & 61 deletions com.unity.multiplayer.mlapi/Editor/NetworkedAnimatorEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,92 +9,70 @@ namespace UnityEditor
[CanEditMultipleObjects]
public class NetworkAnimatorEditor : Editor
{
// TODO @mfatihmar (Unity): Re-implement this after `NetworkedAnimator` re-implementation
/*
private NetworkedAnimator networkedAnimatorTarget;
private NetworkedAnimator m_Target;

[NonSerialized]
private bool initialized;
private bool m_Initialized;

private SerializedProperty animatorProperty;
private GUIContent animatorLabel;
private SerializedProperty m_AnimatorProperty;
private GUIContent m_AnimatorLabel;

void Init()
private void Initialize()
{
if (initialized)
return;

initialized = true;
networkedAnimatorTarget = target as NetworkedAnimator;
if (m_Initialized) return;

animatorProperty = serializedObject.FindProperty("_animator");
animatorLabel = new GUIContent("Animator", "The Animator component to synchronize.");
}
m_Initialized = true;
m_Target = target as NetworkedAnimator;

public override void OnInspectorGUI()
{
Init();
serializedObject.Update();
DrawControls();
serializedObject.ApplyModifiedProperties();
m_AnimatorProperty = serializedObject.FindProperty("m_Animator");
m_AnimatorLabel = new GUIContent("Animator", "The Animator component to synchronize.");
}

void DrawControls()
private void DrawControls()
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(animatorProperty, animatorLabel);
EditorGUILayout.PropertyField(m_AnimatorProperty, m_AnimatorLabel);
if (EditorGUI.EndChangeCheck()) m_Target.ResetTrackedParams();

if (EditorGUI.EndChangeCheck())
networkedAnimatorTarget.ResetParameterOptions();
var animator = m_Target.animator;
if (ReferenceEquals(animator, null)) return;

if (networkedAnimatorTarget.animator == null)
return;
var animatorController = animator.runtimeAnimatorController as AnimatorController;
if (ReferenceEquals(animatorController, null)) return;

var controller = networkedAnimatorTarget.animator.runtimeAnimatorController as AnimatorController;
if (controller != null)
EditorGUI.indentLevel += 1;
var showWarning = false;
{
var showWarning = false;
EditorGUI.indentLevel += 1;
int i = 0;

foreach (var p in controller.parameters)
int paramIndex = 0;
foreach (var animParam in animatorController.parameters)
{
if (i >= 32)
if (paramIndex >= 32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magical

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, already was :(
(probably comes from 32-bits integer and bitwise flags logic)

{
showWarning = true;
break;
}

bool oldSend = networkedAnimatorTarget.GetParameterAutoSend(i);
bool send = EditorGUILayout.Toggle(p.name, oldSend);
if (send != oldSend)
bool wasTracking = m_Target.GetParamTracking(paramIndex);
bool isTracking = EditorGUILayout.Toggle(animParam.name, wasTracking);
if (isTracking != wasTracking)
{
networkedAnimatorTarget.SetParameterAutoSend(i, send);
m_Target.SetParamTracking(paramIndex, isTracking);
EditorUtility.SetDirty(target);
}
i += 1;
}

if (showWarning)
EditorGUILayout.HelpBox("NetworkAnimator can only select between the first 32 parameters in a mecanim controller", MessageType.Warning);

EditorGUI.indentLevel -= 1;
paramIndex++;
}
}
if (showWarning) EditorGUILayout.HelpBox("NetworkAnimator can only select between the first 32 parameters in a mecanim controller", MessageType.Warning);
EditorGUI.indentLevel -= 1;
}

if (Application.isPlaying)
{
EditorGUILayout.Separator();
if (networkedAnimatorTarget.param0 != "")
EditorGUILayout.LabelField("Param 0", networkedAnimatorTarget.param0);
if (networkedAnimatorTarget.param1 != "")
EditorGUILayout.LabelField("Param 1", networkedAnimatorTarget.param1);
if (networkedAnimatorTarget.param2 != "")
EditorGUILayout.LabelField("Param 2", networkedAnimatorTarget.param2);
if (networkedAnimatorTarget.param3 != "")
EditorGUILayout.LabelField("Param 3", networkedAnimatorTarget.param3);
if (networkedAnimatorTarget.param4 != "")
EditorGUILayout.LabelField("Param 4", networkedAnimatorTarget.param4);
}
public override void OnInspectorGUI()
{
Initialize();
serializedObject.Update();
DrawControls();
serializedObject.ApplyModifiedProperties();
}
*/
}
}
}
Loading