Пример #1
0
        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);
                }
            }
        }
 private void CheckIfNeedUnloadAudio()
 {
     if (!string.IsNullOrEmpty(Error) && m_clip != null)
     {
         DestroyUtils.DestroyImmediate(m_clip);
         m_clip = null;
     }
 }
Пример #3
0
 protected virtual void OnLevelLoaded()
 {
     if (MouseDragger.Instance != null && MouseDragger.Instance != this)
     {
         DestroyUtils.Destroy(MouseDragger.Instance.gameObject);
     }
     MouseDragger.Instance = this;
 }
Пример #4
0
 protected virtual void DeleteRopeClicked()
 {
     foreach (Rope2D v_rope in m_currentCreatedRopes)
     {
         if (v_rope != null)
         {
             DestroyUtils.Destroy(v_rope.gameObject);
         }
     }
 }
Пример #5
0
 public virtual void CancelRequest()
 {
     //var status = AsyncRequestOperation.Status;
     if (AsyncRequestOperation.Status != AsyncStatusEnum.Done)
     {
         AsyncRequestOperation.Status = AsyncStatusEnum.Cancelled;
         RequestStackManager.StopAllRequestsFromSender(this);
     }
     DestroyUtils.Destroy(this.gameObject);
 }
Пример #6
0
 protected virtual void HandleOnCancelRequest(MonoBehaviour sender, IEnumerator routine, string hash)
 {
     if (sender == this)
     {
         UnregisterEvents();
         if (AsyncRequestOperation.Status == AsyncStatusEnum.Processing)
         {
             DestroyUtils.Destroy(this);
         }
     }
 }
Пример #7
0
 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;
     }
 }
Пример #8
0
        public bool Cut()
        {
            if (RopeParent != null)
            {
                return(RopeParent.CutNode(this.gameObject));
            }
            else
            {
                DestroyUtils.DestroyImmediate(this.gameObject);
            }

            return(true);
        }
Пример #9
0
        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);
            }
        }
Пример #10
0
        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);
        }
Пример #11
0
 private void CheckIfNeedUnloadImage()
 {
     if (!string.IsNullOrEmpty(Error) && (m_sprite != null || m_texture != null))
     {
         var v_texture = m_sprite != null? m_sprite.texture : null;
         //Destroy SpriteTexture
         if (v_texture != null)
         {
             DestroyUtils.DestroyImmediate(m_sprite.texture);
         }
         //Destroy Object Texture
         if (m_texture != null && !MarkedToDestroy.IsMarked(m_texture))
         {
             DestroyUtils.DestroyImmediate(m_texture);
         }
         if (m_sprite != null)
         {
             DestroyUtils.DestroyImmediate(m_sprite);
         }
         m_texture = null;
         m_sprite  = null;
     }
 }
Пример #12
0
        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);
        }