Beispiel #1
0
        void OnEnable()
        {
            StreetModifier bm = (StreetModifier)target;

            bm.AwakeCity();
            bm.UpdateCity();
            banner = Resources.Load("CSHeader") as Texture;
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            StreetModifier bm = (StreetModifier)target;

            bm.streetType = (CScape.StreetModifier.CScapeStreetType)EditorGUILayout.EnumPopup("Street Type", bm.streetType);

            GUILayout.Box(banner, GUILayout.ExpandWidth(true));

            GUILayout.BeginVertical("box");
            bm.districtStyle = EditorGUILayout.ObjectField("District Style", bm.districtStyle, typeof(DistrictStyle), true) as DistrictStyle;
            GUILayout.Label("Facade assignement");
            bm.materialId1 = EditorGUILayout.IntSlider("Material ID 1", bm.materialId1, 0, 15);
            bm.materialId2 = EditorGUILayout.IntSlider("Material ID 2", bm.materialId2, 0, 15);
            bm.materialId3 = EditorGUILayout.IntSlider("Material ID 3", bm.materialId3, 0, 15);
            bm.sidewalkID  = EditorGUILayout.IntSlider("Material Sidewalk ID", bm.sidewalkID, 0, 15);
            bm.streetID    = EditorGUILayout.IntSlider("Material Road ID", bm.streetID, 0, 15);
            GUILayout.EndHorizontal();
            //configure Prefab
            GUILayout.BeginVertical("box");
            configurePrefab = EditorGUILayout.Foldout(configurePrefab, "Prefab Configuration");
            if (configurePrefab)
            {
                bm.meshOriginal = EditorGUILayout.ObjectField("Mesh Template", bm.meshOriginal, typeof(Mesh), true) as Mesh;
                if (GUILayout.Button("Update Mesh Template"))
                {
                    bm.AwakeCity();
                    bm.UpdateCity();
                }
                bm.lowFloorBound            = EditorGUILayout.Vector3Field("Resizer Center", bm.lowFloorBound);
                bm.lowFloorBoundSecond      = EditorGUILayout.Vector3Field("Resizer Midpoint", bm.lowFloorBoundSecond);
                bm.prefabFloors             = EditorGUILayout.IntField("Prefab floor number", bm.prefabFloors);
                bm.prefabWidth              = EditorGUILayout.IntField("Prefab width", bm.prefabWidth);
                bm.prefabDepth              = EditorGUILayout.IntField("Prefab depth", bm.prefabDepth);
                bm.prefabCenterSectionWidth = EditorGUILayout.IntField("Center section width", bm.prefabCenterSectionWidth);
                bm.prefabCenterSectionDepth = EditorGUILayout.IntField("Center Section depth", bm.prefabCenterSectionDepth);
                bm.normalThreshold          = EditorGUILayout.Slider("Normal threshold", bm.normalThreshold, 0f, 0.5f);
                bm.floorHeight              = EditorGUILayout.FloatField("Floor Height", bm.floorHeight);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical("box");
            GUILayout.Label("Variations");
            //bm.windowOpen = EditorGUILayout.Slider("Window Close", bm.windowOpen, 0f, 5f);
            //bm.pattern = EditorGUILayout.Slider("Floor Pattern", bm.pattern, 0f, 1f);
            //bm.colorVariation.x = EditorGUILayout.Slider("Lightness", bm.colorVariation.x, 0f, 5f);
            //bm.colorVariation.y = EditorGUILayout.Slider("Hue", bm.colorVariation.y, 0f, 1f);
            //          bm.uniqueMapping = EditorGUILayout.IntField("Unique Mapping", bm.uniqueMapping);
            //         bm.floorNumber = EditorGUILayout.IntField("Floor Number", bm.floorNumber);
            bm.blockDepth   = EditorGUILayout.IntField("Block depth", bm.blockDepth);
            bm.blockWidth   = EditorGUILayout.IntField("Block Width", bm.blockWidth);
            bm.sectionDepth = EditorGUILayout.IntField("Section depth", bm.sectionDepth);
            bm.sectionWidth = EditorGUILayout.IntField("Section Width", bm.sectionWidth);
            bm.randomSeed   = EditorGUILayout.IntField("Random Seed", bm.randomSeed);

            bm.slitRB = EditorGUILayout.IntSlider("Slit RB", bm.slitRB, -30, 30);
            bm.slitLF = EditorGUILayout.IntSlider("Slit LF", bm.slitLF, -30, 30);
            bm.averageBuildingSizeMin = EditorGUILayout.IntField("Building size min", bm.averageBuildingSizeMin);
            bm.averageBuildingSizeMax = EditorGUILayout.IntField("Building Size Max", bm.averageBuildingSizeMax);
            bm.useSkewLR         = EditorGUILayout.Toggle("Use LR Skewing", bm.useSkewLR);
            bm.useSkewFB         = EditorGUILayout.Toggle("Use FB Skewing", bm.useSkewFB);
            bm.skewRotationFront = EditorGUILayout.FloatField("Skew Rotation Front", bm.skewRotationFront);
            bm.skewRotationLeft  = EditorGUILayout.FloatField("Skew Rotation Left", bm.skewRotationLeft);
            bm.skewRotationBack  = EditorGUILayout.FloatField("Skew Rotation Back", bm.skewRotationBack);
            bm.skewRotationRight = EditorGUILayout.FloatField("Skew Rotation Right", bm.skewRotationRight);

            bm.lenghtFront          = EditorGUILayout.FloatField("Lenght Front", bm.lenghtFront);
            bm.lenghtLeft           = EditorGUILayout.FloatField("Lenght Left", bm.lenghtLeft);
            bm.lenghtBack           = EditorGUILayout.FloatField("Lenght Back", bm.lenghtBack);
            bm.lenghtRight          = EditorGUILayout.FloatField("Lenght Right", bm.lenghtRight);
            bm.sidewalkSize         = EditorGUILayout.IntSlider("Sidewalk Size", bm.sidewalkSize, 1, 15);
            bm.distantiateBuildings = EditorGUILayout.IntSlider("Distantiate buildings", bm.distantiateBuildings, 0, Mathf.Min(bm.blockDepth, bm.blockWidth));
            bm.useGraffiti          = EditorGUILayout.Toggle("UseGraffiti", bm.useGraffiti);
            if (GUILayout.Button("Generate Block"))
            {
                bm.GenerateBuildings();
            }
            if (GUILayout.Button("Generate Street Details"))
            {
                bm.GenerateDetails();
            }

            if (bm.useSkewFB)
            {
                if (GUILayout.Button("SplitX"))
                {
                    bm.SplitX();
                }
            }
            else if (bm.useSkewLR)
            {
                if (GUILayout.Button("SplitZ"))
                {
                    bm.SplitZ();
                }
            }
            else
            {
                if (GUILayout.Button("SplitX"))
                {
                    bm.SplitX();
                }
                if (GUILayout.Button("SplitZ"))
                {
                    bm.SplitZ();
                }
            }


            GUILayout.EndHorizontal();



            if (GUI.changed)
            {
                bm.UpdateCity();
                EditorUtility.SetDirty(bm);
#if UNITY_5_4_OR_NEWER
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
#endif
            }
        }