public static T DestroySelfGracefully <T>(this T selfObj) where T : Object { if (selfObj) { Object.Destroy(selfObj); } return(selfObj); }
public static T DestroySelfAfterDelayGracefully <T>(this T selfObj, float delay) where T : Object { if (selfObj) { Object.Destroy(selfObj, delay); } return(selfObj); }
// Clear the pool public void Clear(bool destroyObjects = true) { if (destroyObjects) { // Destroy all the Objects in the pool foreach (T item in pool) { Object.Destroy(item as Object); } } pool.Clear(); }
public void Initialize() { List <ViewableEntityInitializer> initializableEntities = Object.FindObjectsOfType <ViewableEntityInitializer>().ToList(); foreach (ViewableEntityInitializer initializableEntity in initializableEntities) { List <BaseComponentMonoBehaviour> monoComponents = initializableEntity.GetComponents <BaseComponentMonoBehaviour>().ToList(); IContext currentContext = _contexts.game; Entity entity = (Entity)currentContext.GetType().InvokeMember("CreateEntity", BindingFlags.InvokeMethod, null, currentContext, null); string componentLookupClassName = currentContext.contextInfo.name + "ComponentsLookup"; Type[] componentTypes = (Type[])Type.GetType(componentLookupClassName).GetField("componentTypes", BindingFlags.Public | BindingFlags.Static).GetValue(null); IComponent viewComponent = new ViewComponent { gameObject = initializableEntity.gameObject }; int viewComponentIndex = Array.IndexOf(componentTypes, viewComponent.GetType()); entity.AddComponent(viewComponentIndex, viewComponent); foreach (BaseComponentMonoBehaviour monoComponent in monoComponents) { var component = monoComponent.Component; int componentIndex = Array.IndexOf(componentTypes, component.GetType()); //@todo Implement univeral 'special case' initializers if (component.GetType() == typeof(NavAgentComponent)) { ((NavAgentComponent)component).value = initializableEntity.GetComponent <NavAgentBehaviour>(); } entity.AddComponent(componentIndex, component); Object.Destroy(monoComponent); } initializableEntity.gameObject.Link(entity, currentContext); Object.Destroy(initializableEntity); } }
public void Dispose() { using (var iterator = deployedScenes.GetEnumerator()) { while (iterator.MoveNext()) { Object.Destroy(iterator.Current.Value.gameObject); } } deployedScenes.Clear(); using (var iterator = projectScenes.GetEnumerator()) { while (iterator.MoveNext()) { Object.Destroy(iterator.Current.Value.gameObject); } } projectScenes.Clear(); }
/// <summary> /// Create car spawner on the map /// </summary> /// <returns>Do car spawners paths have access to each other</returns> private bool BuildCarSpawner() { var carSpawners = CarSpawnerGen().ToList(); InitPathFinding(); if (_graph.GetRange(1, _graph.Count - 1).Any(pos => !Dijkstras.shortest_path(_graph.First(), pos).Any())) { _graph.Clear(); _road.Clear(); foreach (var spawners in carSpawners) { Object.Destroy(spawners.gameObject); } return(false); } foreach (var spawner in carSpawners) { _map.SetNewOwner(spawner); } return(true); }
public void Destroy(T pItem) { mActiveList.Remove(pItem); mInactiveList.Remove(pItem); Object.Destroy(pItem); }
/// <summary> /// Checks the popup buttons and closes them if none of them are hovered. /// </summary> /// <param name="clickType"> The ClickType that was pressed. </param> private void CheckPopupButtons(ClickType clickType) { if (clickType != ClickType.Down) { return; } if (observables.Count == 0 || observables.Where(observable => observable.PointerEntered).Count() > 0) { return; } observables.Where(button => button.PopupObject != null).ToList().SafeForEach(obj => Object.Destroy(obj.PopupObject)); observables.Clear(); onObjectsDestroyed?.Invoke(); }
//释放掉当前UI所占的内存 public static void DestroyUI(string uiName) { Object.Destroy(uiDic[uiName]); uiDic.Remove(uiName); }
void Destroy() { _go.onClick.RemoveListener(() => CreateImageFromText()); Object.Destroy(_dropdown); Object.Destroy(_go); }
private static IEnumerator SaveMinimapImpl(string path, int size) { bool wasLarge = Minimap.instance.m_largeRoot.activeSelf; if (!wasLarge) { Minimap.instance.SetMapMode(Minimap.MapMode.Large); Minimap.instance.CenterMap(Vector3.zero); } bool wasClouds = MinimapCloudsEnabled; DisableMinimapClouds(); var mapPanelObject = CreateQuad(100, 100, 10, Minimap.instance.m_mapImageLarge.material); mapPanelObject.layer = 19; var renderTexture = new RenderTexture(size, size, 24); var cameraObject = new GameObject(); cameraObject.layer = 19; var camera = cameraObject.AddComponent <Camera>(); camera.targetTexture = renderTexture; camera.orthographic = true; camera.rect = new Rect(0, 0, renderTexture.width, renderTexture.height); camera.nearClipPlane = 0; camera.farClipPlane = 100; camera.orthographicSize = 50; camera.cullingMask = 1 << 19; camera.Render(); yield return(new WaitForEndOfFrame()); RenderTexture.active = renderTexture; var tex = new Texture2D(renderTexture.width, renderTexture.height, TextureFormat.RGB24, false); tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0); tex.Apply(); RenderTexture.active = null; Directory.CreateDirectory(Path.GetDirectoryName(path)); Console.instance.Print($"Screenshot of minimap saved to {path}"); File.WriteAllBytes(path, ImageConversion.EncodeToPNG(tex)); Object.Destroy(mapPanelObject); Object.Destroy(cameraObject); Object.Destroy(renderTexture); Object.Destroy(tex); if (!wasLarge) { Minimap.instance.SetMapMode(Minimap.MapMode.Small); } if (wasClouds) { EnableMinimapClouds(); } }
private void OnCreditsDialogCloseClick() { _creditsDialog.Utilize(); Object.Destroy(_creditsDialog.gameObject); }
public static bool UpdateFire_Prefix(Fire __instance) { float lifetime = 10f; float spreadTime = 5f; float generationCap = 6; if (BMChallenges.IsChallengeFromListActive(cChallenge.AffectsFires)) { if (GC.challenges.Contains(cChallenge.NapalmSprings)) { lifetime = 20f; spreadTime = 15f; generationCap = 99f; } else if (GC.challenges.Contains(cChallenge.Mildfire)) { lifetime = 6f; spreadTime = 3f; generationCap = 2; } if (GC.challenges.Contains(cChallenge.GasolineHumidity)) { spreadTime = lifetime - 2f; } } if (GC.serverPlayer) { if (!__instance.hasBurningObject && !__instance.noObject) { __instance.timeLeft = 0f; if (!__instance.destroying) { try { __instance.DestroyMe(); } catch { Debug.LogError(string.Concat(new object[] { "Fire DestroyMe Error 1: ", __instance, " - ", __instance.UID })); } } } if (__instance.timeLeft <= 0f) { goto IL_460; } if (__instance.burningObjectAgent && __instance.hasObjectAgent) { try { __instance.objectAgent.tr.position = __instance.tr.position; } catch { } } __instance.timeLeft -= Time.deltaTime; __instance.timeToOilSpread -= Time.deltaTime; if (__instance.timeLeft <= spreadTime && !__instance.fireHasSpread && __instance.canSpread) { try { if (__instance.generation < generationCap && GC.serverPlayer) { __instance.StartCoroutine(__instance.FireSpread()); } __instance.fireHasSpread = true; } catch { Debug.LogError(string.Concat(new object[] { "Fire Spread Error 1: ", __instance, " - ", __instance.UID })); } } if (__instance.timeLeft <= spreadTime && __instance.neverGoOut) { __instance.timeLeft = lifetime; } if (__instance.timeLeft <= spreadTime && __instance.oilFireTime > 0) { __instance.oilFireTime--; __instance.timeLeft = lifetime; } if (__instance.timeLeft <= 0f && !__instance.destroying) { try { __instance.DestroyMe(); goto IL_460; } catch { Debug.LogError(string.Concat(new object[] { "Fire DestroyMe Error 2: ", __instance, " - ", __instance.UID })); if (__instance.particles != null) { __instance.particles.GetComponent <ParticleSystem>().Stop(); __instance.particles.transform.SetParent(GC.particleEffectsNest.transform); } GC.firesList.Remove(__instance); Object.Destroy(__instance.gameObject); return(false); } } if (__instance.timeToOilSpread > 0f || __instance.hasSpreadOil) { goto IL_460; } try { __instance.timeToOilSpread = __instance.timeToOilSpreadBase; __instance.FireSpreadOil(); __instance.hasSpreadOil = true; goto IL_460; } catch { Debug.LogError(string.Concat(new object[] { "Fire Spread Error 2: ", __instance, " - ", __instance.UID })); if (__instance.particles != null) { __instance.particles.GetComponent <ParticleSystem>().Stop(); __instance.particles.transform.SetParent(GC.particleEffectsNest.transform); } GC.firesList.Remove(__instance); Object.Destroy(__instance.gameObject); return(false); } } if (!__instance.clientDestroyed && __instance.destroying) { try { __instance.clientDestroyed = true; __instance.DestroyMe(); goto IL_460; } catch { Debug.LogError(string.Concat(new object[] { "Fire DestroyMe Error 3: ", __instance, " - ", __instance.UID })); goto IL_460; } } if (!GC.serverPlayer && !__instance.destroying && __instance.burningObject != null) { try { if (__instance.burningObjectAgent || __instance.burningObjectItem) { __instance.tr.position = new Vector3(__instance.burningObject.transform.position.x, __instance.burningObject.transform.position.y - 0.1f, __instance.burningObject.transform.position.z); } else { __instance.tr.position = __instance.burningObject.transform.position; } } catch { Debug.LogError(string.Concat(new object[] { "Fire Transform Error: ", __instance, " - ", __instance.burningObject })); } } IL_460: if (__instance.tr.eulerAngles != Vector3.zero) { __instance.tr.eulerAngles = Vector3.zero; } return(false); }
private void DestroyCardView(SceneCardView sceneCardView) { Object.Destroy(sceneCardView.gameObject); }
public static void OnUnSpawnPlayer(GameObject unspawned) { Object.Destroy(unspawned); }
public void Dispose() { OnDispose(); Object.Destroy(Go); }
void TestUnspawnDelegate(NetworkIdentity identity) { Object.Destroy(identity.gameObject); }
public void TearDown() { Object.Destroy(DummyGameObject); }
public static void Destroy(Object obj) { float t = 0f; Object.Destroy(obj, t); }
private static void BuildInventoryGrid(ref InventoryGrid grid, string name, Vector2 position, Vector2 size, InventoryGui inventoryGui) { if (grid != null) { Object.Destroy(grid); grid = null; } var go = new GameObject(name, typeof(RectTransform)); go.transform.SetParent(inventoryGui.m_player, false); var highlight = new GameObject("SelectedFrame", typeof(RectTransform)); highlight.transform.SetParent(go.transform, false); highlight.AddComponent <Image>().color = Color.yellow; var highlightRT = highlight.transform as RectTransform; highlightRT.anchoredPosition = new Vector2(0, 0); highlightRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x + 2); highlightRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y + 2); highlightRT.localScale = new Vector3(1, 1, 1); var bkg = inventoryGui.m_player.Find("Bkg").gameObject; var background = Object.Instantiate(bkg, go.transform); background.name = name + "Bkg"; var backgroundRT = background.transform as RectTransform; backgroundRT.anchoredPosition = new Vector2(0, 0); backgroundRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x); backgroundRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y); backgroundRT.localScale = new Vector3(1, 1, 1); grid = go.AddComponent <InventoryGrid>(); var root = new GameObject("Root", typeof(RectTransform)); root.transform.SetParent(go.transform, false); var rect = go.transform as RectTransform; rect.anchoredPosition = position; grid.m_elementPrefab = inventoryGui.m_playerGrid.m_elementPrefab; grid.m_gridRoot = root.transform as RectTransform; grid.m_elementSpace = inventoryGui.m_playerGrid.m_elementSpace; grid.ResetView(); if (name == "EquipmentSlotGrid") { grid.m_onSelected += OnEquipmentSelected(inventoryGui); grid.m_onRightClick += OnEquipmentRightClicked(inventoryGui); } else { grid.m_onSelected += OnSelected(inventoryGui); grid.m_onRightClick += OnRightClicked(inventoryGui); } grid.m_uiGroup = grid.gameObject.AddComponent <UIGroupHandler>(); grid.m_uiGroup.m_groupPriority = 1; grid.m_uiGroup.m_active = true; grid.m_uiGroup.m_enableWhenActiveAndGamepad = highlight; var list = inventoryGui.m_uiGroups.ToList(); list.Insert(2, grid.m_uiGroup); inventoryGui.m_uiGroups = list.ToArray(); }
public void Flow3() { Object.Destroy(window.transform.gameObject); finishedAct(); }
public virtual void DestroyView(GameObject view) { Object.Destroy(view); }
public static void Destroy(this Object me) { Object.Destroy(me); }
private void EachBtn_Delete(GameObject go) // 点击了 Item 的 Delete { l_CurrentBeans.Remove(itemSelectK_ResutltV[go]); itemSelectK_ResutltV.Remove(go); Object.Destroy(go); }
public static void DestroySelf <T>(this T selfObj) where T : Object { Object.Destroy(selfObj); }
public void Dispose() { Object.Destroy(_scheduler.gameObject); }
public static T DestroySelfAfterDelay <T>(this T selfObj, float afterDelay) where T : Object { Object.Destroy(selfObj, afterDelay); return(selfObj); }
//释放掉UI所占的内存 public void Clear() { ClearAllText(); Object.Destroy(transform.gameObject); }
public void Dispose() { Object.Destroy(asset); }
public override void Finish(PlayerRunner player) { Object.Destroy(effectTransform.gameObject); player.GetLife().indestructable = false; player.gameObject.SetLayer(playerLayer); }