コード例 #1
0
        public override void OnInspectorGUI()
        {
            if (ToggleButtonStyleToggled == null)
            {
                ToggleButtonStyleNormal  = "Button";
                ToggleButtonStyleToggled = new GUIStyle(ToggleButtonStyleNormal);
                ToggleButtonStyleToggled.normal.background = ToggleButtonStyleToggled.active.background;
            }

            serializedObject.Update();

            SerializedProperty polygonProp  = serializedObject.FindProperty(POLYGON_PROP_NAME);
            SerializedProperty verticesProp = polygonProp.FindPropertyRelative(VERTICES_PROP_NAME);

            EditorGUILayout.PropertyField(verticesProp, includeChildren: true);

            // edit mode
            using (new EditorGUI.DisabledScope(targets.Length > 1)) {
                EditorGUILayout.EditorToolbarForTarget(EditorGUIUtility.TrTempContent("Edit Polygon"), target);
            }

            serializedObject.ApplyModifiedProperties();
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            if (s_Contents == null)
            {
                s_Contents = new Contents();
            }

            if (!EditorGUIUtility.wideMode)
            {
                EditorGUIUtility.wideMode   = true;
                EditorGUIUtility.labelWidth = EditorGUIUtility.currentViewWidth - 212;
            }

            serializedObject.Update();

            var occluder = target as Occluder;

            var oldType = occluder.Type;

            occluder.Type = (Occluder.OccluderType)EditorGUILayout.Popup(s_Contents.occluderType, (int)occluder.Type, s_Contents.occluderTypes);

            if (oldType != occluder.Type)
            {
                occluder.Mesh = null;
            }

            EditorGUI.indentLevel++;
            if (occluder.Type == Occluder.OccluderType.Mesh)
            {
                EditorGUILayout.EditorToolbarForTarget(s_Contents.editOccluderMesh, occluder);
                EditorGUILayout.PropertyField(m_Mesh, s_Contents.meshContent);
            }
            else if (occluder.Type == Occluder.OccluderType.Volume)
            {
                EditorGUILayout.BeginHorizontal();
                occluder.m_PrismSides = EditorGUILayout.IntField(EditorGUIUtility.TrTempContent("Prism sides"), occluder.m_PrismSides);
                if (occluder.m_PrismSides < 3)
                {
                    occluder.m_PrismSides = 3;
                }

                if (GUILayout.Button("Create"))
                {
                    var volume = new OccluderVolume();
                    volume.CreatePrism(occluder.m_PrismSides);
                    occluder.Mesh = volume.CalculateMesh();
                }
                EditorGUILayout.EndHorizontal();

                if (occluder.Mesh == null)
                {
                    EditorGUILayout.LabelField("Volume not yet created.");
                }
                else
                {
                    EditorGUILayout.EditorToolbarForTarget(s_Contents.editOccluderVolume, target);
                }
            }
            EditorGUI.indentLevel--;

            EditorGUILayout.PropertyField(m_Position, s_Contents.positionContent);
            EditorGUILayout.PropertyField(m_Rotation, s_Contents.rotationContent);
            EditorGUILayout.PropertyField(m_Scale, s_Contents.scaleContent);

            serializedObject.ApplyModifiedProperties();
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.EditorToolbarForTarget(target);

            DrawDefaultInspector();
        }