Пример #1
0
        private string MaterialFilePath()
        {
            BuildRSettings settings         = BuildRSettings.GetSettings();
            string         settingsLocation = UnityEditor.AssetDatabase.GetAssetPath(settings);

            if (string.IsNullOrEmpty(settingsLocation))
            {
                return("");
            }
            int    dirLength      = settingsLocation.Length - (settings.name.Length + 6);//+6 for .asset
            string settingsFolder = settingsLocation.Substring(0, dirLength);

            string tempTextureFolder = Concat(settingsFolder, MATERIAL_FOLDER_PATH);

            string dataPath              = Application.dataPath;
            int    dataPathLength        = dataPath.Length;
            string projectPath           = Application.dataPath.Substring(0, dataPathLength - 6);//cull assets folder reference
            string fullTempTextureFolder = Concat(projectPath, tempTextureFolder);

            if (!Directory.Exists(fullTempTextureFolder))
            {
                Directory.CreateDirectory(fullTempTextureFolder);
            }
            return(Concat(tempTextureFolder, "buildr_atlas_", name, ".mat"));
        }
Пример #2
0
        public static WallSection CreateWallSection(string name = null, string directory = null)
        {
            WallSection wallSection = CreateInstance <WallSection>();

            if (Application.isPlaying)
            {
                return(wallSection);
            }
            if (name != null)
            {
                wallSection.name = name;
            }
#if UNITY_EDITOR
            if (directory == null)
            {
                UnityEditor.AssetDatabase.CreateAsset(wallSection, AssetCreator.GeneratePath("newWallSection.asset", "WallSections"));
            }
            else
            {
                UnityEditor.AssetDatabase.CreateAsset(wallSection, Path.Combine(directory, "newWallSection.asset"));
            }
#endif

            BuildRSettings settings = BuildRSettings.GetSettings();
            wallSection._openingWidthAbs  = settings.defaultWindowWidth;
            wallSection._openingHeightAbs = settings.defaultWindowHeight;
            wallSection._openingDepth     = settings.defaultWindowDepth;

            return(wallSection);
        }
Пример #3
0
 public static BuildRSettings GetSettings()
 {
     if (building != null)
     {
         return(building.getSettings);
     }
     return(BuildRSettings.GetSettings());
 }
Пример #4
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();
        }
Пример #5
0
        private void OnEnable()
        {
            _wallSection = (WallSection)target;
            _plane       = Primitives.Plane(10);
            _settings    = BuildingEditor.GetSettings();

            UpdatePreview();
//            InteractivePreview.Reset();
        }
Пример #6
0
        private static string SurfacePath(string filename)
        {
            BuildRSettings settings       = BuildingEditor.GetSettings();
            string         pluginLocation = settings.pluginLocation;
            string         dirPath        = Path.Combine(pluginLocation, "Surfaces/");

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }
            return(AssetDatabase.GenerateUniqueAssetPath(Path.Combine(dirPath, filename)));
        }
