Exemple #1
0
        //  public MeshCollider collider;



        private void Awake()
        {
            if (!Application.isPlaying)
            {
                advertising = null;
                rooftops    = null;
            }
        }
        void OnEnable()
        {
            CSRooftops bm = (CSRooftops)target;

            banner = Resources.Load("CSHeader") as Texture;
            bm.AwakeMe();
            bm.UpdateElements();
        }
        public void OnSceneGUI()
        {
            CSRooftops bm = (CSRooftops)target;

            if (bm.rooftopHolder != null)
            {
                bm.rooftopHolder.transform.position = bm.gameObject.transform.position;
                bm.rooftopHolder.transform.rotation = bm.gameObject.transform.rotation;
            }
        }
        public override void OnInspectorGUI()
        {
            CSRooftops bm = (CSRooftops)target;

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

            bm.useRooftops = EditorGUILayout.Toggle("Use Rooftops", bm.useRooftops);

            if (GUILayout.Button("Update Template"))
            {
                bm.AwakeMe();
                bm.UpdateElements();
            }
            bm.lodDistance = EditorGUILayout.Slider("Culling Distance", bm.lodDistance, 0f, 1f);
            bm.instancesX  = EditorGUILayout.IntField("Rooftop density", bm.instancesX);
            bm.randomSeed  = EditorGUILayout.IntField("Random seed", bm.randomSeed);
            bm.greebleMat  = EditorGUILayout.ObjectField("Rooftop Material", bm.greebleMat, typeof(Material), true) as Material;

            GUILayout.BeginVertical();
            for (int i = 0; i < bm.rooftopElements.Length; i++)
            {
                bm.rooftopElements[i] = EditorGUILayout.ObjectField("" + i, bm.rooftopElements[i], typeof(GameObject), true) as GameObject;
            }
            GUILayout.BeginHorizontal("Box");
            if (GUILayout.Button("-", "Label", GUILayout.Width(20), GUILayout.Height(15)))
            {
                System.Array.Resize(ref bm.rooftopElements, bm.rooftopElements.Length - 1);
            }
            if (GUILayout.Button("+", "Label", GUILayout.Width(20), GUILayout.Height(15)))
            {
                System.Array.Resize(ref bm.rooftopElements, bm.rooftopElements.Length + 1);
            }

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();



            if (GUI.changed)
            {
                Repaint();

                bm.AwakeMe();
                //    bm.UpdateElements();
                EditorUtility.SetDirty(bm);
            }
        }
 public void UpdateRooftopCulling()
 {
     CSRandomizerComponent = gameObject.GetComponent <CityRandomizer>();
     csDetailsObject       = CSRandomizerComponent.buildings;
     foreach (Transform go in csDetailsObject.transform.Cast <Transform>().Reverse())
     {
         CSRooftops rooftops = go.GetComponent(typeof(CSRooftops)) as CSRooftops;
         if (rooftops != null)
         {
             rooftops.instancesX     = rooftopDensity;
             rooftops.lodDistance    = rooftopsCullingSize;
             rooftops.animateLodFade = true;
             rooftops.UpdateElements();
         }
     }
 }
Exemple #6
0
        public void OnDestroy()
        {
            if (!dontDestroyChildren)
            {
                if (Application.isEditor && !Application.isPlaying)
                {
                    if (useAdvertising)
                    {
                        if (advertising != null)
                        {
                            DestroyImmediate(advertising.rooftopHolder);
                        }
                    }

                    if (hasBalcony)
                    {
                        CSArray CSArray = balcony;
                        for (int x = 0; x < CSArray.numberOfModifiers; x++)
                        {
                            DestroyImmediate(CSArray.rooftopHolder[x]);
                        }
                    }
                    if (hasRooftops)
                    {
                        CSRooftops csRooftops = rooftops;
                        if (csRooftops && csRooftops.rooftopHolder)
                        {
                            DestroyImmediate(csRooftops.rooftopHolder);
                        }
                    }

                    if (hasFloorDetails)
                    {
                        CSFloorDetails csRooftops = floorDetails;
                        if (floorDetails && floorDetails.rooftopHolder)
                        {
                            DestroyImmediate(floorDetails.rooftopHolder);
                        }
                    }
                }
            }
        }
Exemple #7
0
        public void AwakeCity()
        {
            if (useFloorLimiting)
            {
                LimitFloors();
            }

            if (gameObject.activeInHierarchy)
            {
                CheckParents();

                if (cityRandomizerParent == null && isInRoot)
                {
                    cityRandomizerParent = gameObject.transform.parent.transform.parent.GetComponent <CityRandomizer>() as CityRandomizer;
                }

                rooftops = gameObject.GetComponent <CSRooftops>();
                if (gameObject.GetComponent <CSRooftops>() != null)
                {
                    hasRooftops = true;
                }
                else
                {
                    hasRooftops = false;
                }

                advertising = gameObject.GetComponent <CSAdvertising>();
                if (advertising != null)
                {
                    hasAdvertising             = true;
                    advertising.useAdvertising = useAdvertising;
                }
                else
                {
                    hasAdvertising = false;
                }

                balcony = gameObject.GetComponent <CSArray>();
                if (balcony != null)
                {
                    hasBalcony             = true;
                    balcony.useAdvertising = useAdvertising;
                }
                else
                {
                    hasFloorDetails = false;
                }

                floorDetails = gameObject.GetComponent <CSFloorDetails>();
                if (floorDetails != null)
                {
                    hasFloorDetails = true;
                }
                else
                {
                    hasFloorDetails = false;
                }



                parentStreets     = new StreetModifier[5];
                connectedSections = new BuildingModifier[5];

                //meshOriginal = GetComponent<MeshFilter>().sharedMesh;
                originalVertices = meshOriginal.vertices;
                if (scaleFrom1to3)
                {
                    for (int i = 0; i < meshOriginal.vertices.Length; i++)
                    {
                        originalVertices[i] = meshOriginal.vertices[i] * 3f;
                    }
                }
                originalUVs = meshOriginal.uv;

                if (meshOriginal.colors.Length > 0)
                {
                    originalColors = meshOriginal.colors;
                }
                else
                {
                    originalColors = new Color[meshOriginal.vertices.Length];
                }

                vColors = new Vector4[originalVertices.Length];
                mesh    = Instantiate(meshOriginal) as Mesh;
                MeshFilter meshFilter = GetComponent <MeshFilter>();
                meshFilter.mesh = mesh;
                //		gameObject.transform.GetChild (0);
                //      lightVec = (Mathf.FloorToInt(colorVariation.x * 0.1f) * 10f) + (Mathf.FloorToInt(colorVariation.y) * 0.1f) + (Mathf.FloorToInt(colorVariation.z) * 0.01f) + (Mathf.FloorToInt(colorVariation.w) * 0.001f + 0.00001f);
                //
                ModifyBuilding();
                //  Thread olix = new Thread (ModifyBuilding);
            }
        }