Esempio n. 1
0
        public static void OnInspectorGUI_S(RoomStyle roomStyle)
        {
            BuildingEditor.BuildRHeader("Room Style");


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name", GUILayout.Width(120));
            string newName = EditorGUILayout.DelayedTextField(roomStyle.name);

            if (newName != roomStyle.name)
            {
                nameError = BuildingEditorUtils.RenameAsset(roomStyle, newName);
            }
            EditorGUILayout.EndHorizontal();

            if (nameError.Length > 0)
            {
                EditorGUILayout.HelpBox(nameError, MessageType.Error);
            }

            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Surfaces");
            roomStyle.floorSurface   = (Surface)EditorGUILayout.ObjectField("Floor", roomStyle.floorSurface, typeof(Surface), false);
            roomStyle.wallSurface    = (Surface)EditorGUILayout.ObjectField("Wall", roomStyle.wallSurface, typeof(Surface), false);
            roomStyle.ceilingSurface = (Surface)EditorGUILayout.ObjectField("Ceiling", roomStyle.ceilingSurface, typeof(Surface), false);
            EditorGUILayout.EndVertical();
        }
Esempio n. 2
0
        public static void OnInspectorGUI_S(Surface surface, string title = "Surface")
        {
            BuildingEditor.BuildRHeader(title);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name", GUILayout.Width(120));
            string newName = EditorGUILayout.DelayedTextField(surface.name);

            if (newName != surface.name)
            {
                nameError = BuildingEditorUtils.RenameAsset(surface, newName);
            }
            EditorGUILayout.EndHorizontal();

            if (nameError.Length > 0)
            {
                EditorGUILayout.HelpBox(nameError, MessageType.Error);
            }

            if (!surface.readable)
            {
                string warningContent = "Texture used is not set to readable";
                EditorGUILayout.HelpBox(warningContent, MessageType.Error);

                if (GUILayout.Button("Make surface readable"))
                {
                    string          texturePath     = AssetDatabase.GetAssetPath(surface.previewTexture);
                    TextureImporter textureImporter = (TextureImporter)AssetImporter.GetAtPath(texturePath);
                    if (textureImporter != null)
                    {
                        textureImporter.isReadable = true;
                        AssetDatabase.ImportAsset(texturePath);
                        surface.MarkModified();
                    }
                }
            }

            EditorGUILayout.Space();
        }
Esempio n. 3
0
        public static void OnInspectorGUI_S(Facade facade)
        {
            BuildingEditor.BuildRHeader("Facade Design");


            EditorGUILayout.BeginHorizontal(GUILayout.Width(BuildingEditor.MAIN_GUI_WIDTH));
            EditorGUILayout.LabelField("Name", GUILayout.Width(120));
            string newName = EditorGUILayout.DelayedTextField(facade.name);

            if (newName != facade.name)
            {
                NAME_ERROR = BuildingEditorUtils.RenameAsset(facade, newName);
            }
            EditorGUILayout.EndHorizontal();

            if (NAME_ERROR.Length > 0)
            {
                EditorGUILayout.HelpBox(NAME_ERROR, MessageType.Error);
            }

            BuildingEditor.GUIDivider();
            SHOW_BASE_PATTERN = EditorGUILayout.Foldout(SHOW_BASE_PATTERN, "Base Facade Pattern");
            if (SHOW_BASE_PATTERN)
            {
                EditorGUILayout.BeginHorizontal("Box", GUILayout.Width(BuildingEditor.MAIN_GUI_WIDTH));
                float bottomWidth = Mathf.Min((SECTION_PREVIEW_SIZE + 17) * facade.baseWidth, BuildingEditor.MAIN_GUI_WIDTH - SECTION_PREVIEW_SIZE);
                EditorGUILayout.BeginVertical(GUILayout.Width(bottomWidth));

                BasePatternEditor(facade);

                EditorGUILayout.BeginHorizontal(GUILayout.Width(bottomWidth), GUILayout.Height(SECTION_PREVIEW_SIZE));
                if (GUILayout.Button("-", GUILayout.Width(SECTION_PREVIEW_SIZE), GUILayout.Height(SECTION_PREVIEW_SIZE)))
                {
                    facade.baseWidth--;
                }
                EditorGUILayout.LabelField(String.Format("Pattern\nWidth:\n{0}", facade.baseWidth), GUILayout.Width(SECTION_PREVIEW_SIZE), GUILayout.Height(SECTION_PREVIEW_SIZE));
                GUILayout.Space(bottomWidth - SECTION_PREVIEW_SIZE * 3);
                if (GUILayout.Button("+", GUILayout.Width(SECTION_PREVIEW_SIZE), GUILayout.Height(SECTION_PREVIEW_SIZE)))
                {
                    facade.baseWidth++;
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.EndVertical();

                float rightHeight = facade.baseHeight * SECTION_PREVIEW_SIZE + SECTION_PREVIEW_SIZE;
                EditorGUILayout.BeginVertical(GUILayout.Width(SECTION_PREVIEW_SIZE), GUILayout.Height(rightHeight));

                if (GUILayout.Button("+", GUILayout.Width(SECTION_PREVIEW_SIZE), GUILayout.Height(SECTION_PREVIEW_SIZE)))
                {
                    facade.baseHeight++;
                }
                EditorGUILayout.LabelField(String.Format("Pattern\nHeight:\n{0}", facade.baseHeight), GUILayout.Width(SECTION_PREVIEW_SIZE), GUILayout.Height(SECTION_PREVIEW_SIZE));
                GUILayout.Space(rightHeight - SECTION_PREVIEW_SIZE * 3);
                if (GUILayout.Button("-", GUILayout.Width(SECTION_PREVIEW_SIZE), GUILayout.Height(SECTION_PREVIEW_SIZE)))
                {
                    facade.baseHeight--;
                }
                GUILayout.Space(40);

                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();

                //TODO add back in
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Ground Floor Pattern");
                facade.hasGroundFloorPattern = EditorGUILayout.Toggle(facade.hasGroundFloorPattern);
                EditorGUILayout.EndHorizontal();

                EditorGUI.BeginDisabledGroup(!facade.hasGroundFloorPattern);
                GroundPatternEditor(facade);
                EditorGUI.EndDisabledGroup();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Pattern Anchor");
                facade.patternAnchors = (Facade.PatternAnchors)EditorGUILayout.EnumPopup(facade.patternAnchors);
                EditorGUILayout.EndHorizontal();

                //                EditorGUILayout.BeginHorizontal();
                //                EditorGUILayout.LabelField("Tiled Pattern");
                //                facade.tiled = EditorGUILayout.Toggle(facade.tiled);
                //                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Stretch Mode");
                facade.stretchMode = (Facade.StretchModes)EditorGUILayout.EnumPopup(facade.stretchMode);
                EditorGUILayout.EndHorizontal();


                EditorGUILayout.BeginVertical("box");

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("String Course");
                facade.stringCourse = EditorGUILayout.Toggle(facade.stringCourse);
//                if(GUILayout.Button("?", GUILayout.Width(20)))
//                    EditorUtility.DisplayDialog("Help", "Me", "No");
                EditorGUILayout.EndHorizontal();

                EditorGUI.BeginDisabledGroup(!facade.stringCourse);


                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Height");
                facade.stringCourseHeight = EditorGUILayout.Slider(facade.stringCourseHeight, 0.01f, 0.5f);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Depth");
                facade.stringCourseDepth = EditorGUILayout.Slider(facade.stringCourseDepth, 0.01f, 0.5f);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Vertical Position");
                facade.stringCoursePosition = EditorGUILayout.Slider(facade.stringCoursePosition, 0, 1);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Surface");
                facade.stringCourseSurface = EditorGUILayout.ObjectField(facade.stringCourseSurface, typeof(Surface), false) as Surface;
                EditorGUILayout.EndHorizontal();

                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Random Mode");
                facade.randomisationMode = (Facade.RandomisationModes)EditorGUILayout.EnumPopup(facade.randomisationMode);
                EditorGUILayout.EndHorizontal();
            }
        }
Esempio n. 4
0
        public override void OnInspectorGUI()
        {
            BuildingEditor.BuildRHeader("Wall Section");

            Undo.RecordObject(_wallSection, "Wall Section Modification");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name", GUILayout.Width(80));
            string newName = EditorGUILayout.DelayedTextField(_wallSection.name);

            if (newName != _wallSection.name)
            {
                BuildingEditorUtils.RenameAsset(_wallSection, newName);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Has Opening");
            _wallSection.hasOpening = EditorGUILayout.Toggle(_wallSection.hasOpening);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Is Door");
            _wallSection.isDoor = EditorGUILayout.Toggle(_wallSection.isDoor);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Vertical Restriction");
            _wallSection.verticalRestriction = (WallSection.VerticalRestrictions)EditorGUILayout.EnumPopup(_wallSection.verticalRestriction);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Custom Models");

            //TODO SOON!
//            EditorGUILayout.BeginHorizontal();
//            EditorGUILayout.LabelField("Wall Section Model");
//            _wallSection.model = EditorGUILayout.ObjectField(_wallSection.model, typeof(Model), false) as Model;
//            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Opening Model");
            EditorGUILayout.BeginVertical();
            _wallSection.portal       = EditorGUILayout.ObjectField(_wallSection.portal, typeof(Portal), false) as Portal;
            _wallSection.openingModel = EditorGUILayout.ObjectField(_wallSection.openingModel, typeof(Model), false) as Model;
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Balcony Model");
            _wallSection.balconyModel = EditorGUILayout.ObjectField(_wallSection.balconyModel, typeof(BuildR2.Model), false) as Model;
            EditorGUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(_wallSection.balconyModel == null);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Balcony Height");
            _wallSection.balconyHeight = EditorGUILayout.Slider(_wallSection.balconyHeight, 0.01f, 1);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Balcony Side Overhang");
            _wallSection.balconySideOverhang = EditorGUILayout.Slider(_wallSection.balconySideOverhang, 0, 0.56f);
            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Shutter Model");
            _wallSection.shutterModel = EditorGUILayout.ObjectField(_wallSection.shutterModel, typeof(Model), false) as Model;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Dimentions Type");
            _wallSection.dimensionType = (WallSection.DimensionTypes)EditorGUILayout.EnumPopup(_wallSection.dimensionType);
            EditorGUILayout.EndHorizontal();

            if (_wallSection.dimensionType == WallSection.DimensionTypes.Absolute)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Opening Width");
                _wallSection.openingWidth = EditorGUILayout.Slider(_wallSection.openingWidth, _settings.minimumWindowWidth, _settings.maximumWindowWidth);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Opening Height");
                _wallSection.openingHeight = EditorGUILayout.Slider(_wallSection.openingHeight, _settings.minimumWindowHeight, _settings.maximumWindowHeight);
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Opening Width");
                _wallSection.openingWidth = EditorGUILayout.Slider(_wallSection.openingWidth, 0, 1);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Opening Height");
                _wallSection.openingHeight = EditorGUILayout.Slider(_wallSection.openingHeight, 0, 1);
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Opening Depth");
            _wallSection.openingDepth = EditorGUILayout.Slider(_wallSection.openingDepth, _settings.minimumWindowDepth, _settings.maximumWindowDepth);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Opening Width Ratio");
            _wallSection.openingWidthRatio = EditorGUILayout.Slider(_wallSection.openingWidthRatio, 0, 1);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Opening Height Ratio");
            _wallSection.openingHeightRatio = EditorGUILayout.Slider(_wallSection.openingHeightRatio, 0, 1);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Opening is Arched");
            _wallSection.isArched = EditorGUILayout.Toggle(_wallSection.isArched);
            EditorGUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(!_wallSection.isArched);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Arch Height");
            _wallSection.archHeight = EditorGUILayout.Slider(_wallSection.archHeight, 0.1f, _wallSection.openingHeight);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Arch Curve");
            _wallSection.archCurve = EditorGUILayout.Slider(_wallSection.archCurve, 0, 1);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Arch Segments");
            _wallSection.archSegments = EditorGUILayout.IntSlider(_wallSection.archSegments, 1, 20);
            EditorGUILayout.EndHorizontal();

            EditorGUI.EndDisabledGroup();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Bay Extruded");
            _wallSection.bayExtruded = EditorGUILayout.Toggle(_wallSection.bayExtruded);
            EditorGUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(!_wallSection.bayExtruded);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Bay Extrusion");
            _wallSection.bayExtrusion = EditorGUILayout.Slider(_wallSection.bayExtrusion, 0.1f, 1);
            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(!_wallSection.bayExtruded);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Bay Bevel");
            _wallSection.bayBevel = EditorGUILayout.Slider(_wallSection.bayBevel, 0.1f, 1);
            EditorGUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();


            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Sill");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Enabled");
            _wallSection.extrudedSill = EditorGUILayout.Toggle(_wallSection.extrudedSill);
            EditorGUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(!_wallSection.extrudedSill);

            Vector3 sillDimentions = _wallSection.extrudedSillDimentions;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Overshoot");
            sillDimentions.x = EditorGUILayout.FloatField(sillDimentions.x);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Height");
            sillDimentions.y = EditorGUILayout.FloatField(sillDimentions.y);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Depth");
            sillDimentions.z = EditorGUILayout.FloatField(sillDimentions.z);
            EditorGUILayout.EndHorizontal();

            _wallSection.extrudedSillDimentions = sillDimentions;

            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();


            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Lintel");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Enabled");
            _wallSection.extrudedLintel = EditorGUILayout.Toggle(_wallSection.extrudedLintel);
            EditorGUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(!_wallSection.extrudedLintel);

            Vector3 lintelDimenstions = _wallSection.extrudedLintelDimentions;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Overshoot");
            lintelDimenstions.x = EditorGUILayout.FloatField(lintelDimenstions.x);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Height");
            lintelDimenstions.y = EditorGUILayout.FloatField(lintelDimenstions.y);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Depth");
            lintelDimenstions.z = EditorGUILayout.FloatField(lintelDimenstions.z);
            EditorGUILayout.EndHorizontal();

            _wallSection.extrudedLintelDimentions = lintelDimenstions;

            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Opening Frame");
            _wallSection.openingFrame = EditorGUILayout.Toggle(_wallSection.openingFrame);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Size");
            _wallSection.openingFrameSize = EditorGUILayout.Slider(_wallSection.openingFrameSize, 0.02f, 0.25f);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Extrusion");
            _wallSection.openingFrameExtrusion = EditorGUILayout.Slider(_wallSection.openingFrameExtrusion, 0.0f, 0.1f);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();


            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.LabelField("Surfaces");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Wall");
            _wallSection.wallSurface = EditorGUILayout.ObjectField(_wallSection.wallSurface, typeof(Surface), false) as Surface;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Opening");
            _wallSection.openingSurface = EditorGUILayout.ObjectField(_wallSection.openingSurface, typeof(Surface), false) as Surface;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Sill");
            _wallSection.sillSurface = EditorGUILayout.ObjectField(_wallSection.sillSurface, typeof(Surface), false) as Surface;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Ceiling");
            _wallSection.ceilingSurface = EditorGUILayout.ObjectField(_wallSection.ceilingSurface, typeof(Surface), false) as Surface;
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                Repaint();
                _wallSection.GenereateData();
                UpdatePreview();
                _wallSection.SaveData();

                UpdatePreview();

                EditorUtility.SetDirty(_wallSection);
            }
        }
Esempio n. 5
0
        public override void OnInspectorGUI()
        {
            //            BuildRSettings settings = BuildRSettings.GetSettings();

            Undo.RecordObject(_gable, "Gable Modification");

            BuildingEditor.BuildRHeader("Gable");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name", GUILayout.Width(80));
            string newName = EditorGUILayout.DelayedTextField(_gable.name);

            if (newName != _gable.name)
            {
                BuildingEditorUtils.RenameAsset(_gable, newName);
            }
            EditorGUILayout.EndHorizontal();

            //            EditorGUILayout.BeginHorizontal();
            //            EditorGUILayout.LabelField("Thickness");
            //            _gable.thickness = EditorGUILayout.Slider(_gable.thickness, 0.1f, 5);
            //            EditorGUILayout.EndHorizontal();

            //            EditorGUILayout.BeginHorizontal();
            //            EditorGUILayout.LabelField("Additional Height");
            //            _gable.additionalHeight = EditorGUILayout.Slider(_gable.additionalHeight, 0.0f, 10f);
            //            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Surface");
            _gable.surface = EditorGUILayout.ObjectField(_gable.surface, typeof(Surface), false) as Surface;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Gable Segments");
            _gable.segments = EditorGUILayout.IntSlider(_gable.segments, 1, 24);
            EditorGUILayout.EndHorizontal();

            int partCount = _gable.count;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(string.Format("Gable Parts: {0}", partCount));
            if (GUILayout.Button("Add Part", GUILayout.Width(90)))
            {
                _gable.AddNewPart();
                partCount = _gable.count;
            }
            EditorGUILayout.EndHorizontal();

            for (int p = 0; p < partCount; p++)
            {
                GablePart part = _gable[p];

                EditorGUILayout.BeginVertical("Box");
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(string.Format("Part {0}", p + 1));

                if (GUILayout.Button("Insert", GUILayout.Width(70)))
                {
                    _gable.InsertNewPart(p);
                    break;
                }

                if (GUILayout.Button("Remove", GUILayout.Width(70)))
                {
                    _gable.RemovePartAt(p);
                    break;//just kill the loop for now
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Type", GUILayout.Width(50));
                part.type = (GablePart.Types)EditorGUILayout.EnumPopup(part.type, GUILayout.Width(90));
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Size", GUILayout.Width(50));

                Vector2 size = part.size;
                switch (part.type)
                {
                case GablePart.Types.Horizonal:
                    //                        size.x = EditorGUILayout.DelayedFloatField(size.x);
                    size.x = EditorGUILayout.FloatField("\t", size.x);
                    break;

                case GablePart.Types.Vertical:
                    size.y = EditorGUILayout.FloatField("\t", size.y);
                    break;

                default:
                    size = EditorGUILayout.Vector2Field("", size);
                    break;
                }
                part.size = size;
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();

                _gable[p] = part;//reassign to check for modification
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Add Part", GUILayout.Width(90)))
            {
                _gable.AddNewPart();
            }
            EditorGUILayout.EndHorizontal();

            if (GUI.changed)
            {
                Repaint();
                EditorUtility.SetDirty(_gable);
            }

            //            DrawDefaultInspector();
        }
Esempio n. 6
0
        public override void OnInspectorGUI()
        {
            if (_portal.type == Portal.Types.Window)
            {
                Undo.RecordObject(_portal, "Window Modification");
                BuildingEditor.BuildRHeader("Window");
            }
            else
            {
                Undo.RecordObject(_portal, "Door Modification");
                BuildingEditor.BuildRHeader("Door");
            }

            GUILayout.Space(5);


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name", GUILayout.Width(120));
            string newName = EditorGUILayout.DelayedTextField(_portal.name);

            if (newName != _portal.name)
            {
                nameError = BuildingEditorUtils.RenameAsset(_portal, newName);
            }
            EditorGUILayout.EndHorizontal();

            if (nameError.Length > 0)
            {
                EditorGUILayout.HelpBox(nameError, MessageType.Error);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Type", GUILayout.Width(120));
            _portal.type = (Portal.Types)EditorGUILayout.EnumPopup(_portal.type);
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.TextArea("", GUI.skin.horizontalSlider);

            EditorGUILayout.BeginHorizontal();
            if (_portal.defaultFrameTexture != null)
            {
                GUILayout.Label(_portal.defaultFrameTexture.previewTexture, GUILayout.Width(75), GUILayout.Height(75));
            }
            EditorGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Default Frame Texture");
            EditorGUILayout.BeginHorizontal();
            _portal.defaultFrameTexture = EditorGUILayout.ObjectField(_portal.defaultFrameTexture, typeof(Surface), false) as Surface;
            if (GUILayout.Button("?", GUILayout.Width(20)))
            {
                EditorUtility.DisplayDialog("Help Text", "TODO", "ok");
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField("Default Panel Texture");
            EditorGUILayout.BeginHorizontal();
            _portal.defaultPanelTexture = EditorGUILayout.ObjectField(_portal.defaultPanelTexture, typeof(Surface), false, GUILayout.Width(75), GUILayout.Height(75)) as Surface;
            if (GUILayout.Button("?", GUILayout.Width(20)))
            {
                EditorUtility.DisplayDialog("Help Text", "TODO", "ok");
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.TextArea("", GUI.skin.horizontalSlider);

            treeScroll = EditorGUILayout.BeginScrollView(treeScroll);
            DivisionInspector(_portal.root, 0);
            EditorGUILayout.EndScrollView();

            _portal.CheckModification();

//            GUILayout.Space(100);
//            base.OnInspectorGUI();
        }
Esempio n. 7
0
        public override void OnInteractivePreviewGUI(Rect r, GUIStyle background)
        {
            List <Surface> surfaces = _portal.UsedSurfaces();
            int            matCount = surfaces.Count;

//            if(_portal.hasBlankSurfaces) matCount++;
            Material[] mats = new Material[matCount];
//            int blankOffset = 0;
//            if(_portal.hasBlankSurfaces)
//            {
//                mats[0] = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Material.mat");
//                matCount--;
//                blankOffset++;
//            }
            for (int m = 0; m < matCount; m++)
            {
//                Debug.Log(_portal);
//                Debug.Log(m);
//                Debug.Log(m - blankOffset);
//                Debug.Log(_portal.usedSurfaces[m - blankOffset]);
//                Debug.Log(_portal.usedSurfaces[m - blankOffset].name);
//                mats[m + blankOffset] = _portal.usedSurfaces[m].material;
                mats[m] = surfaces[m].material;
            }
            Vector3 max    = _portal.previewMesh.bounds.size;
            float   radius = Mathf.Max(max.x, Mathf.Max(max.y, max.z)) * 1.333f;

            BuildingEditorUtils.OnInteractivePreviewGUI(ref _mPrevRender, ref _drag, _portal.previewMesh, mats, r, background, radius, _plane, _mat);
//            _drag = Drag2D(_drag, r);
//
//            if (_mPrevRender == null)
//                _mPrevRender = new PreviewRenderUtility();
//
//            Vector3 max = _portal.previewMesh.bounds.size;
//            float radius = Mathf.Max(max.x, Mathf.Max(max.y, max.z)) * 1.333f;
//            float dist = radius / (Mathf.Sin(_mPrevRender.m_Camera.fieldOfView * Mathf.Deg2Rad));
//            _mPrevRender.m_Camera.transform.position = Vector2.zero;
//            _mPrevRender.m_Camera.transform.rotation = Quaternion.Euler(new Vector3(-_drag.y, -_drag.x, 0));
//            _mPrevRender.m_Camera.transform.position = _mPrevRender.m_Camera.transform.forward * -dist;
//            _mPrevRender.m_Camera.nearClipPlane = 0.1f;
//            _mPrevRender.m_Camera.farClipPlane = 500;
//
//            _mPrevRender.m_Light[0].intensity = 0.5f;
//            _mPrevRender.m_Light[0].transform.rotation = Quaternion.Euler(30f, 30f, 0f);
//            _mPrevRender.m_Light[1].intensity = 0.5f;
//
//            _mPrevRender.BeginPreview(r, background);
//
//            if (_plane != null && _mat != null)//background
//            {
//                Matrix4x4 matrix = Matrix4x4.TRS(new Vector3(-25, -25, 1), Quaternion.identity, new Vector3(10, 10, 1));
//                _mPrevRender.DrawMesh(_plane, matrix, _mat, 0);
//                _mPrevRender.m_Camera.Render();
//            }
//
//            /*
//                    Material mat = _wallSection.usedMaterials[i];
//                    if(mat == null)
//                        mat = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Material.mat");*/
//
//            Surface[] surfaces = _portal.usedSurfaces;
//            for(int m = 0; m < surfaces.Length; m++)
//            {
//                Material mat = surfaces[m].material;
//                if(mat == null)
//                    mat = AssetDatabase.GetBuiltinExtraResource<Material>("Default-Material.mat");
//                _mPrevRender.DrawMesh(_portal.previewMesh, Matrix4x4.identity, mat, m);
//            }
//
//
//
//
//            //            for (int i = 0; i < 4; i++)
//            //            {
//            //                if (_portal.usedMaterials[0] != null)
//            ////                    continue;
////            _mPrevRender.DrawMesh(_portal.previewMesh, Matrix4x4.identity, AssetDatabase.GetBuiltinExtraResource<Material>("Default-Material.mat"), 0);
////            }
//
//            _mPrevRender.m_Camera.Render();
//            Texture texture = _mPrevRender.EndPreview();
//
//            GUI.DrawTexture(r, texture);
        }
Esempio n. 8
0
        public override void OnInspectorGUI()
        {
            Undo.RecordObject(_model, "Model Modification");

            BuildingEditor.BuildRHeader("Model");

            EditorGUILayout.BeginVertical(GUILayout.Width(BuildingEditor.MAIN_GUI_WIDTH));

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name", GUILayout.Width(80));
            string newName = EditorGUILayout.DelayedTextField(_model.name);

            if (newName != _model.name)
            {
                BuildingEditorUtils.RenameAsset(_model, newName);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Type", GUILayout.Width(80));
            _model.type = (Model.Types)EditorGUILayout.EnumPopup(_model.type);
            EditorGUILayout.EndHorizontal();

            if (_model.type == Model.Types.Mesh && _model.GetMeshes().Length > 1)
            {
                EditorGUILayout.HelpBox("Mesh mode only available for subjects with a single mesh", MessageType.Warning);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Subject", GUILayout.Width(80));
            _model.subject = EditorGUILayout.ObjectField(_model.subject, typeof(GameObject), false) as GameObject;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Model Anchor", GUILayout.Width(150));
            _model.anchor = EditorGUILayout.Vector3Field("", _model.anchor);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Bounds", GUILayout.Width(150));
            _model.userBounds = EditorGUILayout.BoundsField(_model.userBounds);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            if (GUILayout.Button("Reset Bounds"))
            {
                _model.userBounds = _model.modelBounds;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Model Normal", GUILayout.Width(150));
            _model.normal = EditorGUILayout.Vector3Field("", _model.normal);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Rotation Offset", GUILayout.Width(150));
            _model.userRotation = EditorGUILayout.Vector3Field("", _model.userRotation);
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Refresh Data"))
            {
                _model.UpdateInternalData();
            }

            EditorGUILayout.EndVertical();
        }