Пример #7
0
        public static GUIDIconData GenerateGUIDIconData(string guid)
        {
            GUIDIconData output = new GUIDIconData();

#if UNITY_EDITOR
            if (settings == null)
            {
                settings = BuildRSettings.GetSettings();
            }
            string settingsLocation = UnityEditor.AssetDatabase.GetAssetPath(settings);
            if (string.IsNullOrEmpty(settingsLocation))
            {
                return(output);
            }
            //            string settingsFolder = settingsLocation.Split(new[] { settings.name }, StringSplitOptions.RemoveEmptyEntries)[0];
            int    dirLength      = settingsLocation.Length - (settings.name.Length + 6);//+6 for .asset
            string settingsFolder = settingsLocation.Substring(0, dirLength);

            string tempTextureFolder = Concat(settingsFolder, IconFolderPath);//Path.Combine(settingsFolder, IconFolderPath);

            if (!TEMP_TEXTURE_FOLDER_EXISTS)
            {
                string dataPath              = Application.dataPath;
                int    dataPathLength        = dataPath.Length;
                string projectPath           = Application.dataPath.Substring(0, dataPathLength - 6); //cull assets folder reference
                string fullTempTextureFolder = Concat(projectPath, tempTextureFolder);                //Path.Combine(projectPath, tempTextureFolder);
                if (!Directory.Exists(fullTempTextureFolder))
                {
                    Directory.CreateDirectory(fullTempTextureFolder);
                }
                TEMP_TEXTURE_FOLDER_EXISTS = true;
            }
//            string textureFilename = Concat(guid, ".jpg");
            string tempTexturePath       = Concat(tempTextureFolder, guid, ".jpg");//Path.Combine(tempTextureFolder, textureFilename);
            bool   tempTextureFileExists = File.Exists(tempTexturePath);

            string assetPath = string.IsNullOrEmpty(guid) ? "" : UnityEditor.AssetDatabase.GUIDToAssetPath(guid);

            output.assetPath             = assetPath;
            output.tempTexturePath       = tempTexturePath;
            output.tempTextureFolder     = tempTextureFolder;
            output.tempTextureFileExists = tempTextureFileExists;
#endif

            return(output);
        }
Пример #8
0
        public static string GeneratePath(string filename, string foldername)
        {
#if UNITY_EDITOR
            string basePath      = BuildRSettings.GetSettings().newObjectLocation;
            string folderPath    = string.Format("{0}{1}", basePath, foldername);
            string absFolderPath = string.Format("{0}{1}", Application.dataPath, folderPath);
            if (!Directory.Exists(absFolderPath))
            {
                Directory.CreateDirectory(absFolderPath);
            }
            string adbPath = string.Format("{0}/{1}", "Assets", folderPath);
            string output  = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(Path.Combine(adbPath, filename));
            return(output);
#else
            return("");
#endif
        }
Пример #9
0
        private void UpdatePreviewMesh()
        {
            string     meshName = string.Format("{0}_Preview_Mesh", name);
            BuildRMesh pBMesh   = new BuildRMesh(meshName);

            if (_previewMesh == null)
            {
                _previewMesh = new Mesh();
            }
            _previewMesh.name = meshName;
            if (_settings == null)
            {
                _settings = BuildRSettings.GetSettings();
            }
            Vector3 left  = new Vector3(-_settings.previewGableWidth * 0.5f, -_settings.previewGableHeight * 0.5f, 0);
            Vector3 right = new Vector3(_settings.previewGableWidth * 0.5f, -_settings.previewGableHeight * 0.5f, 0);

            GableGenerator.Generate(ref pBMesh, this, left, right, _settings.previewGableHeight, _settings.previewGableThickness, new Vector2());
            pBMesh.Build(_previewMesh);
        }
Пример #10
0
        public static BuildRSettings GetSettings()
        {
            if (INSTANCE != null)
            {
                return(INSTANCE);
            }
#if UNITY_EDITOR
            string[] guids         = UnityEditor.AssetDatabase.FindAssets("t:BuildR2.BuildRSettings");//t: type BuildRSettings
            int      settingsCount = guids.Length;
            if (settingsCount > 1)
            {
                string errorMessage = "Multiple BuildR Settings Files Found - please Delete one";
                for (int i = 0; i < settingsCount; i++)
                {
                    errorMessage += "\n " + (i + 1) + ". " + UnityEditor.AssetDatabase.GUIDToAssetPath(guids[i]);
                }
                Debug.LogError(errorMessage);
            }
            if (settingsCount > 0)
            {
                string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(guids[0]);
                INSTANCE = UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath, typeof(BuildRSettings)) as BuildRSettings;
            }

            if (INSTANCE != null)
            {
                return(INSTANCE);
            }
#endif
            //create new settings file
            INSTANCE = CreateInstance <BuildRSettings>();
#if UNITY_EDITOR
            UnityEditor.AssetDatabase.CreateAsset(INSTANCE, SETTINGS_PATH);
            UnityEditor.AssetDatabase.SaveAssets();
            UnityEditor.AssetDatabase.Refresh();
#endif
            return(INSTANCE);
        }
Пример #11
0
        public static void BuildFloorplan()
        {
            LAYERS.Clear();
            SceneMeshLayer layerOpengings = new SceneMeshLayer();
            SceneMeshLayer layer0         = new SceneMeshLayer();
            SceneMeshLayer layer1         = new SceneMeshLayer();
            SceneMeshLayer layer2         = new SceneMeshLayer();

            LAYERS.Add(layerOpengings);
            LAYERS.Add(layer0);
            LAYERS.Add(layer1);
            LAYERS.Add(layer2);

            Building building = BuildingEditor.building;

            bPosition = building.transform.position;
            bRotation = building.transform.rotation;
            BuildRSettings settings        = building.settings;
            int            numberOfVolumes = building.numberOfPlans;
            Quaternion     rotation        = building.transform.rotation;

            Vector3[] centerPoints = new Vector3[numberOfVolumes];
            for (int f = 0; f < numberOfVolumes; f++)
            {
                centerPoints[f] = BuildrUtils.CalculateFloorplanCenter(building[f]);
            }
            for (int v = 0; v < numberOfVolumes; v++)
            {
                Volume  volume           = (Volume)building[v];
                bool    isSelectedVolume = BuildingEditor.volume == volume;
                int     numberOfPoints   = volume.numberOfPoints;
                Vector3 vUp = Vector3.up * volume.floorHeight;
                Dictionary <int, List <Vector2Int> > anchorPoints = volume.facadeWallAnchors;

                IFloorplan[] floorplans     = volume.InteriorFloorplans();
                int          floorplanCount = floorplans.Length;
                for (int f = 0; f < floorplanCount; f++)//floors
                {
                    IFloorplan floorplan           = floorplans[f];
                    bool       isSelectedFloorplan = BuildingEditor.floorplan == (Floorplan)floorplan;
                    float      intPlanBaseHeight   = volume.CalculateFloorHeight(f);
                    Vector3    baseUpV             = Vector3.up * intPlanBaseHeight;

                    //draw external outline of selected floor
                    if (numberOfPoints > 0 && isSelectedVolume)
                    {
                        SceneMeshLayer    useLayer = isSelectedFloorplan ? layer1 : layer0;
                        List <Vector2Int> planVs   = new List <Vector2Int>();
                        Color             fillCol  = settings.subLineColour;
                        Color             lineCol  = settings.mainLineColour;
                        for (int p = 0; p < numberOfPoints; p++)
                        {
                            if (volume.IsWallStraight(p))
                            {
                                if (!planVs.Contains(volume[p].position))
                                {
                                    planVs.Add(volume[p].position);
                                }
                                Vector3 p0 = volume[p].position.vector3XZ + baseUpV;
                                Vector3 p1 = volume[(p + 1) % numberOfPoints].position.vector3XZ + baseUpV;
                                Vector3 p2 = p0 + vUp;
                                Vector3 p3 = p1 + vUp;

                                useLayer.shapes.Add(new SceneMeshShape(fillCol, p0, p1, p3, p2));
                                useLayer.lines.Add(new SceneMeshLine(p2, p3, lineCol));
                                useLayer.lines.Add(new SceneMeshLine(p0, p2, lineCol));
                                useLayer.lines.Add(new SceneMeshLine(p1, p3, lineCol));
                                if (isSelectedFloorplan)
                                {
                                    useLayer.lines.Add(new SceneMeshLine(p0, p1, Color.red));

                                    List <Vector2Int> anchors = anchorPoints[p];
                                    int wallSections          = anchors.Count;
                                    for (int w = 0; w < wallSections - 1; w++)
                                    {
                                        Vector3 a          = anchors[w].vector3XZ + baseUpV;
                                        float   anchorSize = 0.05f;
                                        if (w == 0)
                                        {
                                            anchorSize *= 2;
                                        }
                                        useLayer.dots.Add(new SceneMeshDot(a, anchorSize, settings.anchorColour));
                                    }
                                }
                            }
                            else
                            {
                                List <Vector2Int> anchors = anchorPoints[p];
                                int wallSections          = anchors.Count;
                                for (int w = 0; w < wallSections - 2; w++)
                                {
                                    if (!planVs.Contains(anchors[w]))
                                    {
                                        planVs.Add(anchors[w]);
                                    }
                                    Vector3 p0 = anchors[w].vector3XZ + baseUpV;
                                    Vector3 p1 = anchors[w + 1].vector3XZ + baseUpV;
                                    Vector3 p2 = p0 + vUp;
                                    Vector3 p3 = p1 + vUp;

                                    useLayer.lines.Add(new SceneMeshLine(p2, p3, lineCol));
                                    if (w == 0)
                                    {
                                        useLayer.lines.Add(new SceneMeshLine(p0, p2, lineCol));
                                    }
                                    if (w == wallSections - 2)
                                    {
                                        useLayer.lines.Add(new SceneMeshLine(p1, p3, lineCol));
                                    }

                                    useLayer.shapes.Add(new SceneMeshShape(fillCol, p0, p1, p3, p2));

                                    if (isSelectedFloorplan)
                                    {
                                        useLayer.lines.Add(new SceneMeshLine(p0, p1, Color.red));

                                        float anchorSize = 0.05f;
                                        if (w == 0)
                                        {
                                            anchorSize *= 2;
                                        }
                                        if (w < wallSections - 1)
                                        {
                                            useLayer.dots.Add(new SceneMeshDot(p0, anchorSize, settings.anchorColour));
                                        }
                                    }
                                }
                            }
                        }

                        if (isSelectedFloorplan)
                        {
                            int       planVCount = planVs.Count;
                            Vector3[] planV3     = new Vector3[planVCount];
                            for (int pv = 0; pv < planVCount; pv++)
                            {
                                planV3[pv] = planVs[pv].vector3XZ + baseUpV;
                            }
                            ShapeWithLines(useLayer, planV3, Color.red, new Color(1, 1, 1, 0.9f));
                        }
                    }

                    if (isSelectedFloorplan)
                    {
                        Room[]            rooms       = floorplan.AllRooms();
                        int               roomCount   = rooms.Length;
                        List <Vector2Int> shapePoints = new List <Vector2Int>();
                        for (int r = 0; r < roomCount; r++)
                        {
                            Room room           = rooms[r];
                            bool isRoomSelected = room == BuildingEditor.room && BuildingEditor.roomPortal == null && BuildingEditor.opening == null;
                            shapePoints.Clear();

                            FloorplanUtil.RoomWall[] roomWalls = FloorplanUtil.CalculatePoints(room, volume);
                            int roomWallCount = roomWalls.Length;

                            Color wallCol     = isRoomSelected ? settings.roomWallSelectedColour : settings.roomWallColour;
                            Color floorCol    = isRoomSelected ? settings.roomWallSelectedColour : settings.roomFloorColour;
                            Color mainLineCol = isRoomSelected ? settings.selectedPointColour : settings.mainLineColour;
                            Color subLineCol  = isRoomSelected ? settings.selectedPointColour : settings.subLineColour;

                            for (int rwp = 0; rwp < roomWallCount; rwp++)
                            {
                                FloorplanUtil.RoomWall roomWall = roomWalls[rwp];
                                int offsetCount = roomWall.offsetPoints.Length;

                                Vector2Int pi0 = roomWall.baseA;
                                Vector2Int pi1 = roomWall.baseB;

                                if (pi0 == pi1)
                                {
                                    continue;            //not a wall
                                }
                                for (int op = 0; op < offsetCount - 1; op++)
                                {
                                    Vector2Int wsint0 = new Vector2Int(roomWall.offsetPoints[op]);
                                    if (!shapePoints.Contains(wsint0))
                                    {
                                        shapePoints.Add(wsint0);
                                    }
                                    Vector3 ws0 = new Vector3(roomWall.offsetPoints[op].x, 0, roomWall.offsetPoints[op].y) + baseUpV;

                                    if (isSelectedFloorplan)//draw anchor points
                                    {
                                        float anchorSize = 0.05f;
                                        if (op == 0)
                                        {
                                            anchorSize *= 2;
                                        }
                                        layer1.dots.Add(new SceneMeshDot(ws0, anchorSize * 0.05f, settings.linkedAnchorColour));
                                    }

                                    int     nextIndex = (op + 1) % offsetCount;
                                    Vector3 ws1       = new Vector3(roomWall.offsetPoints[nextIndex].x, 0, roomWall.offsetPoints[nextIndex].y) + baseUpV;
                                    Vector3 ws2       = ws0 + vUp;
                                    Vector3 ws3       = ws1 + vUp;

                                    layer1.lines.Add(new SceneMeshLine(ws0, ws1, mainLineCol));
                                    layer1.lines.Add(new SceneMeshLine(ws0, ws2, subLineCol));
                                    layer1.lines.Add(new SceneMeshLine(ws1, ws3, subLineCol));

                                    layer1.shapes.Add(new SceneMeshShape(wallCol, ws0, ws1, ws3, ws2));
                                }
                            }

                            int       shapePointsCount = shapePoints.Count;
                            Vector3[] planV3           = new Vector3[shapePointsCount];
                            for (int pv = 0; pv < shapePointsCount; pv++)
                            {
                                planV3[pv] = shapePoints[pv].vector3XZ + baseUpV;
                            }
                            ShapeWithLines(layer1, planV3, mainLineCol, floorCol, settings.highlightPerpendicularity, settings.highlightPerpendicularityColour, settings.highlightAngleColour);

                            RoomPortal[] portals     = room.GetAllPortals();
                            int          portalCount = portals.Length;
                            for (int pt = 0; pt < portalCount; pt++)
                            {
                                RoomPortal portal           = portals[pt];
                                bool       isSelected       = BuildingEditor.roomPortal == portal;
                                Color      portalLineColour = isSelectedFloorplan ? settings.mainLineColour : settings.subLineColour;
                                Color      portalFillColour = isSelected ? settings.selectedPointColour : settings.mainLineColour;
                                if (!isSelectedFloorplan)
                                {
                                    portalFillColour = Color.clear;
                                }
                                DrawPortal(layer2, rotation, intPlanBaseHeight, volume.floorHeight, room, portal, portalLineColour, portalFillColour);
                            }
                        }

                        for (int r = 0; r < roomCount; r++)
                        {
                            Room    room       = rooms[r];
                            Vector3 roomCenter = room.center.vector3XZ + baseUpV + Vector3.up * volume.floorHeight;
                            layer1.labels.Add(new SceneMeshLabel(roomCenter, string.Format("Room {0}", (r + 1))));
                        }
                    }

                    //Draw vertical openings
                    if (BuildingEditor.floorplan != null)
                    {
                        VerticalOpening[] openings = building.GetAllOpenings();
                        int openingCount           = openings.Length;
                        for (int o = 0; o < openingCount; o++)
                        {
                            VerticalOpening opening           = openings[o];
                            bool            isSelectedOpening = BuildingEditor.opening == opening;

                            Vector3 openingPosition = opening.position.vector3XZ;
                            openingPosition.y = volume.floorHeight * opening.baseFloor;
                            Vector3    openingSize     = opening.size.vector3XZ;
                            float      openingWidth    = openingSize.x;
                            float      openingHeight   = openingSize.z;
                            Quaternion openingRotation = Quaternion.Euler(0, opening.rotation, 0);
                            Vector3    p0        = openingPosition + openingRotation * new Vector3(-openingWidth, 0, -openingHeight) * 0.5f;
                            Vector3    p1        = openingPosition + openingRotation * new Vector3(openingWidth, 0, -openingHeight) * 0.5f;
                            Vector3    p2        = openingPosition + openingRotation * new Vector3(openingWidth, 0, openingHeight) * 0.5f;
                            Vector3    p3        = openingPosition + openingRotation * new Vector3(-openingWidth, 0, openingHeight) * 0.5f;
                            Vector3    openingUp = Vector3.up * volume.floorHeight * (opening.floors + 1);

                            //"Phil" Mitchels
                            Color fillCol = settings.subLineColour;
                            fillCol.a = 0.05f;
                            layerOpengings.shapes.Add(new SceneMeshShape(fillCol, p0, p1, p2, p3));
                            layerOpengings.shapes.Add(new SceneMeshShape(fillCol, p0, p1, p1 + openingUp, p0 + openingUp));
                            layerOpengings.shapes.Add(new SceneMeshShape(fillCol, p1, p2, p2 + openingUp, p1 + openingUp));
                            layerOpengings.shapes.Add(new SceneMeshShape(fillCol, p2, p3, p3 + openingUp, p2 + openingUp));
                            layerOpengings.shapes.Add(new SceneMeshShape(fillCol, p3, p0, p0 + openingUp, p3 + openingUp));

                            //lines
                            Color lineCol = settings.invertLineColour;
                            layer0.lines.Add(new SceneMeshLine(p0, p1, lineCol));
                            layer0.lines.Add(new SceneMeshLine(p1, p2, lineCol));
                            layer0.lines.Add(new SceneMeshLine(p2, p3, lineCol));
                            layer0.lines.Add(new SceneMeshLine(p3, p0, lineCol));

                            layer0.lines.Add(new SceneMeshLine(p0 + openingUp, p1 + openingUp, lineCol));
                            layer0.lines.Add(new SceneMeshLine(p1 + openingUp, p2 + openingUp, lineCol));
                            layer0.lines.Add(new SceneMeshLine(p2 + openingUp, p3 + openingUp, lineCol));
                            layer0.lines.Add(new SceneMeshLine(p3 + openingUp, p0 + openingUp, lineCol));

                            layer0.lines.Add(new SceneMeshLine(p0, p0 + openingUp, lineCol));
                            layer0.lines.Add(new SceneMeshLine(p1, p1 + openingUp, lineCol));
                            layer0.lines.Add(new SceneMeshLine(p2, p2 + openingUp, lineCol));
                            layer0.lines.Add(new SceneMeshLine(p3, p3 + openingUp, lineCol));


                            layer0.labels.Add(new SceneMeshLabel(openingPosition + openingUp, string.Format("Opening {0}", o + 1)));

                            if (volume == BuildingEditor.volume && BuildingEditor.floorplan != null)
                            {
                                Vector3 floorUpA = Vector3.up * volume.CalculateFloorHeight(volume.Floor(BuildingEditor.floorplan));
                                Vector3 floorUpB = floorUpA + Vector3.up * volume.floorHeight;

                                Color          col      = isSelectedOpening ? Color.green : Color.red;
                                SceneMeshLayer useLayer = isSelectedOpening ? layer2 : layer2;

                                useLayer.lines.Add(new SceneMeshLine(p0 + floorUpA, p1 + floorUpA, col));
                                useLayer.lines.Add(new SceneMeshLine(p1 + floorUpA, p2 + floorUpA, col));
                                useLayer.lines.Add(new SceneMeshLine(p2 + floorUpA, p3 + floorUpA, col));
                                useLayer.lines.Add(new SceneMeshLine(p3 + floorUpA, p0 + floorUpA, col));

                                useLayer.lines.Add(new SceneMeshLine(p0 + floorUpB, p1 + floorUpB, col));
                                useLayer.lines.Add(new SceneMeshLine(p1 + floorUpB, p2 + floorUpB, col));
                                useLayer.lines.Add(new SceneMeshLine(p2 + floorUpB, p3 + floorUpB, col));
                                useLayer.lines.Add(new SceneMeshLine(p3 + floorUpB, p0 + floorUpB, col));

                                useLayer.lines.Add(new SceneMeshLine(p0 + floorUpA, p0 + floorUpB, col));
                                useLayer.lines.Add(new SceneMeshLine(p1 + floorUpA, p1 + floorUpB, col));
                                useLayer.lines.Add(new SceneMeshLine(p2 + floorUpA, p2 + floorUpB, col));
                                useLayer.lines.Add(new SceneMeshLine(p3 + floorUpA, p3 + floorUpB, col));
                            }
                        }
                    }
                }
            }
        }
Пример #12
0
        static void ItemOnGui(string guid, Rect rect)
        {
            if (settings == null)
            {
                settings = BuildRSettings.GetSettings();
            }
            if (!settings.iconPreviews)
            {
                return;
            }

            bool  defaultFound  = settings.defaultIcon != null;
            Rect  squareRect    = new Rect(rect.x, rect.y, rect.height, rect.height);
            float defaultHeight = Mathf.Min(56, rect.height);
            float defaultWidth  = Mathf.Min(44, rect.width, defaultHeight * 0.7857f);
            float defaultX      = rect.x;
            float defaultY      = rect.y;

            if (rect.height > 56)
            {
                defaultX = rect.x + (rect.width - 44) * 0.5f;
                defaultY = rect.y + (rect.height - 70) * 0.5f;
            }
            Rect defaultRect = new Rect(defaultX, defaultY, defaultWidth, defaultHeight);

//            IconUtil.GUIDIconData iconData = settings.GetCustomIconData(guid);
//            if(iconData == null)
//            {
//                iconData = IconUtil.GenerateGUIDIconData(guid);
//                settings.AddCustomIconData(guid, iconData);
//            }

            string      assetPath   = AssetDatabase.GUIDToAssetPath(guid);
            WallSection wallSection = AssetDatabase.LoadAssetAtPath(assetPath, typeof(WallSection)) as WallSection;

            if (wallSection != null)
            {
                Texture2D wallSectionPreview = wallSection.previewTexture;
                if (wallSectionPreview != null)
                {
                    GUI.DrawTexture(squareRect, wallSectionPreview);
                }
                else if (defaultFound)
                {
                    GUI.DrawTexture(defaultRect, settings.defaultIcon);
                }
            }


            Facade facade = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Facade)) as Facade;

            if (facade != null)
            {
                Texture2D facadePreview = facade.previewTexture;
                if (facadePreview != null)
                {
                    GUI.DrawTexture(squareRect, facadePreview);
                }
                else if (defaultFound)
                {
                    GUI.DrawTexture(defaultRect, settings.defaultIcon);
                }
            }

            Surface surface = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Surface)) as Surface;

            if (surface != null && surface.previewTexture != null)
            {
                if (surface.previewTexture != null)
                {
                    GUI.DrawTexture(squareRect, surface.previewTexture);
                }
                else if (defaultFound)
                {
                    GUI.DrawTexture(defaultRect, settings.defaultIcon);
                }
            }

            Gable gable = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Gable)) as Gable;

            if (defaultFound && gable != null)
            {
                GUI.DrawTexture(defaultRect, settings.defaultIcon);
            }

            RoomStyle roomStyle = AssetDatabase.LoadAssetAtPath(assetPath, typeof(RoomStyle)) as RoomStyle;

            if (defaultFound && roomStyle != null)
            {
                GUI.DrawTexture(defaultRect, settings.defaultIcon);
            }

            Portal portal = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Portal)) as Portal;

            if (defaultFound && portal != null)
            {
                GUI.DrawTexture(defaultRect, settings.defaultIcon);
            }

            BuildRSettings settingsIcon = AssetDatabase.LoadAssetAtPath(assetPath, typeof(BuildRSettings)) as BuildRSettings;

            if (defaultFound && settingsIcon != null)
            {
                GUI.DrawTexture(defaultRect, settings.defaultIcon);
            }
        }