示例#1
0
    private bool CoroutineUpdate()
    {
        float realtimeSinceStartup = Time.realtimeSinceStartup;
        float delta = realtimeSinceStartup - this.mTime;

        if (delta >= 0.001f)
        {
            this.mTime = realtimeSinceStartup;
            this.UpdateList(this.mOnCoro, delta);
            bool isPlaying = Application.isPlaying;
            int  size      = this.mDest.size;
            while (size > 0)
            {
                DestroyEntry entry = this.mDest.buffer[--size];
                if (!isPlaying || (entry.time < this.mTime))
                {
                    if (entry.obj != null)
                    {
                        NGUITools.Destroy(entry.obj);
                        entry.obj = null;
                    }
                    this.mDest.RemoveAt(size);
                }
            }
            if (((this.mOnUpdate.Count == 0) && (this.mOnLate.Count == 0)) && ((this.mOnCoro.Count == 0) && (this.mDest.size == 0)))
            {
                NGUITools.Destroy(base.gameObject);
                return(false);
            }
        }
        return(true);
    }
示例#2
0
 public static void AddDestroy(UnityEngine.Object obj, float delay)
 {
     if (obj != null)
     {
         if (Application.isPlaying)
         {
             if (delay > 0f)
             {
                 CreateInstance();
                 DestroyEntry item = new DestroyEntry {
                     obj  = obj,
                     time = Time.realtimeSinceStartup + delay
                 };
                 mInst.mDest.Add(item);
             }
             else
             {
                 UnityEngine.Object.Destroy(obj);
             }
         }
         else
         {
             UnityEngine.Object.DestroyImmediate(obj);
         }
     }
 }
示例#3
0
 public static void AddDestroy(Object obj, float delay)
 {
     if (obj == null)
     {
         return;
     }
     if (Application.isPlaying)
     {
         if (delay > 0f)
         {
             CreateInstance();
             DestroyEntry destroyEntry = new DestroyEntry();
             destroyEntry.obj  = obj;
             destroyEntry.time = Time.realtimeSinceStartup + delay;
             mInst.mDest.Add(destroyEntry);
         }
         else
         {
             Object.Destroy(obj);
         }
     }
     else
     {
         Object.DestroyImmediate(obj);
     }
 }
示例#4
0
    private bool CoroutineUpdate()
    {
        float realtimeSinceStartup = Time.realtimeSinceStartup;
        float num = realtimeSinceStartup - mTime;

        if (num < 0.001f)
        {
            return(true);
        }
        mTime = realtimeSinceStartup;
        UpdateList(mOnCoro, num);
        bool isPlaying = Application.isPlaying;
        int  num2      = mDest.size;

        while (num2 > 0)
        {
            DestroyEntry destroyEntry = mDest.buffer[--num2];
            if (!isPlaying || destroyEntry.time < mTime)
            {
                if (destroyEntry.obj != null)
                {
                    NGUITools.Destroy(destroyEntry.obj);
                    destroyEntry.obj = null;
                }
                mDest.RemoveAt(num2);
            }
        }
        if (mOnUpdate.Count == 0 && mOnLate.Count == 0 && mOnCoro.Count == 0 && mDest.size == 0)
        {
            NGUITools.Destroy(base.gameObject);
            return(false);
        }
        return(true);
    }
示例#5
0
    /// <summary>
    /// Destroy the object after the specified delay in seconds.
    /// </summary>

    static public void AddDestroy(UnityEngine.Object obj, float delay)
    {
        if (obj == null)
        {
            return;
        }

        if (Application.isPlaying)
        {
            if (delay > 0f)
            {
                CreateInstance();

                DestroyEntry item = new DestroyEntry();
                item.obj  = obj;
                item.time = Time.realtimeSinceStartup + delay;
                mInst.mDest.Add(item);
                mInst.AutoStartCoro();
            }
            else
            {
                Destroy(obj);
            }
        }
        else
        {
            DestroyImmediate(obj);
        }
    }
示例#6
0
    /// <summary>
    /// Destroy the object after the specified delay in seconds.
    /// </summary>

    static public void AddDestroy(Object obj, float delay)
    {
        if (obj == null)
        {
            return;
        }

        if (Application.isPlaying)
        {
            if (delay > 0f)
            {
                CreateInstance();

                DestroyEntry item = new DestroyEntry();
                item.obj  = obj;
                item.time = (float)(Frontiers.WorldClock.RealTime + delay);                 // Time.realtimeSinceStartup + delay;
                mInst.mDest.Add(item);
            }
            else
            {
                Destroy(obj);
            }
        }
        else
        {
            DestroyImmediate(obj);
        }
    }
示例#7
0
    /// <summary>
    /// Call all coroutine update functions and destroy all delayed destroy objects.
    /// </summary>

    bool CoroutineUpdate()
    {
        float time  = Time.realtimeSinceStartup;
        float delta = time - mTime;

        if (delta < 0.001f)
        {
            return(true);
        }

        mTime = time;

        UpdateList(mOnCoro, delta);

        bool appIsPlaying = Application.isPlaying;

        for (int i = mDest.size; i > 0;)
        {
            DestroyEntry de = mDest.buffer[--i];

            if (!appIsPlaying || de.time < mTime)
            {
                if (de.obj != null)
                {
                    Tool_Destroy(de.obj);
                    de.obj = null;
                }
                mDest.RemoveAt(i);
            }
        }

        // Nothing left to update? Destroy this game object.
        if (mOnUpdate.Count == 0 && mOnLate.Count == 0 && mOnCoro.Count == 0 && mDest.size == 0)
        {
            Tool_Destroy(gameObject);
            mInst = null;
            return(false);
        }
        if (mOnCoro.Count == 0 && mDest.size == 0)
        {
            return(false);
        }

        return(true);
    }
示例#8
0
    /// <summary>
    /// Destroy the object after the specified delay in seconds.
    /// </summary>
    public static void AddDestroy(Object obj, float delay)
    {
        if (obj == null) return;

        if (Application.isPlaying)
        {
            if (delay > 0f)
            {
                CreateInstance();

                DestroyEntry item = new DestroyEntry();
                item.obj = obj;
                item.time = Time.realtimeSinceStartup + delay;
                mInst.mDest.Add(item);
            }
            else Destroy(obj);
        }
        else DestroyImmediate(obj);
    }
示例#9
0
    /// <summary>
    /// Call all coroutine update functions and destroy all delayed destroy objects.
    /// </summary>

    bool CoroutineUpdate()
    {
        double time  = Frontiers.WorldClock.RealTime;
        double delta = time - mTime;

        if (delta < 0.001)
        {
            return(true);
        }

        mTime = time;

        UpdateList(mOnCoro, (float)delta);

        bool appIsPlaying = Application.isPlaying;

        for (int i = mDest.size; i > 0;)
        {
            DestroyEntry de = mDest.buffer[--i];

            if (!appIsPlaying || de.time < mTime)
            {
                if (de.obj != null)
                {
                    NGUITools.Destroy(de.obj);
                    de.obj = null;
                }
                mDest.RemoveAt(i);
            }
        }

        // Nothing left to update? Destroy this game object.
        if (mOnUpdate.Count == 0 && mOnLate.Count == 0 && mOnCoro.Count == 0 && mDest.size == 0)
        {
            NGUITools.Destroy(gameObject);
            return(false);
        }
        return(true);
    }