Esempio n. 1
0
        private static void AddResetVariablesForSpriteOrSpriteFrame(NamedObjectSave nos, List <string> variables)
        {
            // todo - support resetting animation chains on Sprites that aren't using a .scnx
            if (nos.SourceType == SourceType.File && !string.IsNullOrEmpty(nos.SourceFile))
            {
                string            fullFile = ProjectManager.MakeAbsolute(nos.SourceFile);
                SpriteEditorScene ses      = SpriteEditorScene.FromFile(fullFile);

                int endingIndex = nos.SourceName.LastIndexOf('(');

                string     nameWithoutType = nos.SourceName.Substring(0, endingIndex - 1);
                SpriteSave ss = ses.FindSpriteByName(nameWithoutType);

                string animationChainFileName = "";
                if (ss != null)
                {
                    animationChainFileName = ss.AnimationChainsFile;
                }
                else
                {
                    SpriteFrameSave sfs = ses.FindSpriteFrameSaveByName(nameWithoutType);
                    if (sfs != null)
                    {
                        animationChainFileName = sfs.ParentSprite.AnimationChainsFile;
                    }
                }

                if (!string.IsNullOrEmpty(animationChainFileName))
                {
                    variables.Add("CurrentChainName");
                    variables.Add("CurrentFrameIndex");
                }
            }

            variables.Add("Alpha");
            variables.Add("AlphaRate");
        }