protected virtual void TryCreateCanvasAndGraphics() { Canvas v_canvasOptimizer = GetComponent <Canvas>(); UnityEngine.UI.GraphicRaycaster v_graphicsRaycasting = GetComponent <UnityEngine.UI.GraphicRaycaster>(); if (UseCanvasRaycasterOptimization && FullScreenRendering) { if (FullScreenRendering) { if (v_canvasOptimizer == null) { v_canvasOptimizer = gameObject.AddComponent <Canvas>(); } if (v_graphicsRaycasting == null) { v_graphicsRaycasting = gameObject.AddComponent <UnityEngine.UI.GraphicRaycaster>(); } } } else { if (v_graphicsRaycasting != null) { DestroyUtils.Destroy(v_canvasOptimizer); } if (v_canvasOptimizer != null) { DestroyUtils.DestroyImmediate(v_graphicsRaycasting); } } }
protected virtual void OnLevelLoaded() { if (MouseDragger.Instance != null && MouseDragger.Instance != this) { DestroyUtils.Destroy(MouseDragger.Instance.gameObject); } MouseDragger.Instance = this; }
protected virtual void DeleteRopeClicked() { foreach (Rope2D v_rope in m_currentCreatedRopes) { if (v_rope != null) { DestroyUtils.Destroy(v_rope.gameObject); } } }
public virtual void CancelRequest() { //var status = AsyncRequestOperation.Status; if (AsyncRequestOperation.Status != AsyncStatusEnum.Done) { AsyncRequestOperation.Status = AsyncStatusEnum.Cancelled; RequestStackManager.StopAllRequestsFromSender(this); } DestroyUtils.Destroy(this.gameObject); }
protected virtual void HandleOnCancelRequest(MonoBehaviour sender, IEnumerator routine, string hash) { if (sender == this) { UnregisterEvents(); if (AsyncRequestOperation.Status == AsyncStatusEnum.Processing) { DestroyUtils.Destroy(this); } } }
protected override void HandleOnCancelRequest(MonoBehaviour sender, IEnumerator routine, string hash) { if (sender == this) { UnregisterEvents(); if (AsyncRequestOperation.Status == AsyncStatusEnum.Processing) { ProcessWWWReturn(null); DestroyUtils.Destroy(this); } AsyncRequestOperation.Status = AsyncStatusEnum.Cancelled; } }
protected IEnumerator DelayedDestroy(GameObject p_target, float p_lifeTime, float p_initialDelay, bool p_ignoreTimeScale) { if (p_target != null) { if (p_ignoreTimeScale) { yield return(new WaitForSecondsRealtime(p_initialDelay)); } else { yield return(new WaitForSeconds(p_initialDelay)); } var v_renderers = p_target.GetComponentsInChildren <Renderer>(); var v_currentTime = p_lifeTime; if (v_currentTime < 0) { v_currentTime = 0; } while (v_currentTime >= 0) { foreach (var v_renderer in v_renderers) { var v_delta = p_lifeTime <= 0 ? 0 : v_currentTime / p_lifeTime; if (v_renderer != null) { var v_spriteRenderer = v_renderer as SpriteRenderer; if (v_spriteRenderer != null) { v_spriteRenderer.color = new Color(v_spriteRenderer.color.r, v_spriteRenderer.color.g, v_spriteRenderer.color.b, 1 * v_delta); } else { if (v_renderer.material.HasProperty("_Color")) { v_renderer.material.color = new Color(v_renderer.material.color.r, v_renderer.material.color.g, v_renderer.material.color.b, 1 * v_delta); } } } } yield return(null); v_currentTime -= p_ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime; } DestroyUtils.Destroy(p_target); } }
private IEnumerator ProcessRequestInternal() { MarkedToDestroy.RemoveMark(this.gameObject); AsyncRequestOperation.Status = AsyncStatusEnum.Processing; yield return(ProcessRequest()); AsyncRequestOperation.Status = AsyncStatusEnum.Done; foreach (var v_func in FunctionsToCallWhenFinish) { if (v_func != null) { v_func.Params.Clear(); v_func.Params.Add(AsyncRequestOperation); v_func.CallFunction(); } } DestroyUtils.Destroy(this.gameObject); }
public static bool IsPrefab(GameObject p_object) { if (p_object != null) { if (Application.isEditor) { #if UNITY_EDITOR var v_path = UnityEditor.AssetDatabase.GetAssetPath(p_object); return(!string.IsNullOrEmpty(v_path)); #endif } else { #if UNITY_5_4_OR_NEWER return(!p_object.scene.IsValid() || string.IsNullOrEmpty(p_object.scene.name)); #else var v_sucess = false; GameObject v_tempObject = new GameObject(); //v_tempObject.hideFlags = HideFlags.HideAndDontSave; v_tempObject.transform.SetAsFirstSibling(); var v_parent = p_object.transform.root; if (v_parent == null) { v_parent = p_object.transform; } if (v_parent.GetSiblingIndex() == 0) { v_sucess = true; } DestroyUtils.Destroy(v_tempObject); return(v_sucess); #endif } } return(false); }