HEADER









How do I use H E A D E R
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


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     }
File name: PhotonAnimatorViewEditor.cs Copy
179     private void DrawParameterInspector()
180     {
181         SerializedProperty foldoutProperty = serializedObject.FindProperty("ShowParameterInspector");
182         foldoutProperty.boolValue = PhotonGUI.ContainerHeaderFoldout("Synchronize Parameters", foldoutProperty.boolValue);
183
184         if (foldoutProperty.boolValue == false)
185         {
186             return;
187         }
188
189         float lineHeight = 20;
190         Rect containerRect = PhotonGUI.ContainerBody(GetParameterCount()*lineHeight);
191
192         for (int i = 0; i < GetParameterCount(); i++)
193         {
194             AnimatorControllerParameter parameter = null;
195
196#if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6
197             parameter = this.m_Controller.GetParameter(i);
198#else
199             parameter = m_Animator.parameters[ i ];
200#endif
201
202             string defaultValue = "";
203
204             if (parameter.type == AnimatorControllerParameterType.Bool)
205             {
206                 defaultValue += parameter.defaultBool.ToString();
207             }
208             else if (parameter.type == AnimatorControllerParameterType.Float)
209             {
210                 defaultValue += parameter.defaultFloat.ToString();
211             }
212             else if (parameter.type == AnimatorControllerParameterType.Int)
213             {
214                 defaultValue += parameter.defaultInt.ToString();
215             }
216
217             if (this.m_Target.DoesParameterSynchronizeTypeExist(parameter.name) == false)
218             {
219                 this.m_Target.SetParameterSynchronized(parameter.name, (PhotonAnimatorView.ParameterType) parameter.type, PhotonAnimatorView.SynchronizeType.Disabled);
220                 EditorUtility.SetDirty(this.m_Target);
221             }
222
223             PhotonAnimatorView.SynchronizeType value = this.m_Target.GetParameterSynchronizeType(parameter.name);
224
225             Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + i*lineHeight, containerRect.width, lineHeight);
226
227             Rect labelRect = new Rect(elementRect.xMin + 5, elementRect.yMin + 2, EditorGUIUtility.labelWidth - 5, elementRect.height);
228             GUI.Label(labelRect, parameter.name + " (" + defaultValue + ")");
229
230             Rect popupRect = new Rect(elementRect.xMin + EditorGUIUtility.labelWidth, elementRect.yMin + 2, elementRect.width - EditorGUIUtility.labelWidth - 5, EditorGUIUtility.singleLineHeight);
231             value = (PhotonAnimatorView.SynchronizeType) EditorGUI.EnumPopup(popupRect, value);
232
233             if (i < GetParameterCount() - 1)
234             {
235                 Rect splitterRect = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
236                 PhotonGUI.DrawSplitter(splitterRect);
237             }
238
239             if (value != this.m_Target.GetParameterSynchronizeType(parameter.name))
240             {
241                 Undo.RecordObject(target, "Modify Synchronize Parameter " + parameter.name);
242                 this.m_Target.SetParameterSynchronized(parameter.name, (PhotonAnimatorView.ParameterType) parameter.type, value);
243
244                 EditorUtility.SetDirty(this.m_Target);
245             }
246         }
247     }
File name: PhotonRigidbody2DViewEditor.cs Copy
7     public override void OnInspectorGUI()
8     {
9         PhotonGUI.ContainerHeader("Options");
10
11         Rect containerRect = PhotonGUI.ContainerBody(EditorGUIUtility.singleLineHeight*2 + 10);
12
13         Rect propertyRect = new Rect(containerRect.xMin + 5, containerRect.yMin + 5, containerRect.width, EditorGUIUtility.singleLineHeight);
14         EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeVelocity"), new GUIContent("Synchronize Velocity"));
15
16         propertyRect.y += EditorGUIUtility.singleLineHeight;
17         EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeAngularVelocity"), new GUIContent("Synchronize Angular Velocity"));
18     }
File name: PhotonRigidbodyViewEditor.cs Copy
7     public override void OnInspectorGUI()
8     {
9         PhotonGUI.ContainerHeader("Options");
10
11         Rect containerRect = PhotonGUI.ContainerBody(EditorGUIUtility.singleLineHeight*2 + 10);
12
13         Rect propertyRect = new Rect(containerRect.xMin + 5, containerRect.yMin + 5, containerRect.width, EditorGUIUtility.singleLineHeight);
14         EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeVelocity"), new GUIContent("Synchronize Velocity"));
15
16         propertyRect.y += EditorGUIUtility.singleLineHeight;
17         EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeAngularVelocity"), new GUIContent("Synchronize Angular Velocity"));
18     }
File name: PhotonTransformViewEditor.cs Copy
47     public override void OnInspectorGUI()
48     {
49         this.m_Target = (PhotonTransformView) target;
50
51         DrawIsPlayingWarning();
52         GUI.enabled = !Application.isPlaying;
53
54         DrawSynchronizePositionHeader();
55         DrawSynchronizePositionData();
56
57         GUI.enabled = !Application.isPlaying;
58         DrawSynchronizeRotationHeader();
59         DrawSynchronizeRotationData();
60
61         GUI.enabled = !Application.isPlaying;
62         DrawSynchronizeScaleHeader();
63         DrawSynchronizeScaleData();
64
65         serializedObject.ApplyModifiedProperties();
66
67         GUI.enabled = true;
68     }
File name: PhotonTransformViewEditor.cs Copy
91     private void DrawSynchronizePositionHeader()
92     {
93         DrawHeader("Synchronize Position", this.m_SynchronizePositionProperty);
94     }
File name: PhotonTransformViewEditor.cs Copy
304     private void DrawSynchronizeRotationHeader()
305     {
306         DrawHeader("Synchronize Rotation", this.m_SynchronizeRotationProperty);
307     }
File name: PhotonTransformViewEditor.cs Copy
353     private void DrawSynchronizeScaleHeader()
354     {
355         DrawHeader("Synchronize Scale", this.m_SynchronizeScaleProperty);
356     }
File name: PhotonTransformViewEditor.cs Copy
401     private void DrawHeader(string label, SerializedProperty property)
402     {
403         if (property == null)
404         {
405             return;
406         }
407
408         bool newValue = PhotonGUI.ContainerHeaderToggle(label, property.boolValue);
409
410         if (newValue != property.boolValue)
411         {
412             Undo.RecordObject(this.m_Target, "Change " + label);
413             property.boolValue = newValue;
414             EditorUtility.SetDirty(this.m_Target);
415         }
416     }
File name: PhotonGUI.cs Copy
152     public static void ContainerHeader( string headline )
153     {
154         DoContainerHeader( headline, 27, 0 );
155     }

Download file with original file name:HEADER

HEADER 3.264 lượt xem

Gõ tìm kiếm nhanh...