static Events() { Events.callers.Clear(); Events.cache.Clear(); Events.listeners.RemoveAll(x => x.name != "On Events Reset" && (!x.permanent || x.occurrences == 0)); #if UNITY_EDITOR Action Repair = () => { var main = Locate.GetScenePath("@Main"); if (main.GetComponent <EventDetector>().IsNull()) { main.AddComponent <EventDetector>(); main.hideFlags = HideFlags.HideInHierarchy; } #if UNITY_THEMES main.hideFlags = HideFlags.HideAndDontSave; #endif }; Repair(); Events.Add("On Destroy", () => Utility.DelayCall(Repair)); #endif foreach (var listener in Events.listeners) { var scope = Events.cache.AddNew(listener.target).AddNew(listener.name); scope[listener.method] = listener; } Events.Call("On Events Reset"); }
public static void Setup() { if (Proxy.IsPlaying() && Pool.prefabs.Count > 0) { GameObject empty = new GameObject("@Null"); empty.transform.parent = Locate.GetScenePath("@Instances").transform; Pool.empty = empty.AddComponent <Instance>(); Pool.empty.prefab = new PoolPrefab(); } }
public static void Repair() { var main = Locate.GetScenePath("@Main"); if (main.GetComponent <EventDetector>().IsNull()) { main.AddComponent <EventDetector>(); main.hideFlags = HideFlags.HideInHierarchy; } #if ZIOS_MINIMAL main.hideFlags = HideFlags.HideAndDontSave; #endif }
public void OnGUI() { if (!Proxy.IsPlaying() || this.disabled) { return; } var current = Event.current; if (current.isKey || current.shift || current.alt || current.control || current.command) { if (!this.devices.Exists(x => x.name == "Keyboard")) { this.devices.Add(new InputDevice("Keyboard")); } } bool uiActive = this.uiState != InputUIState.None; if (this.uiObject.IsNull()) { this.uiObject = Locate.Find("@Main/InputUI"); if (this.uiObject.IsNull()) { this.uiObject = GameObject.Instantiate(this.uiPrefab); this.uiObject.name = this.uiObject.name.Remove("(Clone)"); this.uiObject.transform.SetParent(Locate.GetScenePath("@Main").transform); Locate.SetDirty(); } } this.uiObject.SetActive(uiActive); Locate.Find("@Main/InputUI/ProfileCreate/").SetActive(false); Locate.Find("@Main/InputUI/ProfileSelect/").SetActive(false); if (uiActive) { Console.Close(true); InputState.disabled = true; this.DrawProfileSelect(); this.DrawProfileEdit(); bool hitEscape = Event.current.keyCode == KeyCode.Escape; if (Event.current.type == EventType.KeyDown && hitEscape) { this.uiState = InputUIState.None; InputState.disabled = false; } } }
public void BuildImages() { this.sprites = new SpriteController[this.amount]; this.nextSpawn = Time.Get() + this.delay; this.nextDeath = new float[this.amount]; Transform parent = Locate.GetScenePath("Effects").transform; for (int index = 0; index < this.amount; ++index) { GameObject image = (GameObject)Instantiate(source.gameObject); Component[] components = image.GetComponentsInChildren <Component>(); Type[] safe = new Type[] { typeof(Transform), typeof(SpriteController), typeof(MeshRenderer), typeof(MeshFilter), typeof(Renderer) }; foreach (Component current in components) { Type type = current.GetType(); if (type == typeof(Transform)) { Transform active = (Transform)current; bool child = active.parent == image.transform; if (child) { Destroy(active.gameObject); } } else if (!safe.Contains(type)) { Destroy(current); } } foreach (Transform current in image.transform) { Destroy(current); } this.sprites[index] = image.GetComponentInChildren <SpriteController>(); image.name = source.name + "-AfterImage-" + (index + 1); image.transform.parent = parent; image.GetComponent <Renderer>().material = new Material(image.GetComponent <Renderer>().material); image.GetComponent <Renderer>().material.shader = Shader.Find("Zios/Olio/Sprite + Particle + Lerp"); image.GetComponent <Renderer>().material.SetFloat("lerpCutoff", 0); image.SetActive(false); this.sprites[index].Start(); } }
public static void Build(PoolPrefab blueprint) { if (blueprint == null || blueprint.prefab == null) { return; } Transform instanceGroup = Locate.GetScenePath("@Instances").transform; Instance[] slots = Pool.instances[blueprint.name] = new Instance[blueprint.maximum]; for (int current = 0; current < blueprint.maximum; ++current) { GameObject gameObject = (GameObject)GameObject.Instantiate(blueprint.prefab); Instance instance = slots[current] = gameObject.AddComponent <Instance>(); instance.prefab = blueprint; instance.gameObject.SetActive(false); instance.gameObject.transform.parent = instanceGroup; instance.gameObject.transform.localScale = blueprint.scale; if (blueprint.uniqueMaterial) { Material material = instance.gameObject.GetComponent <Renderer>().sharedMaterial; instance.gameObject.GetComponent <Renderer>().sharedMaterial = (Material)Material.Instantiate(material); } } }
private static void Step() { if (Class.complete) { return; } int index = Class.index; MeshFilter filter = Class.filters[index]; string updateMessage = "Mesh " + index + "/" + Class.meshCount; bool canceled = EditorUI.DrawProgressBar("Combining Meshes", updateMessage, ((float)index) / Class.meshCount); if (canceled) { Class.meshCount = 0; } else if (filter != null && filter.sharedMesh != null) { if ((Class.vertexCount + filter.sharedMesh.vertexCount) >= 65534) { Log.Show("[Combine Meshes] Added extra submesh due to vertices at " + Class.vertexCount); Class.StepLast(); Class.meshes.Add(new Mesh()); Class.subIndex = index; Class.vertexCount = 0; } Mesh currentMesh = filter.sharedMesh; if (filter.sharedMesh.subMeshCount > 1) { currentMesh = (Mesh)UnityEngine.Object.Instantiate(filter.sharedMesh); currentMesh.triangles = currentMesh.triangles; } Class.combines[index].mesh = currentMesh; Class.combines[index].transform = filter.transform.localToWorldMatrix; Class.vertexCount += currentMesh.vertexCount; if (Class.inline) { Component.DestroyImmediate(filter.gameObject.GetComponent <MeshRenderer>()); Component.DestroyImmediate(filter.gameObject.GetComponent <MeshFilter>()); } } Class.index += 1; if (Class.index >= Class.meshCount) { if (!canceled) { Class.StepLast(); //Material material = File.GetAsset<Material>("Baked.mat"); if (!Class.inline) { foreach (GameObject current in Class.selection) { GameObject target = (GameObject)GameObject.Instantiate(current); target.name = target.name.Replace("(Clone)", ""); target.transform.parent = Locate.GetScenePath("Scene-Combined").transform; MeshFilter[] filters = target.GetComponentsInChildren <MeshFilter>(); foreach (MeshFilter nullFilter in filters) { Component.DestroyImmediate(nullFilter.gameObject.GetComponent <MeshRenderer>()); Component.DestroyImmediate(nullFilter.gameObject.GetComponent <MeshFilter>()); } current.SetActive(false); } } bool singleRoot = Class.selection.Length == 1; string start = singleRoot ? Class.selection[0].name + "/" : ""; foreach (Mesh mesh in Class.meshes) { GameObject container = new GameObject("@Mesh" + Class.meshNumber); if (Class.inline && singleRoot) { container.transform.parent = Class.selection[0].transform; } else { container.transform.parent = Locate.GetScenePath("Scene-Combined/" + start).transform; } //MeshRenderer containerRenderer = container.AddComponent<MeshRenderer>(); MeshFilter containerFilter = container.AddComponent <MeshFilter>(); if (Class.path.IsEmpty()) { Class.path = EditorUtility.SaveFolderPanel("Combine Meshes", Application.dataPath, "").GetAssetPath(); } File.Create(path); ProxyEditor.CreateAsset(mesh, path + "/Combined" + meshNumber + ".asset"); containerFilter.mesh = mesh; //containerRenderer.material = new Material(material); Class.meshNumber += 1; } } TimeSpan span = TimeSpan.FromSeconds(Time.Get() - Class.time); string totalTime = span.Minutes + " minutes and " + span.Seconds + " seconds"; Log.Show("[Combine Meshes] Reduced " + Class.meshCount + " meshes to " + Class.meshes.Count + "."); Log.Show("[Combine Meshes] Completed in " + totalTime + "."); ProxyEditor.SaveAssets(); EditorUI.ClearProgressBar(); Class.complete = true; while (EditorApplication.update == Class.Step) { EditorApplication.update -= Class.Step; } } }