Пример #1
0
        public void Rebuild()
        {
            this.RemoveAllChildren();
            this.DeserializeGeoJson();

            int i = 0;

            foreach (var feature in this.m_features)
            {
                var geometry = feature.Geometry as PolygonGeometry;

                var block = new GameObject(this.Component.featureTypeFilter + i++.ToString());
                block.transform.parent   = this.Component.transform;
                block.transform.position = this.Component.transform.position;

                var controller = block.AddComponent <BlockFromPolygon>();
                controller.height = feature.Properties.Height == null || feature.Properties.Height == 0 ? Random.Range(this.Component.heightMin, this.Component.heightMax) : feature.Properties.Height.Value;

                controller.sideMaterial               = this.Component.sideMaterials[Random.Range(0, this.Component.sideMaterials.Count)];
                controller.topMaterial                = this.Component.topMaterial;
                controller.bottomMaterial             = this.Component.bottomMaterial;
                controller.sideUvUnwrapSettings       = this.Component.sideUvUnwrapSettings;
                controller.pointedRoof                = this.Component.pointedRoofTops;
                controller.raiseFrontAndBackFacadeTop = this.Component.raiseFacades;

                controller.floorPolygon = new List <Vector3>(from coor in geometry.Coordinates[0] select new Vector3(coor.ToLocalGrid(m_origin).x, 0, coor.ToLocalGrid(m_origin).y));

                var blockBuilder = new BlockFromPolygonBuilder(controller);
                blockBuilder.Draw();
            }
        }
        public override void OnInspectorGUI()
        {
            var controller = this.serializedObject.targetObject as BlockFromPolygon;

            serializedObject.Update();

            EditorGUILayout.PropertyField(height);
            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(topMaterial);
            EditorGUILayout.PropertyField(bottomMaterial);
            EditorGUILayout.PropertyField(sideMaterial);
            EditorGUILayout.PropertyField(sideUvUnwrapSettings);
            EditorGUILayout.PropertyField(pointedRoof);
            EditorGUILayout.PropertyField(pointedRoofHeight);
            EditorGUILayout.PropertyField(raiseFrontAndBackFacadeTop);
            EditorGUILayout.PropertyField(leanForward);

            if (controller.floorPolygon != null)
            {
                EditorGUILayout.BeginFoldoutHeaderGroup(false, "Polygon");
                foreach (var coordinate in (this.serializedObject.targetObject as BlockFromPolygon).floorPolygon)
                {
                    EditorGUILayout.LabelField(coordinate.ToString());
                }
                EditorGUILayout.EndFoldoutHeaderGroup();
            }

            // EditorGUILayout.PropertyField(floor);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Set Test Floor"))
            {
                this.CreateTestFloor();
            }
            if (GUILayout.Button("Draw"))
            {
                var builder = new BlockFromPolygonBuilder(controller);
                builder.Draw();
            }
            EditorGUILayout.EndHorizontal();
            serializedObject.ApplyModifiedProperties();
        }