GizmoType









How do I use Gizmo Type
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonGUI.cs Copy
197         SerializedProperty gizmoSizeProperty )
198     {
199         float height = EditorGUIUtility.singleLineHeight;
200         float flexibleWidth = Mathf.Max( 40, position.width - EditorGUIUtility.labelWidth - 20 - 75 - 5 - 40 - 5 );
201
202         Rect labelRect = new Rect( position.xMin, position.yMin, EditorGUIUtility.labelWidth, height );
203         GUI.Label( labelRect, label );
204
205         Rect enabledRect = new Rect( labelRect.xMax, labelRect.yMin, 20, height );
206         EditorGUI.PropertyField( enabledRect, gizmoEnabledProperty, GUIContent.none );
207
208         bool oldGUIEnabled = GUI.enabled;
209         GUI.enabled = gizmoEnabledProperty.boolValue;
210
211         Rect colorRect = new Rect( enabledRect.xMax + 5, labelRect.yMin, 70, height );
212         EditorGUI.PropertyField( colorRect, gizmoColorProperty, GUIContent.none );
213
214         Rect typeRect = new Rect( colorRect.xMax + 5, labelRect.yMin, flexibleWidth * 0.7f, height );
215         EditorGUI.PropertyField( typeRect, gizmoTypeProperty, GUIContent.none );
216
217         Rect sizeLabelRect = new Rect( typeRect.xMax + 10, labelRect.yMin, 30, height );
218         GUI.Label( sizeLabelRect, "Size" );
219
220         Rect sizeRect = new Rect( sizeLabelRect.xMax + 5, labelRect.yMin, flexibleWidth * 0.3f, height );
221         EditorGUI.PropertyField( sizeRect, gizmoSizeProperty, GUIContent.none );
222
223         GUI.enabled = oldGUIEnabled;
224     }
File name: GizmoType.cs Copy
15         public static void Draw( Vector3 center, GizmoType type, Color color, float size )
16         {
17             Gizmos.color = color;
18
19             switch( type )
20             {
21             case GizmoType.Cube:
22                 Gizmos.DrawCube( center, Vector3.one * size );
23                 break;
24             case GizmoType.Sphere:
25                 Gizmos.DrawSphere( center, size * 0.5f );
26                 break;
27             case GizmoType.WireCube:
28                 Gizmos.DrawWireCube( center, Vector3.one * size );
29                 break;
30             case GizmoType.WireSphere:
31                 Gizmos.DrawWireSphere( center, size * 0.5f );
32                 break;
33             }
34         }

Download file with original file name:GizmoType

GizmoType 128 lượt xem

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