DrawWeightInspector
How do I use Draw Weight Inspector
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
30 | DrawWeightInspector(); | 1 |
66 | private void DrawWeightInspector() | 2 |
File name: PhotonAnimatorViewEditor.cs
Copy
18 public override void OnInspectorGUI()
19 {
20 //base.OnInspectorGUI();
21
22 if (this.m_Animator == null)
23 {
24 GUILayout.BeginVertical(GUI.skin.box);
25 GUILayout.Label("GameObject doesn't have an Animator component to synchronize");
26 GUILayout.EndVertical();
27 return;
28 }
29
30 DrawWeightInspector();
31
32 if (this.m_Animator.layerCount == 0)
33 {
34 GUILayout.BeginVertical(GUI.skin.box);
35 GUILayout.Label("Animator doesn't have any layers setup to synchronize");
36 GUILayout.EndVertical();
37 }
38
39 DrawParameterInspector();
40
41 if (GetParameterCount() == 0)
42 {
43 GUILayout.BeginVertical(GUI.skin.box);
44 GUILayout.Label("Animator doesn't have any parameters setup to synchronize");
45 GUILayout.EndVertical();
46 }
47
48 serializedObject.ApplyModifiedProperties();
49
50 //GUILayout.Label( "m_SynchronizeLayers " + serializedObject.FindProperty( "m_SynchronizeLayers" ).arraySize );
51 //GUILayout.Label( "m_SynchronizeParameters " + serializedObject.FindProperty( "m_SynchronizeParameters" ).arraySize );
52 }
File name: PhotonAnimatorViewEditor.cs
Copy
66 private void DrawWeightInspector()
67 {
68 SerializedProperty foldoutProperty = serializedObject.FindProperty("ShowLayerWeightsInspector");
69 foldoutProperty.boolValue = PhotonGUI.ContainerHeaderFoldout("Synchronize Layer Weights", foldoutProperty.boolValue);
70
71 if (foldoutProperty.boolValue == false)
72 {
73 return;
74 }
75
76 float lineHeight = 20;
77 Rect containerRect = PhotonGUI.ContainerBody(this.m_Animator.layerCount*lineHeight);
78
79 for (int i = 0; i < this.m_Animator.layerCount; ++i)
80 {
81 if (this.m_Target.DoesLayerSynchronizeTypeExist(i) == false)
82 {
83 this.m_Target.SetLayerSynchronized(i, PhotonAnimatorView.SynchronizeType.Disabled);
84 EditorUtility.SetDirty(this.m_Target);
85 }
86
87 PhotonAnimatorView.SynchronizeType value = this.m_Target.GetLayerSynchronizeType(i);
88
89 Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + i*lineHeight, containerRect.width, lineHeight);
90
91 Rect labelRect = new Rect(elementRect.xMin + 5, elementRect.yMin + 2, EditorGUIUtility.labelWidth - 5, elementRect.height);
92 GUI.Label(labelRect, "Layer " + i);
93
94 Rect popupRect = new Rect(elementRect.xMin + EditorGUIUtility.labelWidth, elementRect.yMin + 2, elementRect.width - EditorGUIUtility.labelWidth - 5, EditorGUIUtility.singleLineHeight);
95 value = (PhotonAnimatorView.SynchronizeType) EditorGUI.EnumPopup(popupRect, value);
96
97 if (i < this.m_Animator.layerCount - 1)
98 {
99 Rect splitterRect = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
100 PhotonGUI.DrawSplitter(splitterRect);
101 }
102
103 if (value != this.m_Target.GetLayerSynchronizeType(i))
104 {
105 Undo.RecordObject(target, "Modify Synchronize Layer Weights");
106 this.m_Target.SetLayerSynchronized(i, value);
107
108 EditorUtility.SetDirty(this.m_Target);
109 }
110 }
111 }
DrawWeightInspector 104 lượt xem
Gõ tìm kiếm nhanh...