Ejemplo n.º 1
0
 // Remove unnecessary tweens from LeanTween.
 private void OnDisable()
 {
     if (restartOnEnable)
     {
         LeanTween.Cancel(gameObject);
     }
 }
Ejemplo n.º 2
0
 // If object is destroyed, get rid of tweens.
 private void OnDestroy()
 {
     LeanTween.Cancel(gameObject);
 }
Ejemplo n.º 3
0
        // Builds the tween structure with all the appropriate values.
        // Cancels all previous tweens to keep a clean tween list.
        // The overallDelay variable is used to set a delay
        // to the entire group.
        // <param name="overallDelay">Overall delay.</param>
        public string BuildAllTweens(bool generateCode, bool resetPath, GameObject overrideGameObject = null)
        {
            if (isSimulating)
            {
                generateCode = false;
            }

            if (generateCode)
            {
                codeBuild = new System.Text.StringBuilder(1024);
                tabs      = "";
                if (doesAllLoop)
                {
                    tabs += "\t";
                }
            }
            else
            {
                LeanTween.Cancel(gameObject);
            }

            string preTabs       = tabs;
            float  lastTweenTime = GetAllGroupsDuration();
            int    i             = 0;

            foreach (LeanTweenGroup group in groupList)
            {
                bool wrapCode = (group.doesLoop && group.itemList.Count > 0) || group.delay > 0f;
                if (generateCode)
                {
                    if (i != 0)
                    {
                        codeBuild.Append("\n");
                    }
                    codeBuild.Append(tabs + "// " + group.groupName + " Group\n");
                }
                if (generateCode && wrapCode)
                {
                    codeBuild.Append(tabs + "LeanTween.DelayedCall(gameObject, " + GetGroupEndTime(group) + "f, ()=>{\n");
                    tabs += "\t";
                }

                if (generateCode)
                {
                    group.SetGenerateCode();
                }
                group.loopIter           = 0;
                group.overrideGameObject = overrideGameObject;
                this.resetPath           = resetPath;
                BuildGroup(group);

                tabs = preTabs;
                if (generateCode && wrapCode)
                {
                    if (group.delay > 0f)
                    {
                        codeBuild.Append(".SetDelay(" + group.delay + "f)");
                    }
                    codeBuild.Append(tabs + "}).SetOnCompleteOnStart(true)");
                    if (group.doesLoop)
                    {
                        codeBuild.Append(".SetRepeat(" + (group.loopCount < 0 ? -1 : group.loopCount - 1) + ")");
                    }
                    codeBuild.Append(";\n");
                }

                i++;
            }

            if (doesAllLoop)
            {
                if (generateCode)
                {
                    codeBuild.Insert(0, "LeanTween.DelayedCall(gameObject, " + lastTweenTime + "f, ()=>{\n");
                    codeBuild.Append("}).SetRepeat(" + repeatIter + ").SetOnCompleteOnStart(true);\n");
                }
                else if (repeatIter < loopAllCount - 1 || loopAllCount < 0)
                {
                    LeanTween.DelayedCall(gameObject, lastTweenTime, BuildAllTweensAgain);
                    repeatIter++;
                }
                else
                {
                    repeatIter = 0;
                    // reset optional
                }
            }
            if (generateCode)
            {
                return(codeBuild.ToString());
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
 //LeanTween.cancel
 public static void LeanCancel(this GameObject gameObject)
 {
     LeanTween.Cancel(gameObject);
 }