public void UpdateAdvertisingCulling() { CSRandomizerComponent = gameObject.GetComponent <CityRandomizer>(); csDetailsObject = CSRandomizerComponent.buildings; foreach (Transform go in csDetailsObject.transform.Cast <Transform>().Reverse()) { CSAdvertising rooftops = go.GetComponent(typeof(CSAdvertising)) as CSAdvertising; if (rooftops != null) { rooftops.instancesX = advertsDensity; rooftops.lodDistance = advertsCullingSize; rooftops.useAdvertising = useRooftops; rooftops.animateLodFade = true; rooftops.DeleteSolution(); rooftops.UpdateElements(); } } foreach (Transform go in csDetailsObject.transform.Cast <Transform>().Reverse()) { BuildingModifier bm = go.GetComponent(typeof(BuildingModifier)) as BuildingModifier; if (bm != null) { bm.useAdvertising = useRooftops; // bm.AwakeCity(); bm.UpdateCity(); } } }
// public MeshCollider collider; private void Awake() { if (!Application.isPlaying) { advertising = null; rooftops = null; } }
void OnEnable() { CSAdvertising bm = (CSAdvertising)target; banner = Resources.Load("CSHeader") as Texture; bm.AwakeMe(); bm.UpdateElements(); }
public void OnSceneGUI() { CSAdvertising bm = (CSAdvertising)target; if (bm.rooftopHolder != null) { bm.rooftopHolder.transform.position = bm.gameObject.transform.position; bm.rooftopHolder.transform.rotation = bm.gameObject.transform.rotation; } }
public void UpdateCity() { if (useFloorLimiting) { LimitFloors(); } if (gameObject.activeInHierarchy) { CheckParents(); // if (cityRandomizerParent == null) cityRandomizerParent = GameObject.Find("CScape City").GetComponent<CityRandomizer>() as CityRandomizer; if (cityRandomizerParent == null && isInRoot) { cityRandomizerParent = gameObject.transform.parent.transform.parent.GetComponent <CityRandomizer>() as CityRandomizer; } if (gameObject.GetComponent <CSRooftops>() != null) { hasRooftops = true; } advertising = gameObject.GetComponent <CSAdvertising>(); if (advertising != null) { hasAdvertising = true; advertising.useAdvertising = useAdvertising; } balcony = gameObject.GetComponent <CSArray>(); if (balcony != null) { hasBalcony = true; balcony.useAdvertising = useAdvertising; } else { hasBalcony = false; } floorDetails = gameObject.GetComponent <CSFloorDetails>(); if (floorDetails != null) { hasFloorDetails = true; } else { hasFloorDetails = false; } ModifyBuilding(); // Thread olix = new Thread(ModifyBuilding); } }
public override void OnInspectorGUI() { CSAdvertising bm = (CSAdvertising)target; GUILayout.Box(banner, GUILayout.ExpandWidth(true)); if (GUILayout.Button("Update Template")) { bm.AwakeMe(); bm.UpdateElements(); } bm.useAdvertising = EditorGUILayout.Toggle("Use Advertising Panels", bm.useAdvertising); bm.lodDistance = EditorGUILayout.Slider("Culling Distance", bm.lodDistance, 0f, 1f); bm.instancesX = EditorGUILayout.IntField("Advertising density", bm.instancesX); bm.randomScaleMin = EditorGUILayout.FloatField("Scale Min", bm.randomScaleMin); bm.randomScaleMax = EditorGUILayout.FloatField("Scale Max", bm.randomScaleMax); 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) { bm.AwakeMe(); bm.UpdateElements(); EditorUtility.SetDirty(bm); } }
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); } }