static object GetValueForPropertyOnObject(SpriteFrameSave spriteFrameSave, string fieldOrProperty) { object returnValue = GetValueForPropertyOnObject <SpriteFrameSave>(spriteFrameSave, fieldOrProperty); // Many of the properties on the SpriteFrame are actually on the Sprite itself. if (returnValue == null) { returnValue = GetValueForPropertyOnObject(spriteFrameSave.ParentSprite, fieldOrProperty); } return(returnValue); }
private AnimationChainListSave GetAnimationChainListFromScnxReference(NamedObjectSave referencedNos) { string sourceFileName = ContentDirectory + referencedNos.SourceFile; string sourceFileDirectory = FlatRedBall.IO.FileManager.GetDirectory(sourceFileName); AnimationChainListSave acls = null; SpriteEditorScene ses; if (System.IO.File.Exists(sourceFileName)) { ses = SpriteEditorScene.FromFile(sourceFileName); string truncatedName = referencedNos.SourceName.Substring(0, referencedNos.SourceName.LastIndexOf('(') - 1); SpriteSave spriteSave = ses.FindSpriteByName(truncatedName); if (spriteSave != null && !string.IsNullOrEmpty(spriteSave.AnimationChainsFile)) { acls = AnimationChainListSave.FromFile( sourceFileDirectory + spriteSave.AnimationChainsFile); } if (acls == null) { SpriteFrameSave sfs = ses.FindSpriteFrameSaveByName(truncatedName); if (sfs != null) { acls = AnimationChainListSave.FromFile( sourceFileDirectory + sfs.ParentSprite.AnimationChainsFile); } } } return(acls); }
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"); }