Esempio n. 1
0
    public override void OnInspectorGUI()
    {
        bool editing = (_data != null) ? _data.editing : true;

        EditorGUILayout.Space();

        GUILayout.BeginVertical(GUILayout.Width(400));
        if (editing)
        {
            if (_editMode.stage == BuildrEditMode.stages.start)
            {
                GUILayout.Space(10);
                EditorGUILayout.Space();
                if (Event.current.type == EventType.Repaint)
                {
                    _splashRect = GUILayoutUtility.GetLastRect();
                }
                _splashRect.width  = 300;
                _splashRect.height = 194;
                GUI.DrawTexture(_splashRect, (Texture2D)Resources.Load("splash"));
                GUILayout.Space(_splashRect.height);

                EditorGUILayout.LabelField("Welcome to BuildR.\nSelect from the following menu to begin a new building.", GUILayout.Height(30));

                if (GUILayout.Button("Start floorplan with basic square"))
                {
                    _editMode.StartBuilding();
                    _editMode.SetMode(BuildrEditMode.modes.addNewVolume);
                }

                if (GUILayout.Button("Start floorplan by drawing square"))
                {
                    _editMode.StartBuilding();
                    _editMode.SetMode(BuildrEditMode.modes.addNewVolumeByDraw);
                }

                if (GUILayout.Button("Start floorplan by drawing walls"))
                {
                    _editMode.StartBuilding();
                    _editMode.SetMode(BuildrEditMode.modes.addNewVolumeByPoints);
                }

                if (GUILayout.Button("Procedurally Generate Building"))
                {
                    _editMode.StartBuilding();
                    _editMode.SetStage(BuildrEditMode.stages.building);
                    _editMode.data.editing = false;
                }

                if (GUILayout.Button("Start floorplan from XML"))
                {
                    string xmlPath = EditorUtility.OpenFilePanel("Select the XML file...", "Assets/BuildR/Exported/", "xml");
                    if (xmlPath == "")
                    {
                        return;
                    }
                    BuildrData buildData = _editMode.gameObject.AddComponent <BuildrData>();
                    buildData.plan = ScriptableObject.CreateInstance <BuildrPlan>();
                    BuildrXMLImporter.Import(xmlPath, buildData);
                    _editMode.SetStage(BuildrEditMode.stages.building);
                }

                GUILayout.Space(10);

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Online Documentation"))
                {
                    Help.BrowseURL("http://buildr.jasperstocker.com/documentation/");
                }

                if (GUILayout.Button("Contact"))
                {
                    Help.BrowseURL("mailto:[email protected]");
                }
                GUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();

                //TITLE
                GUIStyle title = new GUIStyle(GUI.skin.label);
                title.fixedHeight      = 60;
                title.fixedWidth       = 223;
                title.alignment        = TextAnchor.UpperCenter;
                title.fontStyle        = FontStyle.Bold;
                title.normal.textColor = Color.white;
                EditorGUILayout.LabelField("Edit Mode", title);
                Texture2D facadeTexture = new Texture2D(1, 1);
                facadeTexture.SetPixel(0, 0, BuildrColours.BLUE);
                facadeTexture.Apply();
                Rect sqrPos = new Rect(0, 0, 0, 0);
                if (Event.current.type == EventType.Repaint)
                {
                    sqrPos = GUILayoutUtility.GetLastRect();
                }
                GUI.DrawTexture(sqrPos, facadeTexture);
                EditorGUI.LabelField(sqrPos, "Edit Mode", title);

                if (GUILayout.Button("Switch to Generate Mode", GUILayout.Width(165)))
                {
                    _editMode.stage = BuildrEditMode.stages.building;
                    _data.editing   = false;
                }
                EditorGUILayout.EndHorizontal();

                bool isLegal = _data.plan != null;
                if (isLegal)
                {
                    isLegal = !(_data.plan.illegalPoints.Length > 0);
                }
                if (isLegal)
                {
                    isLegal = _editMode.transform.localScale == Vector3.one;
                }

                EditorGUILayout.Space();

                GUILayout.BeginHorizontal();
                int currentStage = (int)_editMode.stage - 1;

                GUIContent[] guiContent = new GUIContent[9];
                for (int i = 0; i < 9; i++)
                {
                    guiContent[i] = new GUIContent(_stageToolbarTextures[i], _stageToolbar[i]);
                }
                int newStage = GUILayout.Toolbar(currentStage, guiContent, GUILayout.Width(400), GUILayout.Height(50));
                if (newStage != currentStage)
                {
                    _editMode.stage = (BuildrEditMode.stages)(newStage + 1);
                    _editMode.mode  = BuildrEditMode.modes.floorplan;//reset the floorplan mode
                    UpdateGui();
                }
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();

                if (_editMode.transform.localScale != Vector3.one)
                {
                    EditorGUILayout.HelpBox("The scale is not set to (1,1,1)!", MessageType.Error);
                    return;
                }

                if (_data.plan != null)
                {
                    if (_data.plan.illegalPoints.Length > 0)
                    {
                        EditorGUILayout.HelpBox("Your floorplan contains walls that intersect one another. " + "\nEnsure that no walls intersect another. " + "\nThe intersecting walls are highlighted red.", MessageType.Error);
                    }
                }

                switch (_editMode.stage)
                {
                case BuildrEditMode.stages.floorplan:
                    RenderTitle(_stageToolbar[0]);
                    BuildrEditModeFloorplan.InspectorGUI(_editMode, _data.plan);
                    break;

                case BuildrEditMode.stages.textures:
                    RenderTitle(_stageToolbar[1]);
                    BuildrEditModeTextures.InspectorGUI(_editMode, _data);
                    break;

                case BuildrEditMode.stages.facades:
                    RenderTitle(_stageToolbar[2]);
                    BuildrEditModeFacades.InspectorGUI(_editMode, _data);
                    break;

                case BuildrEditMode.stages.roofs:
                    RenderTitle(_stageToolbar[3]);
                    BuildrEditModeRoofs.InspectorGUI(_editMode, _data);
                    break;

                case BuildrEditMode.stages.details:
                    RenderTitle(_stageToolbar[4]);
                    BuildrEditModeDetails.InspectorGUI(_editMode, _data);
                    break;

                case BuildrEditMode.stages.interior:
                    RenderTitle(_stageToolbar[5]);
                    BuildrEditModeInterior.InspectorGUI(_editMode, _data);
                    break;

                case BuildrEditMode.stages.building:
                    RenderTitle(_stageToolbar[6]);
                    BuildrEditModeBuilding.InspectorGUI(_editMode, _data);
                    break;

                case BuildrEditMode.stages.options:
                    RenderTitle(_stageToolbar[7]);
                    BuildrEditModeOptions.InspectorGUI(_editMode, _data);
                    break;

                case BuildrEditMode.stages.export:
                    RenderTitle(_stageToolbar[8]);
                    BuildrEditModeExport.InspectorGUI(_editMode, _data);
                    break;
                }
            }
        }
        else
        {
            EditorGUILayout.BeginHorizontal();

            //TITLE
            GUIStyle title = new GUIStyle(GUI.skin.label);
            title.fixedHeight = 60;
            title.fixedWidth  = 223;
            title.alignment   = TextAnchor.UpperCenter;
            title.fontStyle   = FontStyle.Bold;
            EditorGUILayout.LabelField("", title);
            Texture2D facadeTexture = new Texture2D(1, 1);
            facadeTexture.SetPixel(0, 0, BuildrColours.BLUE);
            facadeTexture.Apply();
            Rect sqrPos = new Rect(0, 0, 0, 0);
            if (Event.current.type == EventType.Repaint)
            {
                sqrPos = GUILayoutUtility.GetLastRect();
            }
            GUI.DrawTexture(sqrPos, facadeTexture);
            EditorGUI.LabelField(sqrPos, "Genereate Mode (beta)", title);

            if (GUILayout.Button("Switch to Edit Mode", GUILayout.Width(165)))
            {
                _editMode.stage = BuildrEditMode.stages.generate;
                _data.editing   = true;
            }
            EditorGUILayout.EndHorizontal();

            //generating
            BuildrGenerateModeEditor.InspectorGUI(_editMode, _data);
        }
        GUILayout.EndVertical();

        if (Event.current.type == EventType.ValidateCommand)
        {
            switch (Event.current.commandName)
            {
            case "UndoRedoPerformed":
                GUI.changed = true;
                break;
            }
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(_editMode);
            if (_data != null)
            {
                EditorUtility.SetDirty(_data);//TODO: LOOK INTO ERROR HERE
            }
            _editMode.UpdateRender();
            UpdateGui();
            //Undo.RegisterSceneUndo("Building Modified");
        }
    }
Esempio n. 2
0
    public static void InspectorGUI(BuildrEditMode editMode, BuildrData _data)
    {
        int helpWidth = 20;

        data = _data;

        Undo.RecordObject(data, "Facade Modified");

        BuildrFacadeDesign[] facades = data.facades.ToArray();
        int numberOfFacades          = facades.Length;

        selectedFacade = Mathf.Clamp(selectedFacade, 0, numberOfFacades - 1);

        if (numberOfFacades == 0)
        {
            EditorGUILayout.HelpBox("There are no facade designs to show", MessageType.Info);
            return;
        }

        bool hasUnusedFacades = false;
        int  unusedIndex      = 0;

        //Check all facades have een used and warn if there are unused ones
        for (int i = 0; i < numberOfFacades; i++)
        {
            bool facadeUnused = true;
            foreach (BuildrVolume volume in data.plan.volumes)
            {
                if (volume.ContainsFacade(i))
                {
                    facadeUnused = false;
                    break;
                }
            }
            if (facadeUnused)
            {
                hasUnusedFacades = true;
                unusedIndex      = i;
                break;
            }
        }
        if (hasUnusedFacades)
        {
            EditorGUILayout.HelpBox("There are facade designs that are not applied to your building and are unused.\nGo to the Building section to apply them to a facade.\nCheck facade design \"" + facades[unusedIndex].name + "\"", MessageType.Warning);
        }

        //Facade Selector
        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Facade Design:", GUILayout.Width(145));
        string[] facadeNames = new string[numberOfFacades];
        for (int f = 0; f < numberOfFacades; f++)
        {
            facadeNames[f] = facades[f].name;
        }
        selectedFacade = EditorGUILayout.Popup(selectedFacade, facadeNames);
        BuildrFacadeDesign bFacade = facades[selectedFacade];

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Add", GUILayout.Width(60)))
        {
            data.facades.Add(new BuildrFacadeDesign("new facade " + numberOfFacades));
            facades = data.facades.ToArray();
            numberOfFacades++;
            selectedFacade = numberOfFacades - 1;
        }

        if (GUILayout.Button("Duplicate", GUILayout.Width(90)))
        {
            data.facades.Add(bFacade.Duplicate());
            facades = data.facades.ToArray();
            numberOfFacades++;
            selectedFacade = numberOfFacades - 1;
        }

        if (GUILayout.Button("Delete", GUILayout.Width(70)))
        {
            if (EditorUtility.DisplayDialog("Deleting Facade Design Entry", "Are you sure you want to delete this facade?", "Delete", "Cancel"))
            {
                data.RemoveFacadeDesign(bFacade);
                selectedFacade = 0;
                GUI.changed    = true;

                return;
            }
        }

        if (GUILayout.Button("Import", GUILayout.Width(71)))
        {
            string xmlPath = EditorUtility.OpenFilePanel("Select the XML file...", "Assets/BuildR/Exported/", "xml");
            if (xmlPath == "")
            {
                return;
            }
            BuildrXMLImporter.ImportFacades(xmlPath, _data);
            facades        = _data.facades.ToArray();
            selectedFacade = 0;
            GUI.changed    = true;
        }

        if (GUILayout.Button("Export", GUILayout.Width(71)))
        {
            string xmlPath = EditorUtility.SaveFilePanel("Export as...", "Assets/BuildR/Exported/", _data.name + "_facadeLibrary", "xml");
            if (xmlPath == "")
            {
                return;
            }
            BuildrXMLExporter.ExportFacades(xmlPath, _data);
            GUI.changed = true;
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        bFacade      = facades[selectedFacade];//reassign
        bFacade.name = EditorGUILayout.TextField("Facade Name: ", bFacade.name);


        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Facade Design Type:", GUILayout.Width(145));
        bFacade.type = (BuildrFacadeDesign.types)EditorGUILayout.EnumPopup(bFacade.type);
        if (GUILayout.Button("?", GUILayout.Width(helpWidth)))
        {
            string helpTitle = "Help - Design Type";
            string helpBody  = "This allows you to select the type of design you're using.\n" +
                               "Simple - the facade openings will be uniform\n" +
                               "Patterned - the facade openings will follow a pattern of defined dimensions and textures\n";
            EditorUtility.DisplayDialog(helpTitle, helpBody, "close");
        }
        EditorGUILayout.EndHorizontal();

        int numberOfTextures = data.textures.Count;

        string[] textureNames = new string[numberOfTextures];
        for (int t = 0; t < numberOfTextures; t++)
        {
            textureNames[t] = data.textures[t].name;
        }

        bFacade.hasWindows = EditorGUILayout.Toggle("Facade Has Bays", bFacade.hasWindows);

        if (bFacade.hasWindows)
        {
            if (bFacade.type == BuildrFacadeDesign.types.simple)
            {
                BuildrBay bbay = bFacade.simpleBay;

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Render Bay", GUILayout.Width(146));
                bool renderBayBack = EditorGUILayout.Toggle(bbay.renderBack);
                if (renderBayBack != bbay.renderBack)
                {
                    bbay.renderBack = renderBayBack;
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Bay Model", GUILayout.Width(146));
                bbay.bayModel = (GameObject)EditorGUILayout.ObjectField(bbay.bayModel, typeof(GameObject), false);
                if (GUILayout.Button("Clear", GUILayout.Width(70)))
                {
                    bbay.bayModel = null;
                }
                EditorGUILayout.EndHorizontal();

                float bbayopeningWidth = Mathf.Max(EditorGUILayout.FloatField("Opening Width", bbay.openingWidth), 0);
                if (bbayopeningWidth != bbay.openingWidth)
                {
                    bbay.openingWidth = bbayopeningWidth;
                }
                float bbayopeningHeight = Mathf.Max(EditorGUILayout.FloatField("Opening Height", bbay.openingHeight), 0);
                if (bbayopeningHeight > data.floorHeight)
                {
                    bbayopeningHeight = data.floorHeight;
                }
                if (bbayopeningHeight != bbay.openingHeight)
                {
                    bbay.openingHeight = bbayopeningHeight;
                }
                float bbayminimumBayWidth = Mathf.Max(EditorGUILayout.FloatField("Min. Spacing", bbay.minimumBayWidth), 0);
                if (bbayminimumBayWidth != bbay.minimumBayWidth)
                {
                    bbay.minimumBayWidth = bbayminimumBayWidth;
                }

                float bbayopeningWidthRatio = EditorGUILayout.Slider("Horizontal Space Ratio", bbay.openingWidthRatio, 0, 1);
                if (bbayopeningWidthRatio != bbay.openingWidthRatio)
                {
                    bbay.openingWidthRatio = bbayopeningWidthRatio;
                }
                float bbayopeningHeightRatio = EditorGUILayout.Slider("Vertical Space Ratio", bbay.openingHeightRatio, 0, 1);
                if (bbayopeningHeightRatio != bbay.openingHeightRatio)
                {
                    bbay.openingHeightRatio = bbayopeningHeightRatio;
                }

                float bbayopeningDepth = EditorGUILayout.Slider("Opening Depth", bbay.openingDepth, -depth, depth);
                if (bbayopeningDepth != bbay.openingDepth)
                {
                    bbay.openingDepth = bbayopeningDepth;
                }
                float bbaycolumnDepth = EditorGUILayout.Slider("Column Depth", bbay.columnDepth, -depth, depth);
                if (bbaycolumnDepth != bbay.columnDepth)
                {
                    bbay.columnDepth = bbaycolumnDepth;
                }
                float bbayrowDepth = EditorGUILayout.Slider("Row Depth", bbay.rowDepth, -depth, depth);
                if (bbayrowDepth != bbay.rowDepth)
                {
                    bbay.rowDepth = bbayrowDepth;
                }
                float bbaycrossDepth = EditorGUILayout.Slider("Cross Depth", bbay.crossDepth, -depth, depth);
                if (bbaycrossDepth != bbay.crossDepth)
                {
                    bbay.crossDepth = bbaycrossDepth;
                }

                int      numberOfTextureSlots = bbay.numberOfTextures;
                string[] titles = new string[numberOfTextureSlots];
                for (int bft = 0; bft < numberOfTextureSlots; bft++)
                {
                    titles[bft] = ((BuildrBay.TextureNames)(bft)).ToString();
                }

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Wall Surface:", GUILayout.Width(75));
                editTextureOnFacade = EditorGUILayout.Popup(editTextureOnFacade, titles);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Wall Texture:", GUILayout.Width(75));
                int newFacadeTextureID = EditorGUILayout.Popup(bbay.textureValues[editTextureOnFacade], textureNames);
                if (newFacadeTextureID != bbay.textureValues[editTextureOnFacade])
                {
                    bbay.textureValues[editTextureOnFacade] = newFacadeTextureID;
                }
                EditorGUILayout.EndHorizontal();
                BuildrTexture bTexture = data.textures[bbay.textureValues[editTextureOnFacade]];
                Texture2D     texture  = bTexture.texture;
                EditorGUILayout.BeginHorizontal();

                if (texture != null)
                {
                    GUILayout.Label(texture, GUILayout.Width(100), GUILayout.Height(100));
                }
                else
                {
                    EditorGUILayout.HelpBox("No texture assigned for '" + textureNames[bbay.textureValues[editTextureOnFacade]] + "', assign one in the Textures menu above", MessageType.Warning);
                }

                bbay.flipValues[editTextureOnFacade] = EditorGUILayout.Toggle("Flip 90\u00B0", bbay.flipValues[editTextureOnFacade]);

                EditorGUILayout.EndHorizontal();
            }
            else
            {
                //Patterned design GUI

                int numberOfBays       = bFacade.bayPattern.Count;
                int numberOfBayDesigns = data.bays.Count;

                EditorGUILayout.BeginHorizontal();
                GUILayout.BeginHorizontal("box");
                if (GUILayout.Button("Add New Bay Design"))
                {
                    BuildrBay newBay = new BuildrBay("new bay design " + (numberOfBayDesigns + 1));
                    data.bays.Add(newBay);
                    bFacade.bayPattern.Add(numberOfBayDesigns);
                    numberOfBays++;
                    selectedBayPatternIndex = numberOfBays - 1;
                    numberOfBayDesigns++;
                    GUI.changed = true;
                }
                EditorGUILayout.EndHorizontal();
                if (numberOfBays == 0 || data.bays.Count == 0)
                {
                    EditorGUILayout.HelpBox("There are no bay designs to show", MessageType.Info);
//                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.EndVertical();
                    return;
                }

                BuildrBay[] bays = new BuildrBay[numberOfBays];
                for (int i = 0; i < numberOfBays; i++)
                {
                    bays[i] = data.bays[bFacade.bayPattern[i]];
                }
                selectedBayPatternIndex = Mathf.Clamp(selectedBayPatternIndex, 0, numberOfBays - 1);

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.BeginHorizontal("box");
                string[] bayDesignNames = new string[data.bays.Count];
                for (int i = 0; i < numberOfBayDesigns; i++)
                {
                    bayDesignNames[i] = data.bays[i].name;
                }
                selectedBayDesign = EditorGUILayout.Popup(selectedBayDesign, bayDesignNames);
                if (GUILayout.Button("Add Selected"))
                {
                    bFacade.bayPattern.Add(selectedBayDesign);
                    GUI.changed = true;
                }
                if (GUILayout.Button("Duplicate Selected"))
                {
                    BuildrBay newBay = data.bays[selectedBayDesign].Duplicate();
                    data.bays.Add(newBay);
                    bFacade.bayPattern.Add(numberOfBayDesigns);
                    numberOfBays++;
                    selectedBayPatternIndex = numberOfBays - 1;
                    numberOfBayDesigns++;
                    GUI.changed = true;
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndHorizontal();

                GUILayout.BeginVertical("box");
                EditorGUILayout.LabelField("Bay Design Order:");
                var scrollbarHStyle    = new GUIStyle(GUI.skin.horizontalScrollbar);
                var scrollbarBackStyle = new GUIStyle();
                var scrollbarVStyle    = new GUIStyle(GUI.skin.verticalScrollbar);
                scrollbarVStyle.fixedHeight = scrollbarVStyle.fixedWidth = 0;
                bayDesignPatternScrollView  = EditorGUILayout.BeginScrollView(bayDesignPatternScrollView, false, false, scrollbarHStyle, scrollbarVStyle, scrollbarBackStyle, GUILayout.Height(40));
                List <string> bayNames = new List <string>();
                foreach (int bayIndex in bFacade.bayPattern)
                {
                    bayNames.Add(data.bays[bayIndex].name);
                }
                selectedBayPatternIndex = GUILayout.Toolbar(selectedBayPatternIndex, bayNames.ToArray());
                EditorGUILayout.EndScrollView();
                BuildrBay bBay = data.bays[bFacade.bayPattern[selectedBayPatternIndex]];

                EditorGUILayout.BeginHorizontal();

                EditorGUI.BeginDisabledGroup(selectedBayPatternIndex == 0);
                if (GUILayout.Button("<<", GUILayout.Width(40)))
                {
                    int bayDesignIndex = bFacade.bayPattern[selectedBayPatternIndex];
                    bFacade.bayPattern.RemoveAt(selectedBayPatternIndex);
                    bFacade.bayPattern.Insert(selectedBayPatternIndex - 1, bayDesignIndex);
                    selectedBayPatternIndex--;
                    GUI.changed = true;
                }
                EditorGUI.EndDisabledGroup();
                if (GUILayout.Button("Remove"))
                {
                    bFacade.bayPattern.RemoveAt(selectedBayPatternIndex);
                    GUI.changed = true;
                }
                if (GUILayout.Button("Delete"))
                {
                    if (EditorUtility.DisplayDialog("Deleting Bay Design Entry", "Are you sure you want to delete this bay?", "Delete", "Cancel"))
                    {
                        int deletedBayDesignIndex = bFacade.bayPattern[selectedBayPatternIndex];
                        Debug.Log("Delete Bay Design " + deletedBayDesignIndex);
                        Debug.Log("Delete Bay Design " + data.bays[deletedBayDesignIndex].name);
                        data.bays.RemoveAt(deletedBayDesignIndex);
                        int numberOfFacadeDesigns = data.facades.Count;
                        for (int i = 0; i < numberOfFacadeDesigns; i++)
                        {
                            BuildrFacadeDesign checkFacade = data.facades[i];
                            int bayPatternSize             = checkFacade.bayPattern.Count;
                            for (int j = 0; j < bayPatternSize; j++)
                            {
                                if (checkFacade.bayPattern[j] == deletedBayDesignIndex)
                                {
                                    checkFacade.bayPattern.RemoveAt(j);
                                    j--;
                                    bayPatternSize--;
                                }
                                else if (checkFacade.bayPattern[j] > deletedBayDesignIndex)
                                {
                                    checkFacade.bayPattern[j]--;
                                }
                            }
                        }
                        GUI.changed = true;
                    }
                }
                EditorGUI.BeginDisabledGroup(selectedBayPatternIndex == numberOfBays - 1);
                if (GUILayout.Button(">>", GUILayout.Width(40)))
                {
                    int bayDesignIndex = bFacade.bayPattern[selectedBayPatternIndex];
                    bFacade.bayPattern.Insert(selectedBayPatternIndex + 2, bayDesignIndex);
                    bFacade.bayPattern.RemoveAt(selectedBayPatternIndex);
                    selectedBayPatternIndex++;
                    GUI.changed = true;
                }
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();

                GUILayout.Space(10);
                EditorGUILayout.BeginVertical("box");
                bBay.name = EditorGUILayout.TextField("Name: ", bBay.name);
                bool bBayisOpening = EditorGUILayout.Toggle("Has Opening", bBay.isOpening);
                if (bBayisOpening != bBay.isOpening)
                {
                    bBay.isOpening = bBayisOpening;
                }

                bool bBayRenderBack = EditorGUILayout.Toggle("Render Back", bBay.renderBack);
                if (bBayRenderBack != bBay.renderBack)
                {
                    bBay.renderBack = bBayRenderBack;
                }

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Bay Model", GUILayout.Width(146));
                bBay.bayModel = (GameObject)EditorGUILayout.ObjectField(bBay.bayModel, typeof(GameObject), false);
                if (GUILayout.Button("Clear", GUILayout.Width(70)))
                {
                    bBay.bayModel = null;
                }
                EditorGUILayout.EndHorizontal();

                float bBayopeningWidth = Mathf.Max(EditorGUILayout.FloatField("Opening Width", bBay.openingWidth), 0);
                if (bBayopeningWidth != bBay.openingWidth)
                {
                    bBay.openingWidth = bBayopeningWidth;
                }
                float bBayopeningHeight = Mathf.Clamp(EditorGUILayout.FloatField("Opening Height", bBay.openingHeight), 0, data.floorHeight);
                if (bBayopeningHeight != bBay.openingHeight)
                {
                    bBay.openingHeight = bBayopeningHeight;
                }

                float bBayminimumBayWidth = Mathf.Max(EditorGUILayout.FloatField("Bay Spacing Width", bBay.minimumBayWidth), 0);
                if (bBayminimumBayWidth != bBay.minimumBayWidth)
                {
                    bBay.minimumBayWidth = bBayminimumBayWidth;
                }

                float bBayopeningWidthRatio = EditorGUILayout.Slider("Horizontal Space Ratio", bBay.openingWidthRatio, 0, 1);
                if (bBayopeningWidthRatio != bBay.openingWidthRatio)
                {
                    bBay.openingWidthRatio = bBayopeningWidthRatio;
                }
                float bBayopeningHeightRatio = EditorGUILayout.Slider("Vertical Space Ratio", bBay.openingHeightRatio, 0, 1);
                if (bBayopeningHeightRatio != bBay.openingHeightRatio)
                {
                    bBay.openingHeightRatio = bBayopeningHeightRatio;
                }

                float bBayopeningDepth = EditorGUILayout.Slider("Opening Depth", bBay.openingDepth, -depth, depth);
                if (bBayopeningDepth != bBay.openingDepth)
                {
                    bBay.openingDepth = bBayopeningDepth;
                }
                float bBaycolumnDepth = EditorGUILayout.Slider("Column depth", bBay.columnDepth, -depth, depth);
                if (bBaycolumnDepth != bBay.columnDepth)
                {
                    bBay.columnDepth = bBaycolumnDepth;
                }
                float bBayrowDepth = EditorGUILayout.Slider("Row depth", bBay.rowDepth, -depth, depth);
                if (bBayrowDepth != bBay.rowDepth)
                {
                    bBay.rowDepth = bBayrowDepth;
                }
                float bBaycrossDepth = EditorGUILayout.Slider("Cross depth", bBay.crossDepth, -depth, depth);
                if (bBaycrossDepth != bBay.crossDepth)
                {
                    bBay.crossDepth = bBaycrossDepth;
                }

                //BAY TEXTURES

                int      numberOfTextureSlots = bBay.numberOfTextures;
                string[] titles = new string[numberOfTextureSlots];
                for (int bft = 0; bft < numberOfTextureSlots; bft++)
                {
                    titles[bft] = ((BuildrBay.TextureNames)(bft)).ToString();
                }

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Surface:", GUILayout.Width(75));
                editTextureOnFacade = EditorGUILayout.Popup(editTextureOnFacade, titles);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Texture:", GUILayout.Width(75));
                bBay.textureValues[editTextureOnFacade] = EditorGUILayout.Popup(bBay.textureValues[editTextureOnFacade], textureNames);
                EditorGUILayout.EndHorizontal();
                BuildrTexture bTexture = data.textures[bBay.textureValues[editTextureOnFacade]];
                Texture2D     texture  = bTexture.texture;
                EditorGUILayout.BeginHorizontal();

                if (texture != null)
                {
                    GUILayout.Label(texture, GUILayout.Width(100), GUILayout.Height(100));
                }
                else
                {
                    EditorGUILayout.HelpBox("No texture assigned for '" + textureNames[bBay.textureValues[editTextureOnFacade]] + "', assign one in the Textures menu above", MessageType.Warning);
                }

                bFacade.flipValues[editTextureOnFacade] = EditorGUILayout.Toggle("Flip 90\u00B0", bFacade.flipValues[editTextureOnFacade]);

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
            }
        }
        else
        {
            editTextureOnFacade = 7;
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Surface:", GUILayout.Width(75));
            EditorGUILayout.LabelField("Wall");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Texture:", GUILayout.Width(75));
            int newFacadeTexture = EditorGUILayout.Popup(bFacade.simpleBay.textureValues[editTextureOnFacade], textureNames);
            if (newFacadeTexture != bFacade.simpleBay.textureValues[editTextureOnFacade])
            {
                bFacade.simpleBay.textureValues[editTextureOnFacade] = newFacadeTexture;
            }
            EditorGUILayout.EndHorizontal();
            BuildrTexture bTexture = data.textures[bFacade.simpleBay.textureValues[editTextureOnFacade]];
            Texture2D     texture  = bTexture.texture;
            EditorGUILayout.BeginHorizontal();

            if (texture != null)
            {
                GUILayout.Label(texture, GUILayout.Width(100), GUILayout.Height(100));
            }
            else
            {
                EditorGUILayout.HelpBox("No texture assigned for '" + textureNames[bFacade.simpleBay.textureValues[editTextureOnFacade]] + "', assign one in the Textures menu above", MessageType.Warning);
            }

            bFacade.simpleBay.flipValues[editTextureOnFacade] = EditorGUILayout.Toggle("Flip 90\u00B0", bFacade.simpleBay.flipValues[editTextureOnFacade]);

            EditorGUILayout.EndHorizontal();
        }
    }
Esempio n. 3
0
    public static void InspectorGUI(BuildrEditMode _editMode, BuildrData _data)
    {
        data = _data;
        BuildrTexture[] textures         = data.textures.ToArray();
        int             numberOfTextures = textures.Length;

        selectedTexture = Mathf.Clamp(selectedTexture, 0, numberOfTextures - 1);
        int currentSelectedTexture = selectedTexture;//keep tack of what we had selected to reset fields if changed

        Undo.RecordObject(data, "Texture Modified");

        if (numberOfTextures == 0)
        {
            EditorGUILayout.HelpBox("There are no textures to show", MessageType.Info);
            if (GUILayout.Button("Add New"))
            {
                data.textures.Add(new BuildrTexture("new texture " + numberOfTextures));
                numberOfTextures++;
                selectedTexture = numberOfTextures - 1;
            }
            return;
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Texture", GUILayout.Width(75));
        string[] textureNames = new string[numberOfTextures];
        for (int t = 0; t < numberOfTextures; t++)
        {
            textureNames[t] = textures[t].name;
        }
        selectedTexture = EditorGUILayout.Popup(selectedTexture, textureNames);
        EditorGUILayout.EndHorizontal();

        BuildrTexture bTexture = textures[selectedTexture];

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.Space();

        if (GUILayout.Button("Add New", GUILayout.Width(81)))
        {
            data.textures.Add(new BuildrTexture("new texture " + numberOfTextures));
            numberOfTextures++;
            selectedTexture = numberOfTextures - 1;
        }


        if (GUILayout.Button("Duplicate", GUILayout.Width(90)))
        {
            data.textures.Add(bTexture.Duplicate());
            numberOfTextures++;
            selectedTexture = numberOfTextures - 1;
        }

        if (GUILayout.Button("Delete", GUILayout.Width(71)))
        {
            if (EditorUtility.DisplayDialog("Deleting Texture Entry", "Are you sure you want to delete this texture?", "Delete", "Cancel"))
            {
                data.RemoveTexture(bTexture);
                selectedTexture = 0;
                GUI.changed     = true;

                return;
            }
        }

        if (GUILayout.Button("Import", GUILayout.Width(71)))
        {
            string xmlPath = EditorUtility.OpenFilePanel("Select the XML file...", "Assets/BuildR/Exported/", "xml");
            if (xmlPath == "")
            {
                return;
            }
            BuildrXMLImporter.ImportTextures(xmlPath, _data);
            textures        = data.textures.ToArray();
            selectedTexture = 0;
            GUI.changed     = true;
        }

        if (GUILayout.Button("Export", GUILayout.Width(71)))
        {
            string xmlPath = EditorUtility.SaveFilePanel("Export as...", "Assets/BuildR/Exported/", _data.name + "_textureLibrary", "xml");
            if (xmlPath == "")
            {
                return;
            }
            BuildrXMLExporter.ExportTextures(xmlPath, _data);
            GUI.changed = true;
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        textures     = data.textures.ToArray();
        textureNames = new string[numberOfTextures];
        for (int t = 0; t < numberOfTextures; t++)
        {
            textureNames[t] = textures[t].name;
        }
        bTexture = textures[selectedTexture];//reassign

        string   textureName = bTexture.name;
        GUIStyle redText     = new GUIStyle(GUI.skin.textField);

        if (textureName.Contains(" "))
        {
            redText.focused.textColor = Color.red;
            textureName = EditorGUILayout.TextField("Name", textureName, redText);
        }
        else
        {
            redText.focused.textColor = defaultCol;
            textureName = EditorGUILayout.TextField("Name", textureName, redText);
        }
        bTexture.name = textureName;

        bool conflictingName = false;

        for (int i = 0; i < textureNames.Length; i++)
        {
            if (selectedTexture != i)
            {
                if (textureNames[i] == bTexture.name)
                {
                    conflictingName = true;
                }
            }
        }

        if (conflictingName)
        {
            EditorGUILayout.HelpBox("You have named this texture the same as another.", MessageType.Warning);
        }


        if (currentSelectedTexture != selectedTexture)
        {
            GUIUtility.hotControl      = 0;
            GUIUtility.keyboardControl = 0;
        }

        bTexture.type = (BuildrTexture.Types)EditorGUILayout.EnumPopup("Type", bTexture.type);

        switch (bTexture.type)
        {
        case BuildrTexture.Types.Basic:

            if (bTexture.texture != null)
            {
                string          texturePath     = AssetDatabase.GetAssetPath(bTexture.texture);
                TextureImporter textureImporter = (TextureImporter)AssetImporter.GetAtPath(texturePath);

                if (!textureImporter.isReadable)
                {
                    EditorGUILayout.HelpBox("The texture you have selected is not readable." + "\nPlease select the readable checkbox under advanced texture settings." + "\nOr move this texture to the BuildR texture folder and reimport.", MessageType.Error);
                }
            }

            //Shader Time
            Shader[]      tempshaders = (Shader[])Resources.FindObjectsOfTypeAll(typeof(Shader));
            List <string> shaderNames = new List <string>(ShaderProperties.NAMES);
            foreach (Shader shader in tempshaders)
            {
                if (!string.IsNullOrEmpty(shader.name) && !shader.name.StartsWith("__") && !shader.name.Contains("hidden"))
                {
                    shaderNames.Add(shader.name);
                }
            }
            int selectedShaderIndex    = shaderNames.IndexOf(bTexture.material.shader.name);
            int newSelectedShaderIndex = EditorGUILayout.Popup("Shader", selectedShaderIndex, shaderNames.ToArray());
            if (selectedShaderIndex != newSelectedShaderIndex)
            {
                bTexture.material.shader = Shader.Find(shaderNames[newSelectedShaderIndex]);
            }

            Shader selectedShader = bTexture.material.shader;
            int    propertyCount  = ShaderUtil.GetPropertyCount(selectedShader);

            for (int s = 0; s < propertyCount; s++)
            {
                ShaderUtil.ShaderPropertyType propertyTpe = ShaderUtil.GetPropertyType(selectedShader, s);
                string shaderPropertyName = ShaderUtil.GetPropertyName(selectedShader, s);
                switch (propertyTpe)
                {
                case ShaderUtil.ShaderPropertyType.TexEnv:
                    Texture shaderTexture    = bTexture.material.GetTexture(shaderPropertyName);
                    Texture newShaderTexture = (Texture)EditorGUILayout.ObjectField(shaderPropertyName, shaderTexture, typeof(Texture), false);
                    if (shaderTexture != newShaderTexture)
                    {
                        bTexture.material.SetTexture(shaderPropertyName, newShaderTexture);
                    }
                    break;

                case ShaderUtil.ShaderPropertyType.Color:
                    Color shaderColor    = bTexture.material.GetColor(shaderPropertyName);
                    Color newShaderColor = EditorGUILayout.ColorField(shaderPropertyName, shaderColor);
                    if (shaderColor != newShaderColor)
                    {
                        bTexture.material.SetColor(shaderPropertyName, newShaderColor);
                    }
                    break;

                case ShaderUtil.ShaderPropertyType.Float:
                    float shaderFloat    = bTexture.material.GetFloat(shaderPropertyName);
                    float newShaderFloat = EditorGUILayout.FloatField(shaderPropertyName, shaderFloat);
                    if (shaderFloat != newShaderFloat)
                    {
                        bTexture.material.SetFloat(shaderPropertyName, newShaderFloat);
                    }
                    break;

                case ShaderUtil.ShaderPropertyType.Range:
                    float shaderRange    = bTexture.material.GetFloat(shaderPropertyName);
                    float rangeMin       = ShaderUtil.GetRangeLimits(selectedShader, s, 1);
                    float rangeMax       = ShaderUtil.GetRangeLimits(selectedShader, s, 2);
                    float newShaderRange = EditorGUILayout.Slider(shaderPropertyName, shaderRange, rangeMin, rangeMax);
                    if (shaderRange != newShaderRange)
                    {
                        bTexture.material.SetFloat(shaderPropertyName, newShaderRange);
                    }
                    break;

                case ShaderUtil.ShaderPropertyType.Vector:
                    Vector3 shaderVector    = bTexture.material.GetVector(shaderPropertyName);
                    Vector3 newShaderVector = EditorGUILayout.Vector3Field(shaderPropertyName, shaderVector);
                    if (shaderVector != newShaderVector)
                    {
                        bTexture.material.SetVector(shaderPropertyName, newShaderVector);
                    }
                    break;
                }
            }

            bool tiled = EditorGUILayout.Toggle("Is Tiled", bTexture.tiled);
            if (tiled != bTexture.tiled)
            {
                bTexture.tiled = tiled;
            }
            if (bTexture.tiled)
            {
                bool patterned = EditorGUILayout.Toggle("Has Pattern", bTexture.patterned);
                if (patterned != bTexture.patterned)
                {
                    bTexture.patterned = patterned;
                }
            }
            else
            {
                bTexture.patterned = false;
            }

            if (bTexture.texture == null)
            {
                return;
            }

            Vector2 textureUnitSize = bTexture.textureUnitSize;
            if (bTexture.tiled)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("texture width", GUILayout.Width(75)); //, GUILayout.Width(42));
                textureUnitSize.x = EditorGUILayout.FloatField(bTexture.textureUnitSize.x, GUILayout.Width(25));
                EditorGUILayout.LabelField("metres", GUILayout.Width(40));        //, GUILayout.Width(42));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("texture height", GUILayout.Width(75));//, GUILayout.Width(42));
                textureUnitSize.y = EditorGUILayout.FloatField(bTexture.textureUnitSize.y, GUILayout.Width(25));
                EditorGUILayout.LabelField("metres", GUILayout.Width(40));
                EditorGUILayout.EndHorizontal();
                if (bTexture.textureUnitSize != textureUnitSize)
                {
                    bTexture.textureUnitSize = textureUnitSize;
                }
            }

            Vector2 tileUnitSize = bTexture.tileUnitUV;
            if (bTexture.patterned)
            {
                float minWidth  = 2 / bTexture.texture.width;
                float minHeight = 2 / bTexture.texture.height;

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("unit width", GUILayout.Width(75));
                float tileUnitSizex = EditorGUILayout.Slider(tileUnitSize.x, minWidth, 1.0f);
                if (tileUnitSizex != tileUnitSize.x)
                {
                    tileUnitSize.x = tileUnitSizex;
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("unit height", GUILayout.Width(75));
                float tileUnitSizey = EditorGUILayout.Slider(tileUnitSize.y, minHeight, 1.0f);
                if (tileUnitSizey != tileUnitSize.y)
                {
                    tileUnitSize.y = tileUnitSizey;
                }
                EditorGUILayout.EndHorizontal();
                bTexture.tileUnitUV = tileUnitSize;

                EditorGUILayout.Space();
            }

            const int previewTextureUnitSize = 120;
            const int previewTileUnitSize    = 59;
            const int previewTileUnitPadding = 2;
            const int previewPadding         = 25;

            EditorGUILayout.BeginHorizontal();
            if (bTexture.tiled)
            {
                EditorGUILayout.LabelField("1 Metre Squared", GUILayout.Width(previewTextureUnitSize));
            }
            GUILayout.Space(previewPadding);
            if (bTexture.patterned)
            {
                EditorGUILayout.LabelField("Texture Pattern Units", GUILayout.Width(previewTileUnitSize * 2));
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();


            if (Event.current.type == EventType.Repaint)
            {
                texturePreviewPostion = GUILayoutUtility.GetLastRect();
            }

            if (bTexture.tiled)
            {
                Rect previewRect = new Rect(texturePreviewPostion.x, texturePreviewPostion.y, previewTextureUnitSize, previewTextureUnitSize);
                Rect sourceRect  = new Rect(0, 0, (1.0f / textureUnitSize.x), (1.0f / textureUnitSize.y));

                Graphics.DrawTexture(previewRect, bTexture.texture, sourceRect, 0, 0, 0, 0);
            }

            if (bTexture.patterned)
            {
                Rect previewRect = new Rect(previewTextureUnitSize + previewPadding, 0, previewTileUnitSize, previewTileUnitSize);
                Rect sourceRect  = new Rect(0, tileUnitSize.y, tileUnitSize.x, tileUnitSize.y);

                previewRect.x += texturePreviewPostion.x;
                previewRect.y += texturePreviewPostion.y;

                Graphics.DrawTexture(previewRect, bTexture.texture, sourceRect, 0, 0, 0, 0);

                sourceRect.x  += tileUnitSize.x;
                previewRect.x += previewTileUnitSize + previewTileUnitPadding;

                Graphics.DrawTexture(previewRect, bTexture.texture, sourceRect, 0, 0, 0, 0);

                sourceRect.x  += -tileUnitSize.x;
                sourceRect.y  += -tileUnitSize.y;
                previewRect.x += -(previewTileUnitSize + previewTileUnitPadding);
                previewRect.y += previewTileUnitSize + previewTileUnitPadding;

                Graphics.DrawTexture(previewRect, bTexture.texture, sourceRect, 0, 0, 0, 0);

                sourceRect.x  += tileUnitSize.x;
                previewRect.x += previewTileUnitSize + previewTileUnitPadding;

                Graphics.DrawTexture(previewRect, bTexture.texture, sourceRect, 0, 0, 0, 0);
            }

            if (!bTexture.tiled)
            {
                EditorGUILayout.LabelField("Tile texture");

                EditorGUILayout.BeginHorizontal();
                int currentXTiles = bTexture.tiledX;
                GUILayout.Label("tile x", GUILayout.Width(38));
                currentXTiles = EditorGUILayout.IntField(currentXTiles, GUILayout.Width(20));
                if (GUILayout.Button("+", GUILayout.Width(25)))
                {
                    currentXTiles++;
                }
                EditorGUI.BeginDisabledGroup(currentXTiles < 2);
                if (GUILayout.Button("-", GUILayout.Width(25)))
                {
                    currentXTiles--;
                }
                EditorGUI.EndDisabledGroup();
                bTexture.tiledX = currentXTiles;

                int currentYTiles = bTexture.tiledY;
                GUILayout.Label("tile y", GUILayout.Width(38));
                currentYTiles = EditorGUILayout.IntField(currentYTiles, GUILayout.Width(20));
                if (GUILayout.Button("+", GUILayout.Width(25)))
                {
                    currentYTiles++;
                }
                EditorGUI.BeginDisabledGroup(currentYTiles < 2);
                if (GUILayout.Button("-", GUILayout.Width(25)))
                {
                    currentYTiles--;
                }
                EditorGUI.EndDisabledGroup();
                bTexture.tiledY = currentYTiles;
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(10);
                EditorGUILayout.Space();
                if (Event.current.type == EventType.Repaint)
                {
                    texturePreviewPostion = GUILayoutUtility.GetLastRect();
                }

                Rect previewRect = new Rect(texturePreviewPostion.x, texturePreviewPostion.y, previewTextureUnitSize, previewTextureUnitSize);
                Rect sourceRect  = new Rect(0, 0, currentXTiles, currentYTiles);

                Graphics.DrawTexture(previewRect, bTexture.texture, sourceRect, 0, 0, 0, 0);
            }

            GUILayout.Space(previewTextureUnitSize);

            break;

        case BuildrTexture.Types.Substance:

            bTexture.proceduralMaterial = (ProceduralMaterial)EditorGUILayout.ObjectField("Procedural Material", bTexture.proceduralMaterial, typeof(ProceduralMaterial), false);

            if (bTexture.proceduralMaterial != null)
            {
                ProceduralMaterial pMat = bTexture.proceduralMaterial;
                GUILayout.Label(pMat.GetGeneratedTexture(pMat.mainTexture.name), GUILayout.Width(400));
            }
            else
            {
                EditorGUILayout.HelpBox("There is no substance material set.", MessageType.Error);
            }
            break;

        case BuildrTexture.Types.User:
            bTexture.userMaterial = (Material)EditorGUILayout.ObjectField("User Material", bTexture.userMaterial, typeof(Material), false);

            if (bTexture.userMaterial != null)
            {
                Material mat = bTexture.userMaterial;
                GUILayout.Label(mat.mainTexture, GUILayout.Width(400));
            }
            else
            {
                EditorGUILayout.HelpBox("There is no substance material set.", MessageType.Error);
            }
            break;
        }
    }
Esempio n. 4
0
    public static void InspectorGUI(BuildrEditMode editMode, BuildrData _data)
    {
        data = _data;
        Undo.RecordObject(data, "Roof Modified");

        BuildrRoofDesign[] roofs = data.roofs.ToArray();
        int numberOfRoofs        = roofs.Length;

        selectedRoof = Mathf.Clamp(selectedRoof, 0, numberOfRoofs - 1);

        if (GUILayout.Button("Add new roof design"))
        {
            data.roofs.Add(new BuildrRoofDesign("new roof " + numberOfRoofs));
            roofs = data.roofs.ToArray();
            numberOfRoofs++;
            selectedRoof = numberOfRoofs - 1;
        }
        if (numberOfRoofs == 0)
        {
            EditorGUILayout.HelpBox("There are no roof designs to show", MessageType.Info);
            return;
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Design: ", GUILayout.Width(75));
        string[] roofNames = new string[numberOfRoofs];
        for (int f = 0; f < numberOfRoofs; f++)
        {
            roofNames[f] = roofs[f].name;
        }
        selectedRoof = EditorGUILayout.Popup(selectedRoof, roofNames);

        BuildrRoofDesign bRoof = roofs[selectedRoof];

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Delete", GUILayout.Width(75)))
        {
            if (EditorUtility.DisplayDialog("Deleting Roof Design Entry", "Are you sure you want to delete this roof?", "Delete", "Cancel"))
            {
                data.RemoveRoofDesign(bRoof);
                selectedRoof = 0;
                GUI.changed  = true;

                return;
            }
        }

        if (GUILayout.Button("Import", GUILayout.Width(71)))
        {
            string xmlPath = EditorUtility.OpenFilePanel("Select the XML file...", "Assets/BuildR/Exported/", "xml");
            if (xmlPath == "")
            {
                return;
            }
            BuildrXMLImporter.ImportRoofs(xmlPath, _data);
            GUI.changed = true;
        }

        if (GUILayout.Button("Export", GUILayout.Width(71)))
        {
            string xmlPath = EditorUtility.SaveFilePanel("Export as...", "Assets/BuildR/Exported/", _data.name + "_roofLibrary", "xml");
            if (xmlPath == "")
            {
                return;
            }
            BuildrXMLExporter.ExportRoofs(xmlPath, _data);
            GUI.changed = true;
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Name: ", GUILayout.Width(75));
        bRoof.name = EditorGUILayout.TextField(bRoof.name);
        EditorGUILayout.EndHorizontal();

        //ROOF STYLE
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Style: ", GUILayout.Width(75));
        BuildrRoofDesign.styles bRoofstyle = (BuildrRoofDesign.styles)EditorGUILayout.EnumPopup(bRoof.style);
        if (bRoofstyle != bRoof.style)
        {
            bRoof.style = bRoofstyle;
        }
        EditorGUILayout.EndHorizontal();

        if (bRoof.style != BuildrRoofDesign.styles.flat && bRoof.style != BuildrRoofDesign.styles.mansard && bRoof.style != BuildrRoofDesign.styles.steepled && bRoof.style != BuildrRoofDesign.styles.hipped)
        {
            EditorGUILayout.HelpBox("Please note that this design can only be used on sections with 4 points." +
                                    "\nComplex sections can only use the Flat, Mansard and Steeple designs.", MessageType.Warning);
        }

        if (bRoof.style != BuildrRoofDesign.styles.flat)
        {
            bRoof.height = Mathf.Max(EditorGUILayout.FloatField("Height", bRoof.height), 0);
        }

        if (bRoof.style == BuildrRoofDesign.styles.mansard)
        {
            bRoof.floorDepth = Mathf.Max(EditorGUILayout.FloatField("Base Depth", bRoof.floorDepth), 0);
            bRoof.depth      = Mathf.Max(EditorGUILayout.FloatField("Top Depth", bRoof.depth), 0);
        }

        if (bRoof.style == BuildrRoofDesign.styles.barrel)
        {
            bRoof.barrelSegments = Mathf.Max(EditorGUILayout.IntField("Barrel Segments", bRoof.barrelSegments), 3);
        }

        if (bRoof.style == BuildrRoofDesign.styles.barrel || bRoof.style == BuildrRoofDesign.styles.gabled || bRoof.style == BuildrRoofDesign.styles.hipped)
        {
            //two directions of the ridge
            bRoof.direction = Mathf.Clamp(bRoof.direction, 0, 1);
            string[] options = new string[2] {
                "short", "long"
            };
            bRoof.direction = EditorGUILayout.Popup(bRoof.direction, options);
        }

        if (bRoof.style == BuildrRoofDesign.styles.leanto || bRoof.style == BuildrRoofDesign.styles.sawtooth)
        {
            //four directions of the ridge
            bRoof.direction = Mathf.Clamp(bRoof.direction, 0, 3);
            string[] options = new string[4] {
                "left", "up", "right", "down"
            };
            bRoof.direction = EditorGUILayout.Popup(bRoof.direction, options);
        }

        if (bRoof.style == BuildrRoofDesign.styles.sawtooth)
        {
            bRoof.sawtoothTeeth = Mathf.Max(EditorGUILayout.IntField("Number of 'teeth'", bRoof.sawtoothTeeth), 2);
        }

        //PARAPET
        bool bRoofparapet = EditorGUILayout.Toggle("Has Parapet", bRoof.parapet);

        if (bRoofparapet != bRoof.parapet)
        {
            bRoof.parapet = bRoofparapet;
        }
        if (bRoof.parapet)
        {
            float bRoofparapetHeight = Mathf.Max(EditorGUILayout.FloatField("Parapet Width", bRoof.parapetHeight), 0);
            if (bRoofparapetHeight != bRoof.parapetHeight)
            {
                bRoof.parapetHeight = bRoofparapetHeight;
            }
            float bRoofparapetFrontDepth = Mathf.Max(EditorGUILayout.FloatField("Parapet Front Depth", bRoof.parapetFrontDepth), 0);
            if (bRoofparapetFrontDepth != bRoof.parapetFrontDepth)
            {
                bRoof.parapetFrontDepth = bRoofparapetFrontDepth;
            }
            float bRoofparapetBackDepth = Mathf.Max(EditorGUILayout.FloatField("Parapet Back Depth", bRoof.parapetBackDepth), 0);
            if (bRoofparapetBackDepth != bRoof.parapetBackDepth)
            {
                bRoof.parapetBackDepth = bRoofparapetBackDepth;
            }

            if (bRoof.parapetStyle == BuildrRoofDesign.parapetStyles.fancy)//NOT IMPLMENTED...YET...
            {
                EditorGUILayout.HelpBox("This allows you to specify a model mesh that will be used to create a parapet." +
                                        "\nIt should not repeat as Buildr will attempt to repeat the style to fit the length of the facade.", MessageType.Info);
                bRoof.parapetDesign      = (Mesh)EditorGUILayout.ObjectField("Parapet Mesh", bRoof.parapetDesign, typeof(Mesh), false);
                bRoof.parapetDesignWidth = Mathf.Max(EditorGUILayout.FloatField("Parapet Design Width", bRoof.parapetDesignWidth), 0);
            }
        }

        //DORMERS
        if (bRoof.style == BuildrRoofDesign.styles.mansard)
        {
            bool bRoofhasDormers = EditorGUILayout.Toggle("Has Dormers", bRoof.hasDormers);
            if (bRoofhasDormers != bRoof.hasDormers)
            {
                bRoof.hasDormers = bRoofhasDormers;
            }
            if (bRoof.hasDormers)
            {
                float bRoofdormerWidth = Mathf.Max(EditorGUILayout.FloatField("Dormer Width", bRoof.dormerWidth), 0);
                if (bRoofdormerWidth != bRoof.dormerWidth)
                {
                    bRoof.dormerWidth = bRoofdormerWidth;
                }
                float bRoofdormerHeight = Mathf.Clamp(EditorGUILayout.FloatField("Dormer Height", bRoof.dormerHeight), 0, bRoof.height);
                if (bRoofdormerHeight != bRoof.dormerHeight)
                {
                    bRoof.dormerHeight = bRoofdormerHeight;
                }
                float bRoofdormerRoofHeight = Mathf.Clamp(EditorGUILayout.FloatField("Dormer Roof Height", bRoof.dormerRoofHeight), 0, bRoof.dormerHeight);
                if (bRoofdormerRoofHeight != bRoof.dormerRoofHeight)
                {
                    bRoof.dormerRoofHeight = bRoofdormerRoofHeight;
                }
                float bRoofminimumDormerSpacing = Mathf.Max(EditorGUILayout.FloatField("Dormer Minimum Spacing", bRoof.minimumDormerSpacing), 0);
                if (bRoofminimumDormerSpacing != bRoof.minimumDormerSpacing)
                {
                    bRoof.minimumDormerSpacing = bRoofminimumDormerSpacing;
                }
                float bRoofdormerHeightRatio = EditorGUILayout.Slider("Dormer Height Ratio", bRoof.dormerHeightRatio, 0, 1);
                if (bRoofdormerHeightRatio != bRoof.dormerHeightRatio)
                {
                    bRoof.dormerHeightRatio = bRoofdormerHeightRatio;
                }
            }
        }

        //TEXTURES
        int numberOfTextures = data.textures.Count;

        string[] textureNames = new string[numberOfTextures];
        for (int t = 0; t < numberOfTextures; t++)
        {
            textureNames[t] = data.textures[t].name;
        }

        int numberOfTextureSlots = bRoof.numberOfTextures;

        string[] titles = new string[numberOfTextureSlots];
        for (int brt = 0; brt < numberOfTextureSlots; brt++)
        {
            titles[brt] = ((BuildrRoofDesign.textureNames)(brt)).ToString();
        }

        editTextureOnRoof = EditorGUILayout.Popup("Texture Surface:", editTextureOnRoof, titles);

        int selectedRoofTexture = EditorGUILayout.Popup("Selected Texture:", bRoof.textureValues[editTextureOnRoof], textureNames);

        if (selectedRoofTexture != bRoof.textureValues[editTextureOnRoof])
        {
            bRoof.textureValues[editTextureOnRoof] = selectedRoofTexture;
        }
        BuildrTexture bTexture = data.textures[bRoof.textureValues[editTextureOnRoof]];
        Texture2D     texture  = bTexture.texture;

        EditorGUILayout.BeginHorizontal();

        if (texture != null)
        {
            GUILayout.Label(texture, GUILayout.Width(100), GUILayout.Height(100));
        }
        else
        {
            EditorGUILayout.HelpBox("No texture assigned for '" + textureNames[bRoof.textureValues[editTextureOnRoof]] + "', assign one in the Textures menu above", MessageType.Warning);
        }

        bRoof.flipValues[editTextureOnRoof] = EditorGUILayout.Toggle("Flip 90\u00B0", bRoof.flipValues[editTextureOnRoof]);

        EditorGUILayout.EndHorizontal();
    }