Exemple #1
0
        public static void OnInspectorGUI(Building building)
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(string.Format("BuildR Version {0}", BuildrVersion.NUMBER));

            BuildingEditor.GUIDivider();

            if (settings == null)
            {
                settings = building.settings;
            }

            Undo.RecordObject(settings, "Settings Modified");

            GUIContent[] guiContent = { new GUIContent("Building Settings"), new GUIContent("BuildR Settings") };
            mode = GUILayout.Toolbar(mode, guiContent, GUILayout.Width(BuildingEditor.MAIN_GUI_WIDTH));

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUILayout.Width(BuildingEditor.MAIN_GUI_WIDTH));
            switch (mode)
            {
            case 0:
                BuildingSettings(building);
                break;

            case 1:
                Editor editor = Editor.CreateEditor(settings);
                editor.DrawDefaultInspector();
                break;
            }

            if (BuildingEditor.directionalLightIssueDetected)
            {
                EditorGUILayout.BeginVertical("box");
                EditorGUILayout.HelpBox("Directional camera bias values may cause real-time shadows to render gaps", MessageType.Warning);
                if (GUILayout.Button("Fix"))
                {
                    Light[] lights     = GameObject.FindObjectsOfType <Light>();
                    int     lightCount = lights.Length;
                    for (int l = 0; l < lightCount; l++)
                    {
                        Light light = lights[l];
                        if (light.type != LightType.Directional)
                        {
                            continue;
                        }

                        light.shadowBias       = building.settings.recommendedBias;
                        light.shadowNormalBias = building.settings.recommendedNormalBias;
                    }
                    BuildingEditor.directionalLightIssueDetected = false;
                }
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndVertical();
        }
Exemple #2
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();
            }
        }