private bool FunctionPlayEndBody(Script_SpriteStudio6_Root scriptRoot, GameObject objectControl) { /* MEMO: Recommend not to change animation playing state in PlayEnd callback processing function. */ switch (AnimationBodyPlaying) { case KindAnimationBody.WAIT: if (0.5f < Random.value) { AnimationBodyRequest = KindAnimationBody.PUT_OUT_L; } else { AnimationBodyRequest = KindAnimationBody.WAIT; } CountRemain--; if (0 > CountRemain) { /* Destroy Self */ /* MEMO: Animation object destroys self when Highest-Parent animation's PlayEnd callback processing function returns false. */ return(false); } break; case KindAnimationBody.PUT_OUT_L: AnimationBodyRequest = KindAnimationBody.RETURN_L; break; case KindAnimationBody.RETURN_L: AnimationBodyRequest = KindAnimationBody.WAIT; break; } return(true); }
/* ----------------------------------------------- Functions */ #region Functions private bool EyeCheckInitialized() { if (false == FlagInitializedEye) { FlagInitializedEye = true; /* Get PartID (Eye's "Instance"-control parts) & "Instance" */ for (int i = 0; i < (int)KindEye.TERMINATOR; i++) { TableIDPartsControlEye[i] = ScriptRoot.IDGetParts(TableNamePartsEye[i]); } /* MEMO: The reason for getting an instance is because it is necessary to get "Instance" animation's "PlayEnd" callback. */ /* In principle, not recommended that you directly control the "Instance" animation. */ /* However, since may be necessary such implementation, will provide basic method as a sample. */ /* MEMO: In the case of this sample, "right eye" and "left eye" play in synchronously. */ /* Enough to callbacking from one side("left eye") only. */ int indexPartsEyeL = TableIDPartsControlEye[(int)KindEye.L]; if (0 <= indexPartsEyeL) { ScriptRootInstanceEyeL = ScriptRoot.InstanceGet(indexPartsEyeL); FlagInitializedEye = true; } TimeWaitBlinkEye = (float)((int)Constant.BLANK_EYE_INITIAL); } return(FlagInitializedEye); }
// アニメーション 再生/変更 private void AnimationChange(AnimationPattern pattern) { Script_SpriteStudio6_Root scriptRoot = null; // SpriteStudio Anime を操作するためのクラス int iTimesPlaey = 0; if (m_goCharacter == null) { return; } scriptRoot = Script_SpriteStudio6_Root.Parts.RootGet(m_goCharacter); if (scriptRoot != null) { switch (pattern) { case AnimationPattern.Wait: iTimesPlaey = 0; // ループ再生 break; case AnimationPattern.Attack: iTimesPlaey = 1; // 1回だけ再生 break; case AnimationPattern.Run: iTimesPlaey = 0; // ループ再生 break; default: break; } scriptRoot.AnimationPlay(-1, (int)pattern, iTimesPlaey); } }
private bool TablSetMaterialInstanceMain(int idParts, UnityEngine.Material[] tableMaterial, bool flagInvolveChildInstance = true) { Script_SpriteStudio6_Root instanceRootInstance = null; bool flagSuccess = true; if ((null == TableControlParts) || (0 > idParts) || (TableControlParts.Length <= idParts)) { return(false); } if (Library_SpriteStudio6.Data.Parts.Animation.KindFeature.INSTANCE == DataAnimation.TableParts[idParts].Feature) { instanceRootInstance = TableControlParts[idParts].InstanceRootUnderControl; if (null == instanceRootInstance) { return(true); } flagSuccess &= instanceRootInstance.TableSetMaterial(tableMaterial); if (true == flagInvolveChildInstance) { flagSuccess &= instanceRootInstance.TableSetMaterialInstance(-1, tableMaterial, true); } } return(true); }
/* ----------------------------------------------- MonoBehaviour-Functions */ #region MonoBehaviour-Functions void Start() { /* Initialize WorkArea */ FlagInitializedEye = false; for (int i = 0; i < (int)KindEye.TERMINATOR; i++) { TableIDPartsControlEye[i] = -1; } /* Get Animation Control Script-Component */ GameObject gameObjectBase = GameObjectRoot; if (null == gameObjectBase) { gameObjectBase = gameObject; } ScriptRoot = Script_SpriteStudio6_Root.Parts.RootGet(gameObjectBase); if (null == ScriptRoot) { /* Error */ return; } /* Set PlayEnd-callback (for "Body") */ ScriptRoot.FunctionPlayEnd = FunctionPlayEndBody; /* Set initial animation */ AnimationBodyRequest = KindAnimationBody.WAIT; /* Initialize Complete */ FlagInitialized = true; }
private bool CallBackFunctionPlayEnd(Script_SpriteStudio6_Root scriptRoot, GameObject objectControl) { /* Progress Step */ IndexStep++; int countStep = CountGetStep(); if (countStep <= IndexStep) { /* Range Over */ if (null != FunctionPlayEnd) { FunctionPlayEnd(this); } /* Set behavior after finished */ switch (TypeLoop) { case Library_SpriteStudio6.Data.Sequence.Type.LAST: IndexStep = countStep - 1; break; case Library_SpriteStudio6.Data.Sequence.Type.TOP: IndexStep = 0; break; case Library_SpriteStudio6.Data.Sequence.Type.KEEP: default: /* MEMO: Step is not changed. */ return(true); } } Status |= FlagBitStatus.UPDATE_STEP; return(true); }
private bool ClusterResetUnderControl() { if ((null == DataAnimation) || (null == TableControlParts)) { return(false); } int countParts = DataAnimation.TableParts.Length; for (int i = 0; i < countParts; i++) { switch (DataAnimation.TableParts[i].Feature) { case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.ROOT: case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.NULL: case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.NORMAL: break; case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.INSTANCE: { Script_SpriteStudio6_Root rootUnderControl = TableControlParts[i].InstanceRootUnderControl; if (null != rootUnderControl) { /* MEMO: "Instance" can be nested. */ rootUnderControl.ClusterBootUpDraw(); rootUnderControl.ClusterResetUnderControl(); } } break; case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.EFFECT: { Script_SpriteStudio6_RootEffect rootUnderControl = TableControlParts[i].InstanceRootEffectUnderControl; if (null != rootUnderControl) { /* MEMO: "Effect" cannot control any animation-object. */ rootUnderControl.ClusterBootUpDraw(); } } break; case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.MASK: break; case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.JOINT: case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.BONE: case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.MOVENODE: case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.CONSTRAINT: case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.BONEPOINT: case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.MESH: break; case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.TRANSFORM_CONSTRAINT: case Library_SpriteStudio6.Data.Parts.Animation.KindFeature.CAMERA: break; } } return(true); }
/* ----------------------------------------------- MonoBehaviour-Functions */ #region MonoBehaviour-Functions void Start() { /* Initialize WorkArea */ FlagPaddingZeroPrevious = !FlagPaddingZero; /* Since this value can not be set with initializer... */ /* Get Animation Control Script-Component */ GameObject gameObjectBase = GameObjectRoot; if (null == gameObjectBase) { gameObjectBase = gameObject; } /* MEMO: "Script_SpriteStudio6_Root.Parts.RootGet" is function for finding "Script_SpriteStudio6_Root" in GameObjects below. */ /* (However, "Instance" is excluded. Find only "Highest-Root"-parts) */ /* You can find "shallowest hierarchy"-one from direct-children, but not guarantee the shallowest when deeper than children. */ /* Because wasteful to search every time access, recommend to cache. */ ScriptRoot = Script_SpriteStudio6_Root.Parts.RootGet(gameObjectBase); if (null == ScriptRoot) { /* Error */ return; } /* Animation Start */ /* MEMO: Since animation without movement, no problem even if stops right after playing. */ /* (no problem even if does not stop too.) */ /* However, stopped animation has less CPU load than continue playing. */ /* MEMO: Since useless to search animation-index every time, recommend to cache frequently used indexes. */ int indexAnimation = ScriptRoot.IndexGetAnimation("Digit08"); if (0 > indexAnimation) { /* Animation not found */ return; } ScriptRoot.AnimationPlay(-1, indexAnimation, 1); ScriptRoot.AnimationStop(-1); /* Get Digit-Parts */ /* MEMO: Get animation-parts for value's each digit. */ /* MEMO: It is desirable that Animation's information are gotten after initialization of animation. */ for (int i = 0; i < (int)Constant.DIGIT_MAX; i++) { /* MEMO: Be careful. When part's name is not found, "-1" is assigned. */ TableIDPartsDigit[i] = ScriptRoot.IDGetParts(TableNameParts[i]); } /* Get Characters' Cell Index */ /* MEMO: Get cell index of bitmap font. */ Library_SpriteStudio6.Data.CellMap cellMap = ScriptRoot.CellMapGet(0); /* Since only 1 texture, specifying direct-value. (Cut corners ...) */ for (int i = 0; i < (int)KindCharacter.TERMINATOR; i++) { TableIndexCell[i] = cellMap.IndexGetCell(TableNameCell[i]); } /* Initialize Complete */ FlagInitialized = true; }
private bool FunctionPlayEndEye(Script_SpriteStudio6_Root scriptRoot, GameObject objectControl) { /* MEMO: Recommend not to change animation playing state in PlayEnd callback processing function. */ AnimationEyeRequest = KindAnimationEye.WAIT; TimeWaitBlinkEye = Random.Range((float)((int)Constant.BLANK_EYE_MIN), (float)((int)Constant.BLANK_EYE_MAX)) + 0.5f; /* MEMO: "Instance"'s PlayEnd callback processing function should never return false. */ /* "Instance" animation can not destroy self. (Returning false will also ignore it) */ /* If you really want to create state that "Instance" is disappeared, create hiding animation or hide "Instance"-part. */ return(true); }
/* ******************************************************** */ //! Change "Instance" /*! * @param idParts * Parts-ID ("Instance"-part) * @param source * Source of new "Instance" (mainly "Prefab")<br> * null == Revert to initial data * @retval Return-Value * true == Success<br> * false == Failure (Error) * * Set(Change) "Instance" controled by part.<br> * <br> * Be careful when using this function.<br> * <br> * This function is heavey load and consumes "Managed-Heap".<br> * Because execute following process, basically.<br> * <br> * - Destroy old "Instance"<br> * - Instantiate "source"(New "Instance")<br> * - Rebuild parent-animation's drawing-meshes buffer<br> * <br> * Also, when set new "Instance", animation to be played is set animation of index 0.<br> * (When revert, set animation-index that original-data has)<br> * <br> * Depending on animation data of the newly set "Instance", may not playing-result as expected.<br> * (Pay attention that how to be controlled from the "Instance"-part)<br> * <br> * Caution that not to cause infinite-nesting by replacing.<br> */ public bool InstanceChange(int idParts, GameObject source) { if ((null == DataAnimation) || (null == TableControlParts)) { return(false); } /* Get now status. */ Script_SpriteStudio6_Root scriptInstance = InstanceGet(idParts); if (null == scriptInstance) { return(false); } bool flagHideForceOld = scriptInstance.FlagHideForce; bool flagPlanarizationOld = scriptInstance.FlagPlanarization; int orderInLayerOld = scriptInstance.OrderInLayer; float rateOpacityOld = scriptInstance.RateOpacity; Vector2 rateScaleOld = scriptInstance.RateScaleLocal; /* Renew "Instance" */ Script_SpriteStudio6_Root scriptRootHighest = RootGetHighest(); if (null == scriptRootHighest) { scriptRootHighest = this; } if (false == TableControlParts[idParts].BootUpInstance(this, idParts, true, source)) { return(false); } /* Set status. */ scriptInstance = InstanceGet(idParts); /* Get New Instance */ scriptInstance.FlagHideForce = flagHideForceOld; scriptInstance.FlagPlanarization = flagPlanarizationOld; scriptInstance.OrderInLayer = orderInLayerOld; scriptInstance.RateOpacity = rateOpacityOld; scriptInstance.RateScaleLocal = rateScaleOld; /* Rebuild Hiest-Root's Draw buffers */ if (false == scriptRootHighest.ClusterBootUpDraw()) { return(false); } if (false == scriptRootHighest.ClusterResetUnderControl()) { return(false); } return(true); }
/* ----------------------------------------------- Functions */ #region Functions private void OnEnable() { InstanceRoot = (Script_SpriteStudio6_Root)target; serializedObject.FindProperty("__DUMMY__"); PropertyDataCellMap = serializedObject.FindProperty("DataCellMap"); PropertyDataAnimation = serializedObject.FindProperty("DataAnimation"); PropertyTableMaterial = serializedObject.FindProperty("TableMaterial"); PropertyHideForce = serializedObject.FindProperty("FlagHideForce"); PropertyCountTrack = serializedObject.FindProperty("LimitTrack"); PropertyInformationPlay = serializedObject.FindProperty("TableInformationPlay"); }
// アニメーション開始 private void AnimationStart() { Script_SpriteStudio6_Root scriptRoot = null; // SpriteStudio Anime を操作するためのクラス int listLength = AnimationList.Length; // すでにアニメーション生成済 or リソース設定無い場合はreturn if (m_goCharacter != null || listLength < 1) { return; } // 再生するリソース名をリストから取得して再生する Object resourceObject = AnimationList[0]; if (resourceObject != null) { // アニメーションを実体化 m_goCharacter = Instantiate(resourceObject, Vector3.zero, Quaternion.identity) as GameObject; if (m_goCharacter != null) { scriptRoot = Script_SpriteStudio6_Root.Parts.RootGet(m_goCharacter); if (scriptRoot != null) { // 座標設定するためのGameObject作成 m_goCharPos = new GameObject(); if (m_goCharPos == null) { // 作成できないケース対応 Destroy(m_goCharacter); m_goCharacter = null; } else { // Object名変更 m_goCharPos.name = "Comipo"; // 座標設定 m_goCharacter.transform.parent = m_goCharPos.transform; // 自分の子に移動して座標を設定 m_goCharPos.transform.parent = this.transform; m_goCharPos.transform.localPosition = m_vecCharacterPos; m_goCharPos.transform.localRotation = Quaternion.identity; m_goCharPos.transform.localScale = m_vecCharacterScale; //アニメーション再生 AnimationChange(AnimationPattern.Wait); } } } } }
/* ********************************************************* */ //! Set Source animation (for Animation-Object) /*! * @param instanceOriginal * Source Animation-Object * * @retval Return-Value * true == Success<br> * false == Failure (Error) * * Set the Animation-Object as replicate source. */ public bool OriginalSet(Script_SpriteStudio6_Root instanceOriginal) { OriginalCleanUp(); /* Mesh-Control Components Correct */ if (false == ComponentSetMesh(instanceOriginal.gameObject)) { return(false); } DrawUpdate = DrawUpdateAnimation; InstanceRootOriginal = instanceOriginal; return(true); }
// アニメーション開始 private void StartAnimation() { // 設定されたプレハブアニメーションの数 int listLength = AnimationList.Length; // すでにアニメーション生成済 or リソース設定が無い場合はreturn if (scriptRoot != null || listLength < 1) { return; } // 再生するリソース名をリストから取得して再生する Object resourceObject = AnimationList[0]; if (resourceObject != null) { // アニメーションを実体化 var characterGameObject = Instantiate(resourceObject, Vector3.zero, Quaternion.identity) as GameObject; if (characterGameObject != null) { scriptRoot = Script_SpriteStudio6_Root.Parts.RootGet(characterGameObject); if (scriptRoot != null) { // 座標設定するためのGameObject作成 var characterRoot = new GameObject("Lily"); if (characterRoot == null) { // 作成できないケース対応 Destroy(characterGameObject); scriptRoot = null; } else { // 座標設定 characterGameObject.transform.SetParent(characterRoot.transform); // 自分の子に移動して座標を設定 characterRoot.transform.SetParent(transform); characterRoot.transform.localPosition = positionOffset; characterRoot.transform.localRotation = Quaternion.identity; characterRoot.transform.localScale = characterScale; //アニメーション再生 ChangeAnimation(AnimationPattern.Wait); } } } } }
// void Update() // { // } void LateUpdate() { if (null == InstanceRootParent) { #if EXPERIMENT_FOR_CAMERA if (null == ArgumentShareEntire) { ArgumentShareEntire = new ArgumentContainer(); } ArgumentShareEntire.CleanUp(); #endif /* MEMO: Execute only at the "Highest Parent(not under anyone's control)"-Root part. */ /* "Child"-Root parts' "LateUpdatesMain" are called from Parent's internal processing. */ if (true == RendererBootUpDraw(false)) { Matrix4x4 matrixInverseMeshRenderer = Matrix4x4.identity; float timeElapsed = FunctionExecTimeElapse(this); #if UNITY_EDITOR /* MEMO: Since time may pass even when not "Play Mode", prevents it. */ if (false == EditorApplication.isPlaying) { timeElapsed = 0.0f; } #endif LateUpdateMain(timeElapsed, false, Library_SpriteStudio6.KindMasking.FOLLOW_DATA, ref matrixInverseMeshRenderer, true, FlagPlanarization ); } } #if EXPERIMENT_FOR_CAMERA else { if (null == ArgumentShareEntire) { /* MEMO: Child animations share highest-parent's ArgumentContainer. */ Script_SpriteStudio6_Root instanceRootParentHighest = RootGetHighest(); if (null != instanceRootParentHighest) { ArgumentShareEntire = instanceRootParentHighest.ArgumentShareEntire; } } } #endif }
private static Script_SpriteStudio6_Root RootGetMain(GameObject gameObject) { Script_SpriteStudio6_Root scriptRoot = null; scriptRoot = gameObject.GetComponent <Script_SpriteStudio6_Root>(); if (null != scriptRoot) { /* Has Root-Parts */ if (null == scriptRoot.InstanceRootParent) { /* has no Parent */ return(scriptRoot); } } return(null); }
void Start() { if (null != GameObjectWatching) { ScriptRootWatching = Script_SpriteStudio6_Root.Parts.RootGet(GameObjectWatching); if (null == ScriptRootWatching) { /* Error */ return; } /* MEMO: If you want animation to elapse special time for application's circumstances, */ /* you can set a function to manage time passage. */ /* MEMO: When set to null, the default(Time.deltaTime) is used. */ ScriptRootWatching.FunctionTimeElapse = FunctionTimeElapse; } }
private void FunctionPlayEndTrackBody(Script_SpriteStudio6_Root scriptRoot, int indexTrackPlay, int indexTrackSlave, int indexAnimation, int indexAnimationSlave ) { /* MEMO: Same function is called when transition end and track play-end. */ /* As method to distinguish them, at the end of the transition, */ /* "indexTrackSlave" is set to "transition track index" and "indexAnimationSlave" is set to "destination animation index". */ /* (In case of playback end of track, both are set to -1) */ /* MEMO: When "track play end" and "transition end" occur simultaneously, callbacks will be execute in following order. */ /* 1. Transition end */ /* 2. Track play end */ /* MEMO: Recommend not to change animation playing state in TrackPlayEnd callback processing function. */ }
/* ----------------------------------------------- MonoBehaviour-Functions */ #region MonoBehaviour-Functions // void Awake() // { // } void Start() { if (null != PrefabAnimation) { GameObject instanceGameObject = Library_SpriteStudio6.Utility.Asset.PrefabInstantiate((GameObject)PrefabAnimation, null, gameObject, false); if (null != instanceGameObject) { /* Instantiate Under-Control Prefab */ Script_SpriteStudio6_Root instanceScriptRoot = instanceGameObject.GetComponent <Script_SpriteStudio6_Root>(); if (null != instanceScriptRoot) { instanceScriptRoot.InstanceGameObjectControl = gameObject; } } } }
/* ----------------------------------------------- Functions */ #region Functions private void OnEnable() { InstanceRoot = (Script_SpriteStudio6_Root)target; serializedObject.FindProperty("__DUMMY__"); PropertyDataCellMap = serializedObject.FindProperty("DataCellMap"); PropertyDataAnimation = serializedObject.FindProperty("DataAnimation"); PropertyHolderAsset = serializedObject.FindProperty("HolderAsset"); PropertyHideForce = serializedObject.FindProperty("FlagHideForce"); PropertyColliderInterlockHideForce = serializedObject.FindProperty("FlagColliderInterlockHideForce"); PropertyFlagPlanarization = serializedObject.FindProperty("FlagPlanarization"); PropertyOrderInLayer = serializedObject.FindProperty("OrderInLayer"); PropertyCountTrack = serializedObject.FindProperty("LimitTrack"); PropertyInformationPlay = serializedObject.FindProperty("TableInformationPlay"); }
/* ******************************************************** */ //! Change "Instance"'s Animation (by name) /*! * @param idParts * Parts-ID ("Instance"-part) * @param nameAnimation * New "Instance"'s animation-name<br> * "" or null == Change only "ignoreAttribute" * @param ignoreAttribute * NON == Restart animation when new "Instance" attribute deecoded<br> * NOW_ANIMATION == Ignore "Instance" attribute until new animation starts playing<br> * PERMANENT == Continue Ignoring "Instance" attribute even if new animation starts playing * @param flagStartImmediate * true == Animation is started immediate<br> * false == Start playing according to "Instance" attribute * @param timesPlay * 0 == Infinite-looping<br> * 1 == Not looping<br> * 2 <= Number of Plays * @param rateTime * Coefficient of time-passage of new animation.<br> * Minus Value is given, Animation is played backwards. * @param style * Library_SpriteStudio6.KindStylePlay.NOMAL == Animation is played One-Way.<br> * Library_SpriteStudio6.KindStylePlay.PINGPONG == Animation is played round-trip. * @param labelRangeStart * Label name to start playing animation.<br> * "" or "_start" == Top frame of Animation ("_start" is reserved label-name) * @param frameRangeOffsetStart * Offset frame from labelRangeStart<br> * Start frame of animation play range is "labelRangeStart + frameRangeOffsetStart". * @param labelRangeEnd * Label-name of the terminal in animation.<br> * "" or "_end" == Last frame of Animation ("_end" is reserved label-name) * @param frameRangeOffsetEnd * Offset frame from labelRangeStart<br> * End frame of animation play range is "labelRangeEnd + frameRangeOffsetEnd". * @retval Return-Value * true == Success<br> * false == Failure (Error) * * Change "Instance"'s animation controled by part.<br> * <br> * To change "Instance"'s animation, use this function without calling "Instance"'s "Script_SpriteStudio6_Root.AnimationPlay".<br> * (Cause inconsistency with control from "Instance" part)<br> * <br> * As a general rule, no designation to "Do not change playing parameters" like "AnimationPlay".<br> * The only exception is changing attribute-ignore setting(ignoreAttribute) without changing the animation.<br> * When set null or "" to "nameAnimation", change only attribute-ignore setting.<br> * (The argument omission after "flagStartImmediate" is written to change only attribute-ignore setting)<br> * <br> * When "nameAnimation" is set normally animation name...<br> * If "flagStartImmediate" is set to true, "Instance"'s animation will be played immediately.<br> * In the case, "Instance" play behaves the same as when "Independent of time" is checked in the "Instance" attribute on SpriteStudio6.<br> * Conversely, If "flagStartImmediate" is set to false, forcefully wait for next data of "Instance" attribute and start playing at decoding new data. */ public bool AnimationChangeInstance(int idParts, string nameAnimation, Library_SpriteStudio6.KindIgnoreAttribute ignoreAttribute, bool flagStartImmediate = false, int timesPlay = 1, float rateTime = 1.0f, Library_SpriteStudio6.KindStylePlay style = Library_SpriteStudio6.KindStylePlay.NORMAL, string labelRangeStart = null, int frameRangeOffsetStart = 0, string labelRangeEnd = null, int frameRangeOffsetEnd = 0 ) { Script_SpriteStudio6_Root scriptRootInstance = InstanceGet(idParts); if (null == scriptRootInstance) { return(false); } int indexAnimation = -1; if (false == string.IsNullOrEmpty(nameAnimation)) { indexAnimation = scriptRootInstance.IndexGetAnimation(nameAnimation); if (0 > indexAnimation) { return(false); } } return(AnimationChangeInstanceMain(ref TableControlParts[idParts], scriptRootInstance, indexAnimation, ignoreAttribute, flagStartImmediate, timesPlay, rateTime, style, labelRangeStart, frameRangeOffsetStart, labelRangeEnd, frameRangeOffsetEnd ) ); }
private void DrawUpdateSequence() { /* Mesh-Control Components Correct */ Script_SpriteStudio6_Root scriptRoot = InstanceSequenceOriginal.ScriptRoot; if (null == scriptRoot) { return; } if (false == ComponentSetMesh(scriptRoot.gameObject)) { return; } InstanceMeshFilter.sharedMesh = InstanceMeshFilterOriginal.sharedMesh; InstanceMeshRenderer.sharedMaterials = InstanceMeshRendererOriginal.sharedMaterials; DrawUpdateRenderer(scriptRoot.TableMaterialPropertyBlock); }
/* ----------------------------------------------- Functions */ #region Functions /* ******************************************************** */ //! Get Root-Parts /*! * @param gameObject * GameObject of starting search * @param flagApplySelf * true == Include "gameObject" as check target<br> * false == exclude "gameObject"<br> * default: true * @retval Return-Value * Instance of "Script_SpriteStudio6_Root"<br> * null == Not-Found / Failure * * Get component "Script_SpriteStudio6_Root" by examining "gameObject" and direct-children.<br> * <br> * This function returns "Script_SpriteStudio6_Root" first found.<br> * However, it is not necessarily in shallowest GameObject-hierarchy.<br> * (Although guarantee up to direct-children, can not guarantee if farther than direct-children)<br> */ public static Script_SpriteStudio6_Root RootGet(GameObject gameObject, bool flagApplySelf = true) { Script_SpriteStudio6_Root scriptRoot = null; /* Check Origin */ if (true == flagApplySelf) { scriptRoot = RootGetMain(gameObject); if (null != scriptRoot) { return(scriptRoot); } } /* Check Direct-Children */ /* MEMO: Processing is wastefull, but check direct-children first so that make to find in closely-relation as much as possible. */ int countChild = gameObject.transform.childCount; Transform transformChild = null; for (int i = 0; i < countChild; i++) { transformChild = gameObject.transform.GetChild(i); scriptRoot = RootGetMain(transformChild.gameObject); if (null != scriptRoot) { return(scriptRoot); } } /* Check Children */ for (int i = 0; i < countChild; i++) { transformChild = gameObject.transform.GetChild(i); scriptRoot = RootGet(transformChild.gameObject, false); if (null != scriptRoot) { /* Has Root-Parts */ return(scriptRoot); } } return(null); }
// アニメーションが再生中か停止中(エラー含)か取得します private bool IsAnimationPlay() { bool ret = false; Script_SpriteStudio6_Root scriptRoot = null; // SpriteStudio Anime を操作するためのクラス if (m_goCharacter != null) { scriptRoot = Script_SpriteStudio6_Root.Parts.RootGet(m_goCharacter); if (scriptRoot != null) { // 再生回数を取得して、プレイ終了かを判断します int Remain = scriptRoot.PlayTimesGetRemain(0); if (Remain >= 0) { ret = true; } } } return(ret); }
private void FunctionCallBackUserData( Script_SpriteStudio6_Root scriptRoot, string nameParts, int indexParts, int indexAnimation, int frameDecode, int frameKeyData, ref Library_SpriteStudio6.Data.Animation.Attribute.UserData userData, bool flagWayBack ) { /* MEMO: "UserData"-callback are execute during animation updating process. */ /* Therefore, do not change playing-status within "UserData"- callback processing function. */ /* As much as possible, please caching values for the next operation */ /* and perform processing with the next "MonoBehaviour.Update()". */ /* MEMO: "UserData"-callback is processed in the order of "1. part" and "2. frame". */ /* When many frames are skipped, please pay attention to the order of callback. */ /* (In parts by parts, Will be called back according to the order of the played-frames.) */ /* MEMO: To be honest, it is not recommended to place "UserData" in many parts. */ /* As much as possible recommend that you put "UserData" together in 1 part. (Can also get good performance) */ /* MEMO: Do not place "UserData" in "Instance" animations. */ /* (Will be ignored) */ /* MEMO: "userData" is a shallow-copy of UserData in animation's master(original)-data. */ /* Therefore, overwriting "userData" risks affecting animations that use same master-data, so do not overwrite in principle. */ /* (Since "userData.Text" is a "string", pay particular attention) */ /* MEMO: "userData" is original-data's shallow-copy, so can not guarantee that same "reference". */ /* Therefore, when judging whether same "UserData", judge by compare "scriptRoot","indexParts", */ /* "indexAnimation" and "frameKeyData". */ /* MEMO: "flagWayBack" becomes true when direction-play is "way-back" during ping-pong(round-trip) playing. */ /* Always false during normal(one-way) playing. */ /* MEMO: If you know exactly what values are stored in the "UserData", */ /* you can directly retrieve values from "NumberInt", "Rectangle", "Coordinate" or "Text". */ /* But usually "IsNumber", "IsRectangle"," IsCoordinate" or "IsText" are used to check values are stored. */ if((true == userData.IsText) && ("ColorChange" == userData.Text)) { IndexColor++; IndexColor %= TableColorFont.Length; } }
/* ******************************************************** */ //! Change "Instance" /*! * @param idParts * Parts-ID ("Instance"-part) * @param source * Source of new "Instance" (mainly "Prefab")<br> * null == Revert to initial data * @retval Return-Value * true == Success<br> * false == Failure (Error) * * Set(Change) "Instance" controled by part.<br> * <br> * Be careful when using this function.<br> * <br> * This function is heavey load and consumes "Managed-Heap".<br> * Because execute following process, basically.<br> * <br> * - Destroy old "Instance"<br> * - Instantiate "source"(New "Instance")<br> * - Rebuild parent-animation's drawing-meshes buffer<br> * <br> * Also, when set new "Instance", animation to be played is set animation of index 0.<br> * (When revert, set animation-index that original-data has)<br> * <br> * Depending on animation data of the newly set "Instance", may not playing-result as expected.<br> * (Pay attention that how to be controlled from the "Instance"-part)<br> * <br> * Caution that not to cause infinite-nesting by replacing.<br> */ public bool InstanceChange(int idParts, GameObject source) { if ((null == DataAnimation) || (null == TableControlParts)) { return(false); } if ((0 > idParts) || (TableControlParts.Length <= idParts)) { return(false); } if (Library_SpriteStudio6.Data.Parts.Animation.KindFeature.INSTANCE != DataAnimation.TableParts[idParts].Feature) { return(false); } Script_SpriteStudio6_Root scriptRootHighest = RootGetHighest(); if (null == scriptRootHighest) { scriptRootHighest = this; } /* Renew "Instance" */ if (false == TableControlParts[idParts].BootUpInstance(this, idParts, true, source)) { return(false); } /* Rebuild Hiest-Root's Draw buffes */ if (false == scriptRootHighest.ClusterBootUpDraw()) { return(false); } return(true); }
/* ----------------------------------------------- Functions */ #region Functions private float FunctionTimeElapse(Script_SpriteStudio6_Root scriptRoot) { /* MEMO: In this case, the set time is allowed to elapse only when the key is pressed. */ float time = 0.0f; if (true == FlagKeyDown) { switch (TimePassage) { case KindTimePassage.FPS_60: time = 1.0f / 60.0f; break; case KindTimePassage.FPS_30: time = 1.0f / 30.0f; break; case KindTimePassage.ELAPSED: time = Time.deltaTime; break; } } return(time); }
/* ----------------------------------------------- MonoBehaviour-Functions */ #region MonoBehaviour-Functions void Start() { /* Get Animation Control Script-Component */ GameObject gameObjectBase = GameObjectRoot; if (null == gameObjectBase) { gameObjectBase = gameObject; } ScriptRoot = Script_SpriteStudio6_Root.Parts.RootGet(gameObjectBase); if (null == ScriptRoot) { /* Error */ return; } /* Cache Animation index */ for (int i = 0; i < KindAnimationTERMINATOR; i++) { TableIndexAnimation[i] = ScriptRoot.IndexGetAnimation(TableNameAnimation[i]); } /* Initialize Complete */ FlagInitialized = true; }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.LabelField("[SpriteStudio6 Replicate Animation]"); int levelIndent = 0; bool flagUpdate = false; EditorGUI.indentLevel = levelIndent + 1; /* Original Data */ Script_SpriteStudio6_Root instanceRoot = PropertyRootOriginal.objectReferenceValue as Script_SpriteStudio6_Root; Script_SpriteStudio6_RootEffect instanceRootEffect = PropertyRootEffectOriginal.objectReferenceValue as Script_SpriteStudio6_RootEffect; Script_SpriteStudio6_Sequence instanceSequence = PropertySequenceOriginal.objectReferenceValue as Script_SpriteStudio6_Sequence; UnityEngine.GameObject gameObjectNow = null; if (null != instanceRoot) { gameObjectNow = instanceRoot.gameObject; } else if (null != instanceRootEffect) { gameObjectNow = instanceRootEffect.gameObject; } else if (null != instanceSequence) { gameObjectNow = instanceSequence.gameObject; } EditorGUILayout.Space(); UnityEngine.GameObject gameObjectNew = EditorGUILayout.ObjectField("Original Animation", gameObjectNow, typeof(UnityEngine.GameObject), true) as UnityEngine.GameObject; EditorGUILayout.LabelField("GameObject that has following components"); EditorGUILayout.LabelField(" can be set to \"Original Animation\"."); EditorGUILayout.LabelField("- Script_SpriteStudio6_Root"); // EditorGUILayout.LabelField("- Script_SpriteStudio6_RootEffect"); EditorGUILayout.LabelField("- Script_SpriteStudio6_Sequence"); EditorGUILayout.Space(); if (gameObjectNow != gameObjectNew) { Script_SpriteStudio6_Root instanceRootNew = null; Script_SpriteStudio6_RootEffect instanceRootEffectNew = null; Script_SpriteStudio6_Sequence instanceSequenceNew = null; if (null == gameObjectNew) { InstanceReplicate.Stop(); // instanceRootNew = null; // instanceRootEffectNew = null; // instanceSequenceNew = null; } else { instanceRootNew = gameObjectNew.GetComponent <Script_SpriteStudio6_Root>(); instanceRootEffectNew = gameObjectNew.GetComponent <Script_SpriteStudio6_RootEffect>(); instanceSequenceNew = gameObjectNew.GetComponent <Script_SpriteStudio6_Sequence>(); if (null != instanceRootNew) { InstanceReplicate.OriginalSet(instanceRootNew); // instanceRootNew = null; instanceRootEffectNew = null; instanceSequenceNew = null; } else if (null != instanceRootEffectNew) { InstanceReplicate.OriginalSet(instanceRootEffectNew); instanceRootNew = null; // instanceRootEffectNew = null; instanceSequenceNew = null; } else if (null != instanceSequenceNew) { InstanceReplicate.OriginalSet(instanceSequenceNew); instanceRootNew = null; instanceRootEffectNew = null; // instanceSequenceNew = null; } // else // { // PropertyRootOriginal.objectReferenceValue = null; // PropertyRootEffectOriginal.objectReferenceValue = null; // PropertySequenceOriginal.objectReferenceValue = null; // } } instanceRoot = instanceRootNew; instanceRootEffect = instanceRootEffectNew; instanceSequence = instanceSequenceNew; flagUpdate |= true; } /* Hide */ PropertyHideForce.boolValue = EditorGUILayout.Toggle("Hide Force", PropertyHideForce.boolValue); // EditorGUILayout.Space(); EditorGUI.indentLevel = levelIndent; if (true == flagUpdate) { PropertyRootOriginal.objectReferenceValue = instanceRoot; PropertyRootEffectOriginal.objectReferenceValue = instanceRootEffect; PropertySequenceOriginal.objectReferenceValue = instanceSequence; } serializedObject.ApplyModifiedProperties(); }
private bool AnimationChangeInstanceMain(ref Library_SpriteStudio6.Control.Animation.Parts controlParts, Script_SpriteStudio6_Root scriptRootInstance, int indexAnimation, Library_SpriteStudio6.KindIgnoreAttribute ignoreAttribute, bool flagStartImmediate, int timesPlay, float rateTime, Library_SpriteStudio6.KindStylePlay style, string labelRangeStart, int frameRangeOffsetStart, string labelRangeEnd, int frameRangeOffsetEnd ) { if (null == TableControlTrack) { return(false); } if (0 > timesPlay) { return(false); } if (true == float.IsNaN(rateTime)) { return(false); } Library_SpriteStudio6.Data.Animation.Attribute.Instance dataInstance = new Library_SpriteStudio6.Data.Animation.Attribute.Instance(); dataInstance.Flags = Library_SpriteStudio6.Data.Animation.Attribute.Instance.FlagBit.CLEAR; switch (style) { case Library_SpriteStudio6.KindStylePlay.NO_CHANGE: return(false); case Library_SpriteStudio6.KindStylePlay.NORMAL: break; case Library_SpriteStudio6.KindStylePlay.PINGPONG: dataInstance.Flags |= Library_SpriteStudio6.Data.Animation.Attribute.Instance.FlagBit.PINGPONG; break; } controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_EXCEPT_NEXTDATA; switch (ignoreAttribute) { case Library_SpriteStudio6.KindIgnoreAttribute.NON: controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_ATTRIBUTE; controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_NEWANIMATION; dataInstance.Flags &= ~Library_SpriteStudio6.Data.Animation.Attribute.Instance.FlagBit.INDEPENDENT; break; case Library_SpriteStudio6.KindIgnoreAttribute.NOW_ANIMATION: controlParts.Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_ATTRIBUTE; controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_NEWANIMATION; dataInstance.Flags |= Library_SpriteStudio6.Data.Animation.Attribute.Instance.FlagBit.INDEPENDENT; break; case Library_SpriteStudio6.KindIgnoreAttribute.PERMANENT: controlParts.Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_ATTRIBUTE; controlParts.Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_NEWANIMATION; dataInstance.Flags |= Library_SpriteStudio6.Data.Animation.Attribute.Instance.FlagBit.INDEPENDENT; break; } dataInstance.PlayCount = timesPlay; dataInstance.RateTime = rateTime; dataInstance.LabelStart = labelRangeStart; dataInstance.OffsetStart = frameRangeOffsetStart; dataInstance.LabelEnd = labelRangeEnd; dataInstance.OffsetEnd = frameRangeOffsetEnd; if (false == flagStartImmediate) { controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_EXCEPT_NEXTDATA; } else { controlParts.Status |= Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_IGNORE_EXCEPT_NEXTDATA; /* MEMO: When does not start immediately, necessary to always decode next data, so turn off "Independent time" status. */ controlParts.Status &= ~Library_SpriteStudio6.Control.Animation.Parts.FlagBitStatus.INSTANCE_PLAY_INDEPENDENT; controlParts.IndexAnimationUnderControl = indexAnimation; controlParts.DataInstance = dataInstance; int indexTrack = controlParts.IndexControlTrack; if (0 <= indexTrack) { float rateTimeControlTrack = TableControlTrack[indexTrack].RateTime * ((true == TableControlTrack[indexTrack].StatusIsPlayingReverse) ? -1.0f : 1.0f); return(controlParts.InstancePlayStart(this, rateTimeControlTrack)); } } return(true); }