/* ******************************************************** */ //! Get Root-Parts /*! * @param InstanceOrigin * GameObject to start the search * @retval Return-Value * Instance of "Script_SpriteStudio_PartsRoot"<br> * null == Not-Found / Failure * * Get "Script_SpriteStudio_PartsRoot" by examining "InstanceOrigin" and direct children. */ public static Script_SpriteStudio_PartsRoot InstanceGetRoot(GameObject InstanceOrigin) { Script_SpriteStudio_PartsRoot ScriptRoot = null; /* Check Origin */ ScriptRoot = InstanceOrigin.GetComponent <Script_SpriteStudio_PartsRoot>(); if (null != ScriptRoot) { /* Has Root-Parts */ return(ScriptRoot); } /* Check Children */ int CountChild = InstanceOrigin.transform.childCount; Transform InstanceTransformChild = null; for (int i = 0; i < CountChild; i++) { InstanceTransformChild = InstanceOrigin.transform.GetChild(i); ScriptRoot = InstanceTransformChild.gameObject.GetComponent <Script_SpriteStudio_PartsRoot>(); if (null != ScriptRoot) { /* Has Root-Parts */ return(ScriptRoot); } } /* Not-Found */ return(null); }
// Update is called once per frame void Update() { //spritestudioルートクラスの取得 //spriteStudioRootを使用してアニメーションの制御を行います。 if(null == spriteStudioRoot) { int Count = transform.childCount; Transform InstanceTransformChild = null; for(int i=0; i<Count; i++) { InstanceTransformChild = transform.GetChild(i); spriteStudioRoot = InstanceTransformChild.gameObject.GetComponent<Script_SpriteStudio_PartsRoot>(); if(null != spriteStudioRoot) { //初期化 //アニメーションの終了割り込みを設定 spriteStudioRoot.FunctionPlayEnd = AnimEnd; //アニメーションの再生 spriteStudioRoot.AnimationPlay(0, 1, 0, 1.0f); break; } } } Vector2 camera = Camera2DControl.GetCamera(); Vector2 tmp = new Vector2(pos.x - camera.x, pos.y - camera.y); transform.position = tmp; }
/* ******************************************************** */ //! Draw-List Clear /*! * @param InstanceGameObjectSub * Instance-Data's Root-Parts * @retval Return-Value * (None) * * Don't use this function. <br> * (This function is for the Link-Prefab's scripts in same GameObject.) */ internal void LinkSetPartsInstance(GameObject InstanceGameObjectSub) { InstanceGameObjectPartsRootSub = InstanceGameObjectSub; scriptPartsRootSub = InstanceGameObjectSub.GetComponent <Script_SpriteStudio_PartsRoot>(); scriptPartsRootSub.PartsRootOrigin = PartsRootGetOrigin(ScriptRoot); scriptPartsRootSub.NodeSetControl(null); }
void Start() { spriteStudioRoot = GetComponentInChildren <Script_SpriteStudio_PartsRoot>(); isKilled = false; scoreObj = GameObject.Find("Score"); scoreScr = scoreObj.GetComponent <Score>(); }
void Start() { spriteStudioRoot = GetComponentInChildren<Script_SpriteStudio_PartsRoot>(); isKilled = false; scoreObj = GameObject.Find("Score") ; scoreScr = scoreObj.GetComponent<Score>() ; }
internal void DrawEntryObject(Script_SpriteStudio_PartsRoot PartsRootDrawObject) { /* Boot-Check */ if (null == DrawEntryPartsRoot) { #if false /* MEMO: Non-Generic List-Class */ DrawEntryPartsRoot = new ArrayList(); DrawEntryPartsRoot.Clear(); #else DrawEntryPartsRoot = new List <InformationDrawObject>(); DrawEntryPartsRoot.Clear(); #endif } /* Get Priority */ Matrix4x4 MatrixWorld = PartsRootDrawObject.transform.localToWorldMatrix; Vector3 OriginWorld = MatrixWorld.MultiplyPoint3x4(Vector3.zero); /* Add Draw-Object (Not "Instance"-Object) */ InformationDrawObject DrawObjectNew = new InformationDrawObject(); DrawObjectNew.PartsRoot = PartsRootDrawObject; DrawObjectNew.Priority = OriginWorld.z; /* Sort & Add Object */ int Count = DrawEntryPartsRoot.Count; if (0 == Count) { /* First Object */ goto DrawEntryObject_Add; } InformationDrawObject DrawObject = null; int Index = 0; for (int i = 0; i < Count; i++) { #if false /* MEMO: Non-Generic List-Class */ DrawObject = DrawEntryPartsRoot[i] as InformationDrawObject; #else DrawObject = DrawEntryPartsRoot[i]; #endif if (DrawObject.Priority < DrawObjectNew.Priority) { goto DrawEntryObject_Insert; } Index++; } DrawEntryObject_Add :; DrawEntryPartsRoot.Add(DrawObjectNew); return; DrawEntryObject_Insert :; DrawEntryPartsRoot.Insert(Index, DrawObjectNew); return; }
private Script_SpriteStudio_PartsRoot PartsRootGetOrigin(Script_SpriteStudio_PartsRoot Start) { Script_SpriteStudio_PartsRoot PartsRootNow = Start; while (null != PartsRootNow.PartsRootOrigin) { PartsRootNow = PartsRootNow.PartsRootOrigin; } return(PartsRootNow); }
public void PrefabLinkInstantiate() { if (null != LinkPrefab) { /* MEMO: "Instance"-Parts has C#-Script ("ScriptPartsInstance" is not null) */ Script_SpriteStudio_PartsInstance ScriptPartsInstance = gameObject.GetComponent <Script_SpriteStudio_PartsInstance>(); GameObject PrefabRoot = (GameObject)LinkPrefab; GameObject Instance = null; Transform TransformChild = gameObject.transform.Find(PrefabRoot.name); if (null == TransformChild) { /* Instantiate Prefab */ #if UNITY_EDITOR Instance = (GameObject)PrefabUtility.InstantiatePrefab(LinkPrefab); #else Instance = (GameObject)Instantiate(LinkPrefab); #endif if (null != Instance) { /* Make "Parent-Child"-Relation */ Instance.gameObject.transform.parent = gameObject.transform; Instance.gameObject.transform.localPosition = Vector3.zero; Instance.gameObject.transform.localEulerAngles = Vector3.zero; Instance.gameObject.transform.localScale = Vector3.one; } #if UNITY_EDITOR /* Break Prefab Instance */ PrefabUtility.DisconnectPrefabInstance(gameObject); #endif } else { Instance = TransformChild.gameObject; } if (null != ScriptPartsInstance) { /* "Instance"-Parts */ ScriptPartsInstance.LinkSetPartsInstance(Instance); } else { /* Control-Node */ Script_SpriteStudio_PartsRoot ScriptRoot = Instance.GetComponent <Script_SpriteStudio_PartsRoot>(); if (null != ScriptRoot) { ScriptRoot.NodeSetControl(gameObject); } } } }
/* ******************************************************** */ //! Change playing the Instance-Object's animation /*! * @param InstancePrefab * New Prefab<br> * @retval Return-Value * true == Success <br> * false == Failure (Error) * * The playing of Instance-Object's Prefab changes. <br> * It is necessary for the New Prefab to have the Prefab which is already set and compatibility of a data structure.<br> * <br> * Caution!: This Function is in experimentally inplement. */ public bool PrefabChangeInstance(GameObject PrefabNew) { GameObject Instance = null; #if UNITY_EDITOR DestroyImmediate(InstanceGameObjectPartsRootSub); Instance = (GameObject)PrefabUtility.InstantiatePrefab(PrefabNew); #else Destroy(InstanceGameObjectPartsRootSub); Instance = (GameObject)Instantiate(PrefabNew); #endif InstanceGameObjectPartsRootSub = null; scriptPartsRootSub = null; LinkSetPartsInstance(Instance); return(true); }
public static Script_SpriteStudio_PartsRoot SpriteStudioDataGetRoot(GameObject GameObjectParts) { GameObject GameObjectParent = GameObjectParts.transform.parent.gameObject; Script_SpriteStudio_PartsRoot ComponentScript_PartsRoot = null; while (null == ComponentScript_PartsRoot) { if (null == GameObjectParent) { break; } ComponentScript_PartsRoot = GameObjectParent.GetComponent <Script_SpriteStudio_PartsRoot>(); if (null != ComponentScript_PartsRoot) { return(ComponentScript_PartsRoot); } GameObjectParent = GameObjectParent.transform.parent.gameObject; } return(null); }
public static AnimationData SpriteStudioDataGetParent(GameObject GameObjectParts) { GameObject GameObjectParent = GameObjectParts.transform.parent.gameObject; AnimationData DataSpriteStudio = null; Script_SpriteStudio_Triangle2 ComponentScript_Triangle2 = GameObjectParent.GetComponent <Script_SpriteStudio_Triangle2>(); if (null != ComponentScript_Triangle2) { DataSpriteStudio = ComponentScript_Triangle2.SpriteStudioData; } else { Script_SpriteStudio_Triangle4 ComponentScript_Triangle4 = GameObjectParent.GetComponent <Script_SpriteStudio_Triangle4>(); if (null != ComponentScript_Triangle4) { DataSpriteStudio = ComponentScript_Triangle4.SpriteStudioData; } else { Script_SpriteStudio_PartsNULL ComponentScript_PartsNULL = GameObjectParent.GetComponent <Script_SpriteStudio_PartsNULL>(); if (null != ComponentScript_PartsNULL) { DataSpriteStudio = ComponentScript_PartsNULL.SpriteStudioData; } else { Script_SpriteStudio_PartsRoot ComponentScript_PartsRoot = GameObjectParts.GetComponent <Script_SpriteStudio_PartsRoot>(); if (null != ComponentScript_PartsRoot) { DataSpriteStudio = ComponentScript_PartsRoot.SpriteStudioData; } } } } return(DataSpriteStudio); }
static void hoge(Script_SpriteStudio_PartsRoot root) { root.FunctionPlayEnd = null; }
public void UpdateUserData(int FrameNo, GameObject GameObjectNow, Script_SpriteStudio_PartsRoot ScriptRoot) { if (0 < AnimationDataUser.Length) { if (0 != (ScriptRoot.Status & Script_SpriteStudio_PartsRoot.BitStatus.DECODE_USERDATA)) { int FrameNoPrevious = (-1 == ScriptRoot.FrameNoPrevious) ? FrameNo : ScriptRoot.FrameNoPrevious; KeyFrame.ValueUser UserData = null; /* Decoding Skipped Frame */ if (0.0f > ScriptRoot.RateTimeAnimation) { /* backwards */ if (FrameNo > FrameNoPrevious) { /* Loop */ for (int i = (FrameNoPrevious - 1); i >= ScriptRoot.FrameNoStart; i--) { UserData = AnimationDataUser[i]; if (Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } for (int i = ScriptRoot.FrameNoEnd; i > FrameNo; i--) { UserData = AnimationDataUser[i]; if (Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } } else { /* Normal */ for (int i = (FrameNoPrevious - 1); i > FrameNo; i--) { UserData = AnimationDataUser[i]; if (Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } } } else { /* foward */ if (FrameNo < FrameNoPrevious) { /* Loop */ for (int i = (FrameNoPrevious + 1); i <= ScriptRoot.FrameNoEnd; i++) { UserData = AnimationDataUser[i]; if (Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } for (int i = ScriptRoot.FrameNoStart; i < FrameNo; i++) { UserData = AnimationDataUser[i]; if (Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } } else { /* Normal */ for (int i = (FrameNoPrevious + 1); i < FrameNo; i++) { UserData = AnimationDataUser[i]; if (Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } } } /* Decoding Just-Now Frame */ UserData = AnimationDataUser[FrameNo]; if (Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, FrameNo, UserData); } } } }
public void UpdateMesh(Mesh MeshNow, int FrameNo, Script_SpriteStudio_PartsRoot ScriptRoot) { Matrix4x4 MatrixTexture = Matrix4x4.identity; Vector2 SizeTexture = Vector2.one; Vector2 RateScaleTexture = Vector2.one; Vector2 PivotTexture = Vector2.zero; Vector2 RateScaleMesh = Vector2.one; Vector2 PivotMesh = Vector2.zero; Rect RectCell = Rect.MinMaxRect(0.0f, 0.0f, 64.0f, 64.0f); int VertexCollectionIndexTableNo = 0; /* Main-Texture Data Get */ Material MaterialNow = ScriptRoot.MaterialGet(AnimationDataCell[FrameNo].TextureNo, KindBlendTarget); if (null != MaterialNow) { Texture InstanceTexture = MaterialNow.mainTexture; SizeTexture.x = (float)InstanceTexture.width; SizeTexture.y = (float)InstanceTexture.height; } /* Cell-Data Get */ if (0 < AnimationDataCell.Length) { RectCell = AnimationDataCell[FrameNo].Rectangle; PivotTexture = new Vector2(RectCell.width * 0.5f, RectCell.height * 0.5f); PivotMesh = AnimationDataCell[FrameNo].Pivot; } /* Disolve Flipping & Texture-Scaling */ if (0 < AnimationDataFlags.Length) { RateScaleTexture.x = (true == AnimationDataFlags[FrameNo].IsTextureFlipX) ? -1.0f : 1.0f; RateScaleTexture.y = (true == AnimationDataFlags[FrameNo].IsTextureFlipY) ? -1.0f : 1.0f; if (true == AnimationDataFlags[FrameNo].IsFlipX) { RateScaleMesh.x = -1.0f; VertexCollectionIndexTableNo += 1; } else { RateScaleMesh.x = 1.0f; } if (true == AnimationDataFlags[FrameNo].IsFlipY) { RateScaleMesh.y = -1.0f; VertexCollectionIndexTableNo += 2; } else { RateScaleMesh.y = 1.0f; } } if (0 < AnimationDataTextureScale.Length) { RateScaleTexture.x *= AnimationDataTextureScale[FrameNo].x; RateScaleTexture.y *= AnimationDataTextureScale[FrameNo].y; } /* Calculate Matrix-Texture */ float Rotate = (0 < AnimationDataTextureRotate.Length) ? AnimationDataTextureRotate[FrameNo] : 0.0f; Vector2 TextureOffset = (0 < AnimationDataTextureTranslate.Length) ? AnimationDataTextureTranslate[FrameNo] : Vector2.zero; Vector3 Translation = new Vector3(((RectCell.xMin + PivotTexture.x) / SizeTexture.x) + TextureOffset.x, ((SizeTexture.y - (RectCell.yMin + PivotTexture.y)) / SizeTexture.y) - TextureOffset.y, 0.0f ); Vector3 Scaling = new Vector3((RectCell.width / SizeTexture.x) * RateScaleTexture.x, (RectCell.height / SizeTexture.y) * RateScaleTexture.y, 1.0f ); Quaternion Rotation = Quaternion.Euler(0.0f, 0.0f, Rotate); MatrixTexture = Matrix4x4.TRS(Translation, Rotation, Scaling); /* Set Vertex-Datas */ int CountVertexData = MeshNow.vertexCount; Vector2[] DataUV = new Vector2[CountVertexData]; Vector3 Coodinate = Vector3.zero; for (int i = 0; i < CountVertexData; i++) /* Texture-UV */ { /* Memo: "ArrayUVMappingUV0_Triangle4" of the data up to the "VertexNo.TERMINATOR2"-th elements are same as those of "ArrayUVMappingUV0_Triangle2". */ Coodinate = MatrixTexture.MultiplyPoint3x4(ArrayUVMappingUV0_Triangle4[i]); DataUV[i] = new Vector2(Coodinate.x, Coodinate.y); } MeshNow.uv = DataUV; float RateOpacity = (0 < AnimationDataOpacityRate.Length) ? AnimationDataOpacityRate[FrameNo] : 1.0f; Vector2[] DataUV2 = new Vector2[CountVertexData]; Color32[] DataColor32 = new Color32[CountVertexData]; if (0 < AnimationDataColorBlend.Length) /* Blending-Color & Opacity*/ { /* Animation-Data */ #if false for (int i = 0; i < CountVertexData; i++) { DataUV2[i] = new Vector2(AnimationDataColorBlend[FrameNo].RatePixelAlpha[i] * RateOpacity, (float)AnimationDataColorBlend[FrameNo].Operation + 0.01f /* "+0.01f" for Rounding-off-Error */ ); DataColor32[i] = AnimationDataColorBlend[FrameNo].VertexColor[i]; } #else if (Library_SpriteStudio.KindColorBound.NON != AnimationDataColorBlend[FrameNo].Bound) { for (int i = 0; i < CountVertexData; i++) { DataUV2[i] = new Vector2(AnimationDataColorBlend[FrameNo].RatePixelAlpha[i] * RateOpacity, (float)AnimationDataColorBlend[FrameNo].Operation + 0.01f /* "+0.01f" for Rounding-off-Error */ ); DataColor32[i] = AnimationDataColorBlend[FrameNo].VertexColor[i]; } } else { /* Default (Same as "No Datas" ) */ Color32 ColorDefault = Color.white; float OperationDefault = (float)KindColorOperation.NON + 0.01f; /* "+0.01f" for Rounding-off-Error */ for (int i = 0; i < CountVertexData; i++) { DataUV2[i] = new Vector2(RateOpacity, OperationDefault); DataColor32[i] = ColorDefault; } } #endif } else { /* Default (No Datas) */ Color32 ColorDefault = Color.white; float OperationDefault = (float)KindColorOperation.NON + 0.01f; /* "+0.01f" for Rounding-off-Error */ for (int i = 0; i < CountVertexData; i++) { DataUV2[i] = new Vector2(RateOpacity, OperationDefault); DataColor32[i] = ColorDefault; } } MeshNow.colors32 = DataColor32; MeshNow.uv2 = DataUV2; Vector3[] DataCoordinate = new Vector3[CountVertexData]; if ((int)VertexNo.TERMINATOR4 == CountVertexData) /* Vertex-Coordinate */ { /* 4-Triangles Mesh */ /* Get SpriteSize & Pivot */ SpriteRecalcSizeAndPivot(ref PivotMesh, ref RectCell, ref RateScaleMesh, FrameNo); /* Get Coordinates */ /* MEMO: No Check "AnimationDataVertexCorrection.Length", 'cause 4-Triangles-Mesh necessarily has "AnimationDataVertexCorrection" */ float Left = (-PivotMesh.x) * RateScaleMesh.x; float Right = (RectCell.width - PivotMesh.x) * RateScaleMesh.x; float Top = (-PivotMesh.y) * RateScaleMesh.y; float Bottom = (RectCell.height - PivotMesh.y) * RateScaleMesh.y; DataCoordinate[(int)VertexNo.LU] = new Vector3(Left + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.LU]].x, -Top + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.LU]].y, 0.0f ); DataCoordinate[(int)VertexNo.RU] = new Vector3(Right + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.RU]].x, -Top + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.RU]].y, 0.0f ); DataCoordinate[(int)VertexNo.RD] = new Vector3(Right + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.RD]].x, -Bottom + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.RD]].y, 0.0f ); DataCoordinate[(int)VertexNo.LD] = new Vector3(Left + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.LD]].x, -Bottom + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.LD]].y, 0.0f ); Vector3 CoordinateLURU = (DataCoordinate[(int)VertexNo.LU] + DataCoordinate[(int)VertexNo.RU]) * 0.5f; Vector3 CoordinateLULD = (DataCoordinate[(int)VertexNo.LU] + DataCoordinate[(int)VertexNo.LD]) * 0.5f; Vector3 CoordinateLDRD = (DataCoordinate[(int)VertexNo.LD] + DataCoordinate[(int)VertexNo.RD]) * 0.5f; Vector3 CoordinateRURD = (DataCoordinate[(int)VertexNo.RU] + DataCoordinate[(int)VertexNo.RD]) * 0.5f; CoordinateGetDiagonalIntersection(out DataCoordinate[(int)VertexNo.C], ref CoordinateLURU, ref CoordinateRURD, ref CoordinateLULD, ref CoordinateLDRD ); } else { /* 2-Triangles Mesh */ /* Get SpriteSize & Pivot */ SpriteRecalcSizeAndPivot(ref PivotMesh, ref RectCell, ref RateScaleMesh, FrameNo); /* Get Coordinates */ float Left = (-PivotMesh.x) * RateScaleMesh.x; float Right = (RectCell.width - PivotMesh.x) * RateScaleMesh.x; float Top = (-PivotMesh.y) * RateScaleMesh.y; float Bottom = (RectCell.height - PivotMesh.y) * RateScaleMesh.y; DataCoordinate[(int)VertexNo.LU] = new Vector3(Left, -Top, 0.0f); DataCoordinate[(int)VertexNo.RU] = new Vector3(Right, -Top, 0.0f); DataCoordinate[(int)VertexNo.RD] = new Vector3(Right, -Bottom, 0.0f); DataCoordinate[(int)VertexNo.LD] = new Vector3(Left, -Bottom, 0.0f); } MeshNow.vertices = DataCoordinate; }
public override void OnInspectorGUI() { Script_SpriteStudio_PartsRoot Data = (Script_SpriteStudio_PartsRoot)target; EditorGUILayout.LabelField("[SpriteStudio Parts-Root]"); int LevelIndent = 0; EditorGUILayout.Space(); FoldOutMaterialTable = EditorGUILayout.Foldout(FoldOutMaterialTable, "Based-Material Table"); if (true == FoldOutMaterialTable) { EditorGUI.indentLevel = LevelIndent + 1; if (null != Data.TableMaterial) { int CountShader = (int)(Library_SpriteStudio.KindColorOperation.TERMINATOR - 1); int Count = Data.TableMaterial.Length / CountShader; int MaterialNoTop = 0; Library_SpriteStudio.KindColorOperation MaterialTableNo = 0; string NameField = ""; for (int i = 0; i < Count; i++) { MaterialNoTop = i * (int)(Library_SpriteStudio.KindColorOperation.TERMINATOR - 1); EditorGUILayout.LabelField("Material No [" + MaterialNoTop + "-" + ((MaterialNoTop + CountShader) - 1) + "]: Texture-" + i ); EditorGUI.indentLevel = LevelIndent + 2; for (int j = 0; j < CountShader; j++) { MaterialTableNo = (Library_SpriteStudio.KindColorOperation)(j + 1); NameField = "Shader [" + MaterialTableNo.ToString() + "]"; Data.TableMaterial[MaterialNoTop + j] = (Material)(EditorGUILayout.ObjectField(NameField, Data.TableMaterial[MaterialNoTop + j], typeof(Material), false)); } EditorGUILayout.Space(); EditorGUI.indentLevel = LevelIndent + 1; } } EditorGUI.indentLevel = LevelIndent; } EditorGUILayout.Space(); FoldOutAnimationInformation = EditorGUILayout.Foldout(FoldOutAnimationInformation, "Animation Information"); if (true == FoldOutAnimationInformation) { EditorGUI.indentLevel = LevelIndent + 1; if (null != Data.ListInformationPlay) { for (int i = 0; i < Data.ListInformationPlay.Length; i++) { EditorGUILayout.LabelField("Animation No [" + i + "]: Name[" + Data.ListInformationPlay[i].Name + "]"); EditorGUI.indentLevel = LevelIndent + 2; EditorGUILayout.LabelField("Start Frame-No [" + Data.ListInformationPlay[i].FrameStart.ToString("D5") + "]"); EditorGUILayout.LabelField("End Frame-No [" + Data.ListInformationPlay[i].FrameEnd.ToString("D5") + "]"); float FPS = 1.0f / (float)Data.ListInformationPlay[i].FramePerSecond; EditorGUILayout.LabelField("Base FPS [" + Data.ListInformationPlay[i].FramePerSecond.ToString("D3") + "]:(" + FPS.ToString() + " Sec.)"); EditorGUILayout.Space(); EditorGUI.indentLevel = LevelIndent + 1; } } EditorGUI.indentLevel = LevelIndent; } EditorGUILayout.Space(); FoldOutPlayInformation = EditorGUILayout.Foldout(FoldOutPlayInformation, "Initial/Preview Play Setting"); if (true == FoldOutPlayInformation) { bool FlagUpdate = false; EditorGUI.indentLevel = LevelIndent + 1; string[] NameAnimation = new string[Data.ListInformationPlay.Length]; int[] IndexAnimation = new int[Data.ListInformationPlay.Length]; for (int i = 0; i < Data.ListInformationPlay.Length; i++) { IndexAnimation[i] = i; NameAnimation[i] = Data.ListInformationPlay[i].Name; } int AnimationNo = EditorGUILayout.IntPopup("Animation Name", Data.AnimationNo, NameAnimation, IndexAnimation); if (Data.AnimationNo != AnimationNo) { Data.AnimationNo = AnimationNo; FlagUpdate = true; } int FrameNoEnd = Data.ListInformationPlay[Data.AnimationNo].FrameEnd - Data.ListInformationPlay[Data.AnimationNo].FrameStart; int FrameNoInitial = EditorGUILayout.IntField("Start Offset Frame-No", Data.FrameNoInitial); // int FrameNoInitial = EditorGUILayout.IntSlider("Start Offset Frame-No", Data.FrameNoInitial, 0, FrameNoEnd); EditorGUILayout.LabelField("(This-Value influences only at Initial)"); EditorGUILayout.LabelField("(Don't set Negative-Value or OverRun-Value)"); if (0 > FrameNoInitial) { FrameNoInitial = 0; } if (FrameNoEnd < FrameNoInitial) { FrameNoInitial = FrameNoEnd; } if (Data.FrameNoInitial != FrameNoInitial) { Data.FrameNoInitial = FrameNoInitial; FlagUpdate = true; } EditorGUILayout.Space(); Data.RateTimeAnimation = EditorGUILayout.FloatField("Rate Time-Progress", Data.RateTimeAnimation); EditorGUILayout.LabelField("(set Negative-Value, Play Backwards.)"); EditorGUILayout.Space(); Data.PlayTimes = EditorGUILayout.IntField("Number of Plays", Data.PlayTimes); EditorGUILayout.LabelField("(1: No Loop / 0: Infinite Loop)"); EditorGUILayout.Space(); if (true == GUILayout.Button("Reset (Reinitialize)")) { Data.AnimationNo = 0; Data.FrameNoInitial = 0; Data.RateTimeAnimation = 1.0f; Data.PlayTimes = 0; FlagUpdate = true; } EditorGUI.indentLevel = LevelIndent; if (true == FlagUpdate) { Data.AnimationPlay(AnimationNo, Data.PlayTimes, -1, 0.0f); } } EditorGUILayout.Space(); FoldOutDrawSetting = EditorGUILayout.Foldout(FoldOutDrawSetting, "Rendering Setting"); if (true == FoldOutDrawSetting) { EditorGUI.indentLevel = LevelIndent + 1; int CountKindQueue = (int)Script_SpriteStudio_PartsRoot.KindDrawQueue.OVERLAY + 1; int[] IndexDrawKind = new int[CountKindQueue]; for (int i = 0; i < CountKindQueue; i++) { IndexDrawKind[i] = i; } int KindRenderQueueBaseNo = (int)Data.KindRenderQueueBase; KindRenderQueueBaseNo = EditorGUILayout.IntPopup("Render-Queue Base", KindRenderQueueBaseNo, NameDrawKind, IndexDrawKind); Data.KindRenderQueueBase = (Script_SpriteStudio_PartsRoot.KindDrawQueue)KindRenderQueueBaseNo; EditorGUI.indentLevel = LevelIndent + 2; EditorGUILayout.LabelField("Details [" + NameDrawKind[KindRenderQueueBaseNo] + "]"); switch ((Script_SpriteStudio_PartsRoot.KindDrawQueue)KindRenderQueueBaseNo) { case Script_SpriteStudio_PartsRoot.KindDrawQueue.SHADER_SETTING: EditorGUILayout.LabelField("- Value Base: Defined Tag\"Queue\" in Shader (Default: Transparent)"); EditorGUILayout.LabelField("- Offset Range: Depend on Tag\"Queue\"(Default: 0-999)"); break; case Script_SpriteStudio_PartsRoot.KindDrawQueue.USER_SETTING: EditorGUILayout.LabelField("- Value Base: 0"); EditorGUILayout.LabelField("- Offset Range: 1000-4999"); break; default: EditorGUILayout.LabelField("- Value Base: " + Script_SpriteStudio_PartsRoot.ValueKindDrawQueue[KindRenderQueueBaseNo]); EditorGUILayout.LabelField("- Offset Range: 0-" + (Script_SpriteStudio_PartsRoot.ValueKindDrawQueue[KindRenderQueueBaseNo + 1] - Script_SpriteStudio_PartsRoot.ValueKindDrawQueue[KindRenderQueueBaseNo] - 1)); break; } EditorGUI.indentLevel = LevelIndent + 1; EditorGUILayout.Space(); Data.OffsetDrawQueue = EditorGUILayout.IntField("Render-Queue Offset", Data.OffsetDrawQueue); EditorGUILayout.Space(); Data.RateDrawQueueEffectZ = EditorGUILayout.FloatField("Rate Z Effect", Data.RateDrawQueueEffectZ); EditorGUILayout.LabelField("(\"This-Value x ViewPort-Z\" Added to Offset)"); EditorGUI.indentLevel = LevelIndent; } EditorGUILayout.Space(); if (true == GUI.changed) { EditorUtility.SetDirty(target); } }
public void SetRoot(Script_SpriteStudio_PartsRoot root) { this._root = root; }
public override void OnInspectorGUI() { Script_SpriteStudio_PartsRoot Data = (Script_SpriteStudio_PartsRoot)target; EditorGUILayout.LabelField("[SpriteStudio Parts-Root]"); int LevelIndent = 0; EditorGUILayout.Space(); FoldOutMaterialTable = EditorGUILayout.Foldout(FoldOutMaterialTable, "Based-Material Table"); if (true == FoldOutMaterialTable) { EditorGUI.indentLevel = LevelIndent + 1; if (null != Data.TableMaterial) { int CountShader = (int)(Library_SpriteStudio.KindColorOperation.TERMINATOR - 1); int Count = Data.TableMaterial.Length / CountShader; int MaterialNoTop = 0; Library_SpriteStudio.KindColorOperation MaterialTableNo = 0; string NameField = ""; for (int i = 0; i < Count; i++) { MaterialNoTop = i * (int)(Library_SpriteStudio.KindColorOperation.TERMINATOR - 1); EditorGUILayout.LabelField("Material No [" + MaterialNoTop + "-" + ((MaterialNoTop + CountShader) - 1) + "]: Texture-" + i ); EditorGUI.indentLevel = LevelIndent + 2; for (int j = 0; j < CountShader; j++) { MaterialTableNo = (Library_SpriteStudio.KindColorOperation)(j + 1); NameField = "Shader [" + MaterialTableNo.ToString() + "]"; Data.TableMaterial[MaterialNoTop + j] = (Material)(EditorGUILayout.ObjectField(NameField, Data.TableMaterial[MaterialNoTop + j], typeof(Material), false)); } EditorGUILayout.Space(); EditorGUI.indentLevel = LevelIndent + 1; } } EditorGUI.indentLevel = LevelIndent; } EditorGUILayout.Space(); FoldOutAnimationInformation = EditorGUILayout.Foldout(FoldOutAnimationInformation, "Animation Information"); if (true == FoldOutAnimationInformation) { EditorGUI.indentLevel = LevelIndent + 1; if (null != Data.ListInformationPlay) { for (int i = 0; i < Data.ListInformationPlay.Length; i++) { EditorGUILayout.LabelField("Animation No [" + i + "]: Name[" + Data.ListInformationPlay[i].Name + "]"); EditorGUI.indentLevel = LevelIndent + 2; EditorGUILayout.LabelField("Start Frame-No [" + Data.ListInformationPlay[i].FrameStart.ToString("D5") + "]"); EditorGUILayout.LabelField("End Frame-No [" + Data.ListInformationPlay[i].FrameEnd.ToString("D5") + "]"); float FPS = 1.0f / (float)Data.ListInformationPlay[i].FramePerSecond; EditorGUILayout.LabelField("Base FPS [" + Data.ListInformationPlay[i].FramePerSecond.ToString("D3") + "]:(" + FPS.ToString() + " Sec.)"); EditorGUILayout.Space(); EditorGUI.indentLevel = LevelIndent + 1; } } EditorGUI.indentLevel = LevelIndent; } EditorGUILayout.Space(); FoldOutPlayInformation = EditorGUILayout.Foldout(FoldOutPlayInformation, "Initial/Preview Play Setting"); if (true == FoldOutPlayInformation) { bool FlagUpdate = false; EditorGUI.indentLevel = LevelIndent + 1; string[] NameAnimation = new string[Data.ListInformationPlay.Length]; int[] IndexAnimation = new int[Data.ListInformationPlay.Length]; for (int i = 0; i < Data.ListInformationPlay.Length; i++) { IndexAnimation[i] = i; NameAnimation[i] = Data.ListInformationPlay[i].Name; } int AnimationNo = EditorGUILayout.IntPopup("Animation Name", Data.AnimationNo, NameAnimation, IndexAnimation); if (Data.AnimationNo != AnimationNo) { Data.AnimationNo = AnimationNo; FlagUpdate = true; } int CountLabel = Data.ListInformationPlay[AnimationNo].Label.Length; bool FlagLabelSelectable = (0 < CountLabel) ? true : false; int FrameNoStart = 0; int FrameNoEnd = Data.ListInformationPlay[AnimationNo].FrameEnd - Data.ListInformationPlay[AnimationNo].FrameStart; int FrameNoStartRange = FrameNoStart; int FrameNoEndRange = FrameNoEnd; EditorGUILayout.LabelField("Animation Frames: " + FrameNoStart.ToString() + " to " + FrameNoEnd.ToString()); EditorGUILayout.Space(); string[] NameLabel = null; int[] IndexLabel = null; int[] FrameNoLabel = null; int LabelStart = -1; int LabelEnd = -1; if (true == FlagLabelSelectable) { CountLabel += 2; /* +2 ... "_start" and "_end" (Reserved-Labels) */ NameLabel = new string[CountLabel]; IndexLabel = new int[CountLabel]; FrameNoLabel = new int[CountLabel]; NameLabel[0] = string.Copy(Library_SpriteStudio.AnimationInformationPlay.LabelDefaultStart); IndexLabel[0] = 0; FrameNoLabel[0] = 0; for (int j = 1; j < (CountLabel - 1); j++) { IndexLabel[j] = j; NameLabel[j] = string.Copy(Data.ListInformationPlay[AnimationNo].Label[j - 1].Name); FrameNoLabel[j] = Data.ListInformationPlay[AnimationNo].Label[j - 1].FrameNo; } NameLabel[CountLabel - 1] = string.Copy(Library_SpriteStudio.AnimationInformationPlay.LabelDefaultEnd); IndexLabel[CountLabel - 1] = CountLabel - 1; FrameNoLabel[CountLabel - 1] = FrameNoEnd; for (int j = 0; j < CountLabel; j++) { if (0 == string.Compare(NameLabel[j], Data.NameLabelStart)) { LabelStart = j; } if (0 == string.Compare(NameLabel[j], Data.NameLabelEnd)) { LabelEnd = j; } } if (-1 == LabelStart) { LabelStart = 0; } if (-1 == LabelEnd) { LabelEnd = CountLabel - 1; } } else { CountLabel = 2; NameLabel = new string[CountLabel]; IndexLabel = new int[CountLabel]; FrameNoLabel = new int[CountLabel]; NameLabel[0] = string.Copy(Library_SpriteStudio.AnimationInformationPlay.LabelDefaultStart); IndexLabel[0] = 0; FrameNoLabel[0] = 0; NameLabel[1] = string.Copy(Library_SpriteStudio.AnimationInformationPlay.LabelDefaultEnd); IndexLabel[1] = CountLabel - 1; FrameNoLabel[1] = FrameNoEnd; } EditorGUILayout.Space(); if (true == FlagLabelSelectable) { int LabelOld = LabelStart; LabelStart = EditorGUILayout.IntPopup("Range Start Label", LabelOld, NameLabel, IndexLabel); if ((LabelOld != LabelStart) || (true == string.IsNullOrEmpty(Data.NameLabelStart))) { Data.NameLabelStart = string.Copy(NameLabel[IndexLabel[LabelStart]]); FlagUpdate = true; } FrameNoStartRange = FrameNoLabel[LabelStart]; } int OffsetOld = Data.OffsetFrameStart - FrameNoStart; int OffsetNew = EditorGUILayout.IntField("Range Start Offset: ", OffsetOld); if ((FrameNoStartRange + OffsetNew) >= FrameNoEnd) { OffsetNew = FrameNoEnd - FrameNoStartRange - 1; } if (OffsetOld != OffsetNew) { Data.OffsetFrameStart = OffsetNew; FlagUpdate = true; } EditorGUILayout.LabelField("Range Start: (" + FrameNoStartRange.ToString() + " + " + OffsetNew.ToString() + ")=" + (FrameNoStartRange + OffsetNew).ToString() ); FrameNoStartRange += OffsetNew; EditorGUILayout.Space(); if (true == FlagLabelSelectable) { int LabelOld = LabelEnd; LabelEnd = EditorGUILayout.IntPopup("Range End Lable", LabelOld, NameLabel, IndexLabel); if ((LabelOld != LabelEnd) || (true == string.IsNullOrEmpty(Data.NameLabelEnd))) { Data.NameLabelEnd = string.Copy(NameLabel[IndexLabel[LabelEnd]]); FlagUpdate = true; } FrameNoEndRange = FrameNoLabel[LabelEnd]; } OffsetOld = Data.OffsetFrameEnd; OffsetNew = EditorGUILayout.IntField("Range End Offset", OffsetOld); if ((FrameNoEndRange + OffsetNew) >= FrameNoEnd) { OffsetNew = 0; } if ((FrameNoEndRange + OffsetNew) <= FrameNoStartRange) { OffsetNew = (FrameNoStartRange - FrameNoEndRange) + 1; } if (OffsetOld != OffsetNew) { Data.OffsetFrameEnd = OffsetNew; FlagUpdate = true; } EditorGUILayout.LabelField("Range End: (" + FrameNoEndRange.ToString() + " + " + OffsetNew.ToString() + ")=" + (FrameNoEndRange + OffsetNew).ToString() ); FrameNoEndRange += OffsetNew; EditorGUILayout.Space(); int FrameNoInitialOld = Data.FrameNoInitial; if (0 > FrameNoInitialOld) { FrameNoInitialOld = 0; } if ((FrameNoEnd - FrameNoStart) < FrameNoInitialOld) { FrameNoInitialOld = FrameNoEnd - FrameNoStart; } int FrameNoInitial = EditorGUILayout.IntField("Initial Start Offset", FrameNoInitialOld); EditorGUILayout.LabelField("Valid Value Range: 0 to " + (FrameNoEndRange - FrameNoStartRange).ToString()); if (0 > FrameNoInitial) { FrameNoInitial = 0; } if ((FrameNoEndRange - FrameNoStartRange) < FrameNoInitial) { FrameNoInitial = FrameNoEndRange - FrameNoStartRange; } if (FrameNoInitialOld != FrameNoInitial) { Data.FrameNoInitial = FrameNoInitial; FlagUpdate = true; } EditorGUILayout.Space(); Data.FlagStylePingpong = EditorGUILayout.Toggle("Play-Pingpong", Data.FlagStylePingpong); EditorGUILayout.Space(); Data.RateTimeAnimation = EditorGUILayout.FloatField("Rate Time-Progress", Data.RateTimeAnimation); EditorGUILayout.LabelField("(set Negative-Value, Play Backwards.)"); EditorGUILayout.Space(); Data.PlayTimes = EditorGUILayout.IntField("Number of Plays", Data.PlayTimes); EditorGUILayout.LabelField("(1: No Loop / 0: Infinite Loop)"); EditorGUILayout.Space(); if (true == GUILayout.Button("Reset (Reinitialize)")) { Data.AnimationNo = 0; Data.FrameNoInitial = 0; Data.RateTimeAnimation = 1.0f; Data.PlayTimes = 0; Data.FlagStylePingpong = false; Data.NameLabelStart = string.Copy(Library_SpriteStudio.AnimationInformationPlay.LabelDefaultStart); Data.OffsetFrameStart = 0; Data.NameLabelEnd = string.Copy(Library_SpriteStudio.AnimationInformationPlay.LabelDefaultEnd); Data.OffsetFrameEnd = 0; FlagUpdate = true; } EditorGUI.indentLevel = LevelIndent; if (true == FlagUpdate) { Data.AnimationPlay(); } } EditorGUILayout.Space(); Data.FlagHideForce = EditorGUILayout.Toggle("Force-Hide", Data.FlagHideForce); if (true == GUILayout.Button("Apply \"Force-Hide\" to Children")) { LibraryEditor_SpriteStudio.Utility.HideSetForce(Data.gameObject, Data.FlagHideForce, true, false); } EditorGUILayout.Space(); if (true == GUI.changed) { EditorUtility.SetDirty(target); } }
/* ******************************************************** */ //! Get GameObject with a particular name /*! * @param PartsKind * (Output) Kind of Parts * @param SpriteKind * (Output) Kind of Sprite * @param InstanceOrigin * GameObject to start the search * @retval Return-Value * Instance of GameObject<br> * null == Not-Found / Failure * @retval PartsKind * Kind of Parts * @retval SpriteKind * Kind of Sprite * * Get GameObject with a particular name by examining "InstanceOrigin" and children.<br> * <br> * Value is set to " PartsKind" means the type of Component that GameObject has.<br> * It has the regularity of the following.<br> * - "Library_SpriteStudio.KindParts.NORMAL" ... "Script_SpriteStudio_Triangle2" / Script_SpriteStudio_Triangle4"<br> * - "Library_SpriteStudio.KindParts.ROOT" ... "Script_SpriteStudio_PartsRoot"<br> * - "Library_SpriteStudio.KindParts.NULL" ... "Script_SpriteStudio_PartsNULL"<br> * - "Library_SpriteStudio.KindParts.INSTANCE" ... "Script_SpriteStudio_PartsInstance"<br> * <br> * Value is set to "SpriteKind" is supplementary information when " PartsKind" is "Library_SpriteStudio.KindParts.NORMAL".<br> * - "Library_SpriteStudio.KindSprite.TRIANGLE2" ... "Script_SpriteStudio_Triangle2"<br> * - "Library_SpriteStudio.KindSprite.TRIANGLE4" ... "Script_SpriteStudio_Triangle4"<br> * - "Library_SpriteStudio.KindSprite.NON" ... the other<br> * <br> * If applicable GameObject has no component for "SS5Player for Unity", * "PartsKind" and "SpriteKind" are set to the contents of the "Library_SpriteStudio.KindParts.NORMAL" and "Library_SpriteStudio.KindSprite.NON" .<br> */ public static GameObject GameObjectGetName(out KindParts PartsKind, out KindSprite SpriteKind, GameObject InstanceOrigin, string Name) { /* Clear Output */ PartsKind = KindParts.NORMAL; SpriteKind = KindSprite.NON; if (true == String.IsNullOrEmpty(Name)) { /* Error */ return(null); } /* Check Name */ if (true == Name.Equals(InstanceOrigin.name)) { Script_SpriteStudio_Triangle2 ScriptTriangle2 = InstanceOrigin.GetComponent <Script_SpriteStudio_Triangle2>(); if (null != ScriptTriangle2) { /* Parts: Sprite-Triangle2 */ PartsKind = KindParts.NORMAL; SpriteKind = KindSprite.TRIANGLE2; return(InstanceOrigin); } else { Script_SpriteStudio_Triangle4 ScriptTriangle4 = InstanceOrigin.GetComponent <Script_SpriteStudio_Triangle4>(); if (null != ScriptTriangle4) { /* Parts: Sprite-Triangle4 */ PartsKind = KindParts.NORMAL; SpriteKind = KindSprite.TRIANGLE4; return(InstanceOrigin); } else { Script_SpriteStudio_PartsNULL ScriptNULL = InstanceOrigin.GetComponent <Script_SpriteStudio_PartsNULL>(); if (null != ScriptNULL) { /* Parts: NULL */ PartsKind = KindParts.NULL; SpriteKind = KindSprite.NON; return(InstanceOrigin); } else { Script_SpriteStudio_PartsInstance ScriptInstance = InstanceOrigin.GetComponent <Script_SpriteStudio_PartsInstance>(); if (null != ScriptInstance) { /* Parts: Instance */ PartsKind = KindParts.INSTANCE; SpriteKind = KindSprite.NON; return(InstanceOrigin); } else { Script_SpriteStudio_PartsRoot ScriptRoot = InstanceOrigin.GetComponent <Script_SpriteStudio_PartsRoot>(); if (null != ScriptRoot) { /* Parts: Root */ PartsKind = KindParts.ROOT; SpriteKind = KindSprite.NON; return(InstanceOrigin); } else { /* Parts: Not-for-SpriteStudio */ PartsKind = KindParts.NORMAL; SpriteKind = KindSprite.NON; return(InstanceOrigin); } } } } } } /* Check Children */ int CountChild = InstanceOrigin.transform.childCount; Transform InstanceTransformChild = null; GameObject InstanceChild = null; for (int i = 0; i < CountChild; i++) { InstanceTransformChild = InstanceOrigin.transform.GetChild(i); InstanceChild = GameObjectGetName(out PartsKind, out SpriteKind, InstanceTransformChild.gameObject, Name); if (null != InstanceChild) { return(InstanceChild); } } /* Not-Found */ return(null); }
public void DrawEntry(Script_SpriteStudio_PartsRoot.InformationMeshData MeshDataInformation, int FrameNo, Script_SpriteStudio_PartsRoot ScriptRoot) { float Priority = (0 < AnimationDataPriority.Length) ? AnimationDataPriority[FrameNo] : 0.0f; int TextureNo = (0 < AnimationDataCell.Length) ? AnimationDataCell[FrameNo].TextureNo : -1; MeshDataInformation.Priority = Priority + ((float)ID * (1.0f / 1000.0f)); ScriptRoot.MeshAdd(TextureNo, KindBlendTarget, MeshDataInformation); }
public void UpdateMesh(Mesh MeshNow, int FrameNo, Script_SpriteStudio_PartsRoot ScriptRoot) { Matrix4x4 MatrixTexture = Matrix4x4.identity; Vector2 SizeTexture = Vector2.one; Vector2 RateScaleTexture = Vector2.one; Vector2 PivotTexture = Vector2.zero; Vector2 RateScaleMesh = Vector2.one; Vector2 PivotMesh = Vector2.zero; Rect RectCell = Rect.MinMaxRect(0.0f, 0.0f, 64.0f, 64.0f); int VertexCollectionIndexTableNo = 0; /* Main-Texture Data Get */ Material MaterialNow = ScriptRoot.MaterialGet(AnimationDataCell[FrameNo].TextureNo, KindBlendTarget); if(null != MaterialNow) { Texture InstanceTexture = MaterialNow.mainTexture; SizeTexture.x = (float)InstanceTexture.width; SizeTexture.y = (float)InstanceTexture.height; } /* Cell-Data Get */ if(0 < AnimationDataCell.Length) { RectCell = AnimationDataCell[FrameNo].Rectangle; PivotTexture = new Vector2(RectCell.width * 0.5f, RectCell.height * 0.5f); PivotMesh = AnimationDataCell[FrameNo].Pivot; } /* Disolve Flipping & Texture-Scaling */ if(0 < AnimationDataFlags.Length) { RateScaleTexture.x = (true == AnimationDataFlags[FrameNo].IsTextureFlipX) ? -1.0f : 1.0f; RateScaleTexture.y = (true == AnimationDataFlags[FrameNo].IsTextureFlipY) ? -1.0f : 1.0f; if(true == AnimationDataFlags[FrameNo].IsFlipX) { RateScaleMesh.x = -1.0f; VertexCollectionIndexTableNo += 1; } else { RateScaleMesh.x = 1.0f; } if(true == AnimationDataFlags[FrameNo].IsFlipY) { RateScaleMesh.y = -1.0f; VertexCollectionIndexTableNo += 2; } else { RateScaleMesh.y = 1.0f; } } if(0 < AnimationDataTextureScale.Length) { RateScaleTexture.x *= AnimationDataTextureScale[FrameNo].x; RateScaleTexture.y *= AnimationDataTextureScale[FrameNo].y; } /* Calculate Matrix-Texture */ float Rotate = (0 < AnimationDataTextureRotate.Length) ? AnimationDataTextureRotate[FrameNo] : 0.0f; Vector2 TextureOffset = (0 < AnimationDataTextureTranslate.Length) ? AnimationDataTextureTranslate[FrameNo] : Vector2.zero; Vector3 Translation = new Vector3( ((RectCell.xMin + PivotTexture.x) / SizeTexture.x) + TextureOffset.x, ((SizeTexture.y - (RectCell.yMin + PivotTexture.y)) / SizeTexture.y) - TextureOffset.y, 0.0f ); Vector3 Scaling = new Vector3( (RectCell.width / SizeTexture.x) * RateScaleTexture.x, (RectCell.height / SizeTexture.y) * RateScaleTexture.y, 1.0f ); Quaternion Rotation = Quaternion.Euler(0.0f, 0.0f, Rotate); MatrixTexture = Matrix4x4.TRS(Translation, Rotation, Scaling); /* Set Vertex-Datas */ int CountVertexData = MeshNow.vertexCount; Vector2[] DataUV = new Vector2[CountVertexData]; Vector3 Coodinate = Vector3.zero; for(int i=0; i<CountVertexData; i++) /* Texture-UV */ { /* Memo: "ArrayUVMappingUV0_Triangle4" of the data up to the "VertexNo.TERMINATOR2"-th elements are same as those of "ArrayUVMappingUV0_Triangle2". */ Coodinate = MatrixTexture.MultiplyPoint3x4(ArrayUVMappingUV0_Triangle4[i]); DataUV[i] = new Vector2(Coodinate.x, Coodinate.y); } MeshNow.uv = DataUV; float RateOpacity = (0 < AnimationDataOpacityRate.Length) ? AnimationDataOpacityRate[FrameNo] : 1.0f; Vector2[] DataUV2 = new Vector2[CountVertexData]; Color32[] DataColor32 = new Color32[CountVertexData]; if(0 < AnimationDataColorBlend.Length) /* Blending-Color & Opacity*/ { /* Animation-Data */ #if false for(int i=0; i<CountVertexData; i++) { DataUV2[i] = new Vector2( AnimationDataColorBlend[FrameNo].RatePixelAlpha[i] * RateOpacity, (float)AnimationDataColorBlend[FrameNo].Operation + 0.01f /* "+0.01f" for Rounding-off-Error */ ); DataColor32[i] = AnimationDataColorBlend[FrameNo].VertexColor[i]; } #else if(Library_SpriteStudio.KindColorBound.NON != AnimationDataColorBlend[FrameNo].Bound) { for(int i=0; i<CountVertexData; i++) { DataUV2[i] = new Vector2( AnimationDataColorBlend[FrameNo].RatePixelAlpha[i] * RateOpacity, (float)AnimationDataColorBlend[FrameNo].Operation + 0.01f /* "+0.01f" for Rounding-off-Error */ ); DataColor32[i] = AnimationDataColorBlend[FrameNo].VertexColor[i]; } } else { /* Default (Same as "No Datas" ) */ Color32 ColorDefault = Color.white; float OperationDefault = (float)KindColorOperation.NON + 0.01f; /* "+0.01f" for Rounding-off-Error */ for(int i=0; i<CountVertexData; i++) { DataUV2[i] = new Vector2(RateOpacity, OperationDefault); DataColor32[i] = ColorDefault; } } #endif } else { /* Default (No Datas) */ Color32 ColorDefault = Color.white; float OperationDefault = (float)KindColorOperation.NON + 0.01f; /* "+0.01f" for Rounding-off-Error */ for(int i=0; i<CountVertexData; i++) { DataUV2[i] = new Vector2(RateOpacity, OperationDefault); DataColor32[i] = ColorDefault; } } MeshNow.colors32 = DataColor32; MeshNow.uv2 = DataUV2; Vector3[] DataCoordinate = new Vector3[CountVertexData]; if((int)VertexNo.TERMINATOR4 == CountVertexData) /* Vertex-Coordinate */ { /* 4-Triangles Mesh */ /* Get SpriteSize & Pivot */ SpriteRecalcSizeAndPivot(ref PivotMesh, ref RectCell, ref RateScaleMesh, FrameNo); /* Get Coordinates */ /* MEMO: No Check "AnimationDataVertexCorrection.Length", 'cause 4-Triangles-Mesh necessarily has "AnimationDataVertexCorrection" */ float Left = (-PivotMesh.x) * RateScaleMesh.x; float Right = (RectCell.width - PivotMesh.x) * RateScaleMesh.x; float Top = (-PivotMesh.y) * RateScaleMesh.y; float Bottom = (RectCell.height - PivotMesh.y) * RateScaleMesh.y; DataCoordinate[(int)VertexNo.LU] = new Vector3( Left + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.LU]].x, -Top + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.LU]].y, 0.0f ); DataCoordinate[(int)VertexNo.RU] = new Vector3( Right + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.RU]].x, -Top + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.RU]].y, 0.0f ); DataCoordinate[(int)VertexNo.RD] = new Vector3( Right + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.RD]].x, -Bottom + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.RD]].y, 0.0f ); DataCoordinate[(int)VertexNo.LD] = new Vector3( Left + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.LD]].x, -Bottom + AnimationDataVertexCorrection[FrameNo].Coordinate[VertexCollrctionOrderVertex[VertexCollectionIndexTableNo, (int)VertexNo.LD]].y, 0.0f ); Vector3 CoordinateLURU = (DataCoordinate[(int)VertexNo.LU] + DataCoordinate[(int)VertexNo.RU]) * 0.5f; Vector3 CoordinateLULD = (DataCoordinate[(int)VertexNo.LU] + DataCoordinate[(int)VertexNo.LD]) * 0.5f; Vector3 CoordinateLDRD = (DataCoordinate[(int)VertexNo.LD] + DataCoordinate[(int)VertexNo.RD]) * 0.5f; Vector3 CoordinateRURD = (DataCoordinate[(int)VertexNo.RU] + DataCoordinate[(int)VertexNo.RD]) * 0.5f; CoordinateGetDiagonalIntersection( out DataCoordinate[(int)VertexNo.C], ref CoordinateLURU, ref CoordinateRURD, ref CoordinateLULD, ref CoordinateLDRD ); } else { /* 2-Triangles Mesh */ /* Get SpriteSize & Pivot */ SpriteRecalcSizeAndPivot(ref PivotMesh, ref RectCell, ref RateScaleMesh, FrameNo); /* Get Coordinates */ float Left = (-PivotMesh.x) * RateScaleMesh.x; float Right = (RectCell.width - PivotMesh.x) * RateScaleMesh.x; float Top = (-PivotMesh.y) * RateScaleMesh.y; float Bottom = (RectCell.height - PivotMesh.y) * RateScaleMesh.y; DataCoordinate[(int)VertexNo.LU] = new Vector3(Left, -Top, 0.0f); DataCoordinate[(int)VertexNo.RU] = new Vector3(Right, -Top, 0.0f); DataCoordinate[(int)VertexNo.RD] = new Vector3(Right, -Bottom, 0.0f); DataCoordinate[(int)VertexNo.LD] = new Vector3(Left, -Bottom, 0.0f); } MeshNow.vertices = DataCoordinate; }
public void DrawEntry(Script_SpriteStudio_PartsRoot.InformationMeshData MeshDataInformation, int FrameNo, Script_SpriteStudio_PartsRoot ScriptRoot) { float Priority = (0 < AnimationDataPriority.Length) ? AnimationDataPriority[FrameNo] : 0.0f; int TextureNo = (0 < AnimationDataCell.Length) ? AnimationDataCell[FrameNo].TextureNo : -1; MeshDataInformation.Priority = Priority + ((float)ID * (1.0f / 1000.0f)); ScriptRoot.MeshAdd(TextureNo, KindBlendTarget, MeshDataInformation); }
private Script_SpriteStudio_PartsRoot PartsRootGetOrigin(Script_SpriteStudio_PartsRoot Start) { Script_SpriteStudio_PartsRoot PartsRootNow = Start; while(null != PartsRootNow.PartsRootOrigin) { PartsRootNow = PartsRootNow.PartsRootOrigin; } return(PartsRootNow); }
/* ******************************************************** */ //! Change playing the Instance-Object's animation /*! @param InstancePrefab New Prefab<br> @retval Return-Value true == Success <br> false == Failure (Error) The playing of Instance-Object's Prefab changes. <br> It is necessary for the New Prefab to have the Prefab which is already set and compatibility of a data structure.<br> <br> Caution!: This Function is in experimentally inplement. */ public bool PrefabChangeInstance(GameObject PrefabNew) { GameObject Instance = null; #if UNITY_EDITOR DestroyImmediate(InstanceGameObjectPartsRootSub); Instance = (GameObject)PrefabUtility.InstantiatePrefab(PrefabNew); #else Destroy(InstanceGameObjectPartsRootSub); Instance = (GameObject)Instantiate(PrefabNew); #endif InstanceGameObjectPartsRootSub = null; scriptPartsRootSub = null; LinkSetPartsInstance(Instance); return(true); }
// Use this for initialization void Awake() { this.animator = this.GetComponent<Animator> (); this.YakukoController = Yakuko.GetComponent<Script_SpriteStudio_PartsRoot> (); this.YakukoController.AnimationPlay (4, 0, 1, 1.0f); this.PlayerState = YakukoState.Sageru; this.timer = new myTimer (); }
// Update is called once per frame void Update() { //spritestudioルートクラスの取得 //spriteStudioRootを使用してアニメーションの制御を行います。 if(null == spriteStudioRoot) { int Count = transform.childCount; Transform InstanceTransformChild = null; for(int i=0; i<Count; i++) { InstanceTransformChild = transform.GetChild(i); //パーツルートの取得 spriteStudioRoot = InstanceTransformChild.gameObject.GetComponent<Script_SpriteStudio_PartsRoot>(); //パーツルートからカラー操作バッファを取得 DataColorBlendOverwrite = spriteStudioRoot.DataGetColorBlendOverwrite(); if(null != spriteStudioRoot) { //初期化 //アニメーションの終了割り込みを設定 spriteStudioRoot.FunctionPlayEnd = AnimEnd; //初期アニメーションを設定 set_motion( AnimationType.STANCE, true); break; } } } //アニメーションの終了を監視 if (anime_end == true) { anime_end = false; //次のモーションを設定 set_next_motion(); } // 現在位置をPositionに代入 Vector2 Position = player_pos; //コマンド処理 //同じ方向を2回連続で入力したらダッシュ if (GameControl.IsPushKey((int)gamemain.INPUTBUTTON.BUTTON_LEFT)) { if (dash_command_count > 0) { if (dash_oldinput_key == -1) { dash = true; } } dash_command_count = dash_command_time; dash_oldinput_key = -1; } else if (GameControl.IsPushKey((int)gamemain.INPUTBUTTON.BUTTON_RIGHT)) { if (dash_command_count > 0) { if (dash_oldinput_key == 1) { dash = true; } } dash_command_count = dash_command_time; dash_oldinput_key = 1; } dash_command_count--; if ( dash_command_count < 0 ) { dash_command_count = 0; dash_oldinput_key = 0; } //プレイヤーのキー入力処理 bool ismove = false; if ((is_wait () == false) && ( defense == false ) ){ if (isground == true) { if(GameControl.IsPressKey((int)gamemain.INPUTBUTTON.BUTTON_DOWN)){ // 下キーを押し続けていたら sit = true; } else { sit = false; if (GameControl.IsPressKey ((int)gamemain.INPUTBUTTON.BUTTON_LEFT)) { // 左キーを押し続けていたら // 代入したPositionに対して加算減算を行う if (dash == true) { Position.x -= SPEED.x * 2.0f; } else { Position.x -= SPEED.x; } direction = 0; ismove = true; } else if (GameControl.IsPressKey ((int)gamemain.INPUTBUTTON.BUTTON_RIGHT)) { // 右キーを押し続けていたら // 代入したPositionに対して加算減算を行う if (dash == true) { Position.x += SPEED.x * 2.0f; } else { Position.x += SPEED.x; } direction = 1; ismove = true; } if (ismove == false) { //移動入力がない場合ダッシュ終了 dash = false; } if (GameControl.IsPressKey((int)gamemain.INPUTBUTTON.BUTTON_UP)) { // 上キーを押し続けていたら if (isground == true) { //地面にいたらジャンプを行う jump_force = 2500.0f; set_motion(AnimationType.JUMP_START); //SE再生 soundcontrol.PlaySE( sound.SE_TYPE.JUMP ); if (ismove == true) { if (dash == true) { if (direction == 0) { jump_speed = -SPEED.x * 2.0f; //ジャンプ中の移動速度 } else if (direction == 1) { jump_speed = SPEED.x * 2.0f; //ジャンプ中の移動速度 } } else { if (direction == 0) { jump_speed = -SPEED.x * 1.0f; //ジャンプ中の移動速度 } else if (direction == 1) { jump_speed = SPEED.x * 1.0f; //ジャンプ中の移動速度 } } } else { jump_speed = 0; //ジャンプ中の移動速度 } } } } } } //ボタンを押したら攻撃 if ( (attack_wait == 0) && (is_wait () == false) && ( defense == false ) ){ if (GameControl.IsPushKey ((int)gamemain.INPUTBUTTON.BUTTON_1)) { attack_wait = attack_wait_init; //攻撃の硬直時間設定値 ren_attack_count++; //連続攻撃の回数 attack_time = 0; //SE再生 soundcontrol.PlaySE( sound.SE_TYPE.ATK ); if (isground == true) { if ( sit == true ) { if ((ren_attack_count % 2) == 1) { set_motion (AnimationType.SIT_KICK); } else { set_motion (AnimationType.SIT_PANCH); } } else{ if ((ren_attack_count % 2) == 1) { set_motion (AnimationType.ATTACK1); } else { set_motion (AnimationType.ATTACK2); } } } else { set_motion (AnimationType.JUMP_ATTACK1); } } } defense = false; if (is_wait () == false){ if (isground == true) { if (GameControl.IsPressKey ((int)gamemain.INPUTBUTTON.BUTTON_2)) { //2ボタンはガード defense = true; } } } attack_wait--; if ( attack_wait < 0 ) { attack_wait = 0; } //jump制御 jump_force = jump_force - gravitiy; Position.y += ( jump_force * 0.02f ) ; if ( Position.y < ground_y ){ jump_force = 0.0f; Position.y = ground_y; if ( isground == false) { if (knockback == 0) { set_motion(AnimationType.JUMP_END); } } isground = true; }else{ if ( isground == true) { // set_motion( AnimationType.JUMP_AIR); } //空中では移動料がかかり続ける Position.x += jump_speed; isground = false; } //motion set if (is_wait () == false) { if (isground == true) { if (ismove == true) { if (dash == true) { set_motion(AnimationType.RUN); if ( ( timer % 10 ) == 0 ) { //SE再生 soundcontrol.PlaySE( sound.SE_TYPE.RUN ); effectcontrol.CreateEffect(5, Position.x, Position.y - 0.0f ); } } else { set_motion(AnimationType.WALK); } } else { if ( sit == true ) { if (motion != AnimationType.SIT) { set_motion(AnimationType.SITDOWN); } } else { if ((motion != AnimationType.JUMP_END) && (motion != AnimationType.STANDUP)) { if (motion == AnimationType.SIT) { set_motion(AnimationType.STANDUP); } else { set_motion(AnimationType.STANCE); } } } } } } //ノックバック移動 if ( knockback > 0 ) { float move_x = (float)( knockback * knockback ) * 0.08f; if (direction == 0) { //左向き Position.x += move_x; } else{ //右向き Position.x -= move_x; } set_motion(AnimationType.DAMEGE); } knockback--; if ( knockback == 0 ) { //ノックバック終了 set_motion(AnimationType.STANCE); } if ( knockback < 0 ) { knockback = 0; hit_muteki = 0; } //ディフェンスノックバック if ( knockback > 0 ) { float move_x = (float)( defense_knockback * defense_knockback ) * 0.02f; if (direction == 0) { //左向き Position.x += move_x; } else{ //右向き Position.x -= move_x; } } defense_knockback--; if ( defense_knockback < 0 ) { defense_knockback = 0; } if ( ( defense == true ) || ( defense_knockback > 0 ) ) { defense = true; set_motion(AnimationType.DEFENSE); } //移動範囲を設定 if (Position.x < -3000.0f) { Position.x = -3000.0f; } if (Position.x > 3000.0f) { Position.x = 3000.0f; } //ダメージフラッシュ damege_flash--; if ( damege_flash < 0 ) { damege_flash = 0; } else { //キャラクターの色を変更 /* Overay-Color Buffer Get */ Color OVColor = Color.white; OVColor.a = 0.0f; if ( damege_flash == 0 ) { //色をもとに戻す DataColorBlendOverwrite.SetVertex(Library_SpriteStudio.KindColorOperation.NON, ref OVColor, ref OVColor, ref OVColor, ref OVColor ); } else { //色を赤に変更 OVColor = Color.red; OVColor.a = damege_flash * 0.1f; if ( OVColor.a > 1.0f ) { OVColor.a = 1.0f; } DataColorBlendOverwrite.SetVertex(Library_SpriteStudio.KindColorOperation.MUL, ref OVColor, ref OVColor, ref OVColor, ref OVColor ); } } //向きを反映 if (direction == 0) { transform.localScale = new Vector3(init_scale, init_scale, 1.0f); //左向き制御スケール } else { transform.localScale = new Vector3(-init_scale, init_scale, 1.0f); //左向き制御スケール } // 現在の位置を設定 player_pos = Position; //コリジョンの設定 { //体 float h = 200.0f; float w = 400.0f; float xofs = 0.0f; float yofs = 250.0f; GameControl.set_collision( gamemain.COLTYPE.EN_COLTYPE_PLAYER, transform.gameObject, player_pos.x + xofs, player_pos.y + yofs, h, w, 0, 0 ); //攻撃 xofs = -300.0f; if ( direction == 1 ) { xofs = 300.0f; } switch (motion) { case AnimationType.ATTACK1: case AnimationType.ATTACK2: case AnimationType.ATTACK3: case AnimationType.KICK1: case AnimationType.KICK2: case AnimationType.JUMP_ATTACK1: case AnimationType.JUMP_ATTACK2: case AnimationType.SIT_ATTACK1: case AnimationType.SIT_ATTACK2: case AnimationType.SIT_KICK: case AnimationType.SIT_PANCH: attack_time++; if ( attack_time == 20 ) { h = 300.0f; w = 300.0f; yofs = 250.0f; GameControl.set_collision( gamemain.COLTYPE.EN_COLTYPE_PLAYER_SHOT, transform.gameObject, player_pos.x + xofs, player_pos.y + yofs, h, w, 0, 0 ); } break; default: break; } } //カメラの位置を設定 { Vector2 camerapos = new Vector2( Position.x, Position.y ); Camera2DControl.SetCamera( camerapos ); } //カメラの位置から表示位置を設定 { Vector2 camerapos = Camera2DControl.GetCamera( ); transform.position = Position - camerapos; } timer++; }
void Update() { /* Clear Instance-Part's Draw-List */ DrawListClearInstance(); /* Boot-Check */ if (null == DataMeshInformation) { DataMeshInformation = new Library_SpriteStudio.DrawManager.InformationMeshData(); } if (null == InstanceGameObjectPartsRootSub) { /* Get "Instance"-Parts" */ GameObject InstanceChild = null; Transform InstanceTransformChild = null; Script_SpriteStudio_PartsRoot InstancePartsRootSub = null; int CountChild = transform.childCount; for (int i = 0; i < CountChild; i++) { InstanceTransformChild = transform.GetChild(i); if (null != InstanceTransformChild) { InstanceChild = InstanceTransformChild.gameObject; InstancePartsRootSub = InstanceChild.gameObject.GetComponent <Script_SpriteStudio_PartsRoot>(); if (null != InstancePartsRootSub) { InstanceGameObjectPartsRootSub = InstanceChild; scriptPartsRootSub = InstancePartsRootSub; scriptPartsRootSub.PartsRootOrigin = PartsRootGetOrigin(ScriptRoot); break; /* Exit for-Loop */ } } } } if (null != InstanceGameObjectPartsRootSub) { /* Update User-CallBack */ SpriteStudioData.UpdateUserData(ScriptRoot.FrameNoNow, gameObject, ScriptRoot); /* Update Instance-Data */ bool FlagValidInstanceData = SpriteStudioData.UpdateInstanceData(ScriptRoot.FrameNoNow, gameObject, ScriptRoot, this); /* Set Matrix for Transform (to the GameObject) */ if ((true == SpriteStudioData.UpdateGameObject(gameObject, ScriptRoot.FrameNoNow, true)) && (null != scriptPartsRootSub) && (true == FlagValidInstanceData) && (false == FlagHideForce)) { /* Show Instance */ /* MEMO: "Instance"-Parts has no mesh */ DataMeshInformation.DataMesh = null; DataMeshInformation.DataTransform = transform; DataMeshInformation.PartsInstance = this; SpriteStudioData.DrawEntryInstance(DataMeshInformation, ScriptRoot.FrameNoNow, ScriptRoot); } } if (null != scriptPartsRootSub) { Script_SpriteStudio_PartsRoot PartsOrigin = scriptPartsRootSub.PartsRootOrigin; if (null != PartsOrigin) { if (false == PartsOrigin.AnimationCheckPlay()) { /* Parent is stopped */ scriptPartsRootSub.AnimationStop(); } } } }
void LateUpdate() { /* Clear Finalize ListDrawMesh */ if (null == arrayListMeshDraw) { arrayListMeshDraw = new Library_SpriteStudio.DrawManager.ArrayListMeshDraw(); arrayListMeshDraw.BootUp(); arrayListMeshDraw.RenderQueueSet(KindRenderQueueBase, OffsetDrawQueue); } arrayListMeshDraw.Clear(); /* Collect Draw-Parts from Root-Parts */ InformationDrawObject DrawObject = null; Library_SpriteStudio.DrawManager.ArrayListMeshDraw ArrayListMeshDrawObject = null; Library_SpriteStudio.DrawManager.ListMeshDraw ListMeshDraw = null; int Count = DrawEntryPartsRoot.Count; for (int i = 0; i < Count; i++) { #if false /* MEMO: Non-Generic List-Class */ DrawObject = DrawEntryPartsRoot[i] as InformationDrawObject; #else DrawObject = DrawEntryPartsRoot[i]; #endif ArrayListMeshDrawObject = DrawObject.PartsRoot.ArrayListMeshDraw; int CountList = ArrayListMeshDrawObject.TableListMesh.Count; for (int j = 0; j < CountList; j++) { /* Add Mesh-List */ #if false /* MEMO: Non-Generic List-Class */ ListMeshDraw = ArrayListMeshDrawObject.TableListMesh[j] as Library_SpriteStudio.DrawManager.ListMeshDraw; #else ListMeshDraw = ArrayListMeshDrawObject.TableListMesh[j]; #endif arrayListMeshDraw.TableListMesh.Add(ListMeshDraw); } /* Clear Original Draw-List */ DrawObject.PartsRoot.DrawListClear(); } DrawEntryPartsRoot.Clear(); /* Collect & Add Draw-Parts "Instance"-Object's Parts */ Library_SpriteStudio.DrawManager.InformationMeshData InformationMeshData = null; Script_SpriteStudio_PartsRoot ScriptPartsRootSub = null; for (int i = 0; i < arrayListMeshDraw.TableListMesh.Count;) { #if false /* MEMO: Non-Generic List-Class */ ListMeshDraw = arrayListMeshDraw.TableListMesh[i] as Library_SpriteStudio.DrawManager.ListMeshDraw; #else ListMeshDraw = arrayListMeshDraw.TableListMesh[i]; #endif if (null == ListMeshDraw) { arrayListMeshDraw.TableListMesh.RemoveAt(i); continue; } InformationMeshData = ListMeshDraw.MeshDataTop; if (null != InformationMeshData.PartsInstance) { Library_SpriteStudio.DrawManager.ListMeshDraw ListMeshDrawSub = null; ScriptPartsRootSub = InformationMeshData.PartsInstance.ScriptPartsRootSub; if (null != ScriptPartsRootSub) { /* Add Mesh-Table */ /* Delete "Instance"-Data */ arrayListMeshDraw.TableListMesh.RemoveAt(i); /* Insert "Instance"-Data's Draw-Mesh-List */ ArrayListMeshDrawObject = ScriptPartsRootSub.ArrayListMeshDraw; for (int j = 0; j < ArrayListMeshDrawObject.TableListMesh.Count; j++) { #if false /* MEMO: Non-Generic List-Class */ ListMeshDrawSub = ArrayListMeshDrawObject.TableListMesh[j] as Library_SpriteStudio.DrawManager.ListMeshDraw; #else ListMeshDrawSub = ArrayListMeshDrawObject.TableListMesh[j]; #endif arrayListMeshDraw.TableListMesh.Insert((i + j), ListMeshDrawSub); } /* Clear Original Draw-List */ ScriptPartsRootSub.DrawListClear(); continue; } } i++; } /* Optimize Draw-Parts List */ Library_SpriteStudio.DrawManager.ListMeshDraw ListMeshDrawNext = null; #if false /* MEMO: Non-Generic List-Class */ ArrayList TableListMesh = arrayListMeshDraw.TableListMesh; #else List <Library_SpriteStudio.DrawManager.ListMeshDraw> TableListMesh = arrayListMeshDraw.TableListMesh; #endif for (int i = 0; i < (TableListMesh.Count - 1);) { Count = i + 1; /* "Count" is temporary */ #if false /* MEMO: Non-Generic List-Class */ ListMeshDraw = TableListMesh[i] as Library_SpriteStudio.DrawManager.ListMeshDraw; ListMeshDrawNext = TableListMesh[Count] as Library_SpriteStudio.DrawManager.ListMeshDraw; #else ListMeshDraw = TableListMesh[i]; ListMeshDrawNext = TableListMesh[Count]; #endif if (ListMeshDraw.MaterialOriginal == ListMeshDrawNext.MaterialOriginal) { /* Mesh-List Merge */ ListMeshDraw.ListMerge(ListMeshDrawNext); TableListMesh.RemoveAt(Count); /* Counter No-Incliment Continue */ continue; } i++; } /* Counting Meshes */ TableListMesh = arrayListMeshDraw.TableListMesh; Count = TableListMesh.Count; int CountMesh = 0; for (int i = 0; i < Count; i++) { #if false /* MEMO: Non-Generic List-Class */ ListMeshDraw = TableListMesh[i] as Library_SpriteStudio.DrawManager.ListMeshDraw; #else ListMeshDraw = TableListMesh[i]; #endif CountMesh += ListMeshDraw.Count; } /* Meshes Combine each Material & Set to MeshFilter/MeshRenderer */ MeshFilter InstanceMeshFilter = GetComponent <MeshFilter>(); MeshRenderer InstanceMeshRenderer = GetComponent <MeshRenderer>(); arrayListMeshDraw.MeshSetCombine(InstanceMeshFilter, InstanceMeshRenderer, InstanceCameraDraw, transform); }
/* ******************************************************** */ //! Draw-List Clear /*! @param InstanceGameObjectSub Instance-Data's Root-Parts @retval Return-Value (None) Don't use this function. <br> (This function is for the Link-Prefab's scripts in same GameObject.) */ internal void LinkSetPartsInstance(GameObject InstanceGameObjectSub) { InstanceGameObjectPartsRootSub = InstanceGameObjectSub; scriptPartsRootSub = InstanceGameObjectSub.GetComponent<Script_SpriteStudio_PartsRoot>(); scriptPartsRootSub.PartsRootOrigin = PartsRootGetOrigin(ScriptRoot); scriptPartsRootSub.NodeSetControl(null); }
// Update is called once per frame void Update() { //spritestudioルートクラスの取得 //spriteStudioRootを使用してアニメーションの制御を行います。 if(null == spriteStudioRoot) { int Count = transform.childCount; Transform InstanceTransformChild = null; for(int i=0; i<Count; i++) { InstanceTransformChild = transform.GetChild(i); spriteStudioRoot = InstanceTransformChild.gameObject.GetComponent<Script_SpriteStudio_PartsRoot>(); if(null != spriteStudioRoot) { //初期化 //アニメーションの終了割り込みを設定 spriteStudioRoot.FunctionPlayEnd = AnimEnd; //バッファ初期化 charinit(); break; } } } //CUP思考 move_cpu(); //アニメーションの終了を監視 if (anime_end == true) { anime_end = false; //次のモーションを設定 set_next_motion(); } // 現在位置をPositionに代入 Vector2 Position = player_pos; /* //コマンド処理 //同じ方向を2回連続で入力したらダッシュ if (GameControl.IsPushKey((int)gamemain.INPUTBUTTON.BUTTON_LEFT)) { if (dash_command_count > 0) { if (dash_oldinput_key == -1) { dash = true; } } dash_command_count = dash_command_time; dash_oldinput_key = -1; } else if (GameControl.IsPushKey((int)gamemain.INPUTBUTTON.BUTTON_RIGHT)) { if (dash_command_count > 0) { if (dash_oldinput_key == 1) { dash = true; } } dash_command_count = dash_command_time; dash_oldinput_key = 1; } dash_command_count--; if ( dash_command_count < 0 ) { dash_command_count = 0; dash_oldinput_key = 0; } */ //プレイヤーのキー入力処理 bool ismove = false; if (is_wait () == false) { if (isground == true) { // 左キーを押し続けていたら if (cpu_input_key[(int)gamemain.INPUTBUTTON.BUTTON_LEFT] != 0) { // 代入したPositionに対して加算減算を行う if (dash == true) { Position.x -= SPEED.x * 2.0f; } else { Position.x -= SPEED.x; } direction = 0; ismove = true; } else if (cpu_input_key[(int)gamemain.INPUTBUTTON.BUTTON_RIGHT] != 0) { // 右キーを押し続けていたら // 代入したPositionに対して加算減算を行う if (dash == true) { Position.x += SPEED.x * 2.0f; } else { Position.x += SPEED.x; } direction = 1; ismove = true; } if (ismove == false) { //移動入力がない場合ダッシュ終了 dash = false; } } if (cpu_input_key[(int)gamemain.INPUTBUTTON.BUTTON_UP] != 0) { // 上キーを押し続けていたら if (isground == true) { //地面にいたらジャンプを行う jump_force = 2500.0f; set_motion(AnimationType.JUMP_START); //SE再生 soundcontrol.PlaySE( sound.SE_TYPE.JUMP ); if (ismove == true) { if (dash == true) { if (direction == 0) { jump_speed = -SPEED.x * 2.0f; //ジャンプ中の移動速度 } else if (direction == 1) { jump_speed = SPEED.x * 2.0f; //ジャンプ中の移動速度 } } else { if (direction == 0) { jump_speed = -SPEED.x * 1.0f; //ジャンプ中の移動速度 } else if (direction == 1) { jump_speed = SPEED.x * 1.0f; //ジャンプ中の移動速度 } } } else { jump_speed = 0; //ジャンプ中の移動速度 } } } else if(cpu_input_key[(int)gamemain.INPUTBUTTON.BUTTON_DOWN] != 0){ // 下キーを押し続けていたら } } //ボタンを押したら攻撃 if ( (attack_wait == 0) && (is_wait () == false) ){ if (cpu_input_key[(int)gamemain.INPUTBUTTON.BUTTON_1] != 0) { // if ( ( timer % 180 ) == 0 ){ attack_wait = attack_wait_init; //攻撃の硬直時間設定値 ren_attack_count++; //連続攻撃の回数 attack_time = 0; //SE再生 soundcontrol.PlaySE( sound.SE_TYPE.ATK ); if (isground == true) { if ((ren_attack_count % 2) == 1) { set_motion (AnimationType.ATTACK1); } else { set_motion (AnimationType.ATTACK2); } } else { set_motion (AnimationType.JUMP_ATTACK1); } } } attack_wait--; if ( attack_wait < 0 ) { attack_wait = 0; } //jump制御 jump_force = jump_force - gravitiy; Position.y += ( jump_force * 0.02f ) ; if ( Position.y < ground_y ){ jump_force = 0.0f; Position.y = ground_y; if ( isground == false) { if (knockback == 0) { set_motion(AnimationType.JUMP_END); } } isground = true; }else{ if ( isground == true) { // set_motion( AnimationType.JUMP_AIR); } //空中では移動料がかかり続ける Position.x += jump_speed; isground = false; } //motion set if (is_wait () == false) { if (isground == true) { if (ismove == true) { if (dash == true) { if ( ( timer % 10 ) == 0 ) { //SE再生 soundcontrol.PlaySE( sound.SE_TYPE.RUN ); effectcontrol.CreateEffect(5, Position.x, Position.y - 0.0f ); } set_motion(AnimationType.RUN); } else { set_motion(AnimationType.WALK); } } else { if (motion != AnimationType.JUMP_END) { set_motion(AnimationType.STANCE); } } } } //ノックバック移動 if ( knockback > 0 ) { float move_x = (float)( knockback * knockback ) * 0.08f; if (direction == 0) { //左向き Position.x += move_x; } else{ //右向き Position.x -= move_x; } set_motion(AnimationType.DAMEGE); } knockback--; if ( knockback == 0 ) { //ノックバック終了 set_motion(AnimationType.STANCE); } if ( knockback < 0 ) { knockback = 0; hit_muteki = 0; } //移動範囲を設定 if (Position.x < -3000.0f) { Position.x = -3000.0f; } if (Position.x > 3000.0f) { Position.x = 3000.0f; } //向きを反映 if (direction == 0) { transform.localScale = new Vector3(init_scale, init_scale, 1.0f); //左向き制御スケール } else { transform.localScale = new Vector3(-init_scale, init_scale, 1.0f); //左向き制御スケール } // 現在の位置を設定 player_pos = Position; if ( life <= 0 ) { //死亡 set_motion(AnimationType.DEAD1); dead_count++; //ライフ if ( dead_count >= 120 ) { if ( (dead_count % 10 ) == 0 ) { Camera2DControl.SetShake( 4 ); float ex = (int)UnityEngine.Random.Range (-100, 100); float ey = (int)UnityEngine.Random.Range (-100, 100); effectcontrol.CreateEffect(2, player_pos.x + ex, player_pos.y + ey); //SE再生 if ( dead_count < 180 ) { soundcontrol.PlaySE( sound.SE_TYPE.DEAD1 ); } } } if ( dead_count >= 180 ) { Camera2DControl.SetShake( 40 ); effectcontrol.CreateEffect(4, player_pos.x, player_pos.y); soundcontrol.PlaySE( sound.SE_TYPE.DEAD2 ); dead_count = 0; charinit(); } } //コリジョンの設定 { //体 float h = 200.0f; float w = 400.0f; float xofs = 0.0f; float yofs = 250.0f; GameControl.set_collision( gamemain.COLTYPE.EN_COLTYPE_ENEMY, transform.gameObject, player_pos.x + xofs, player_pos.y + yofs, h, w, 0, 0 ); //攻撃 xofs = -300.0f; if ( direction == 1 ) { xofs = 300.0f; } switch (motion) { case AnimationType.ATTACK1: case AnimationType.ATTACK2: // case AnimationType.ATTACK3: case AnimationType.KICK1: // case AnimationType.KICK2: case AnimationType.JUMP_ATTACK1: case AnimationType.JUMP_ATTACK2: attack_time++; if ( attack_time == 20 ) { h = 300.0f; w = 300.0f; yofs = 250.0f; GameControl.set_collision( gamemain.COLTYPE.EN_COLTYPE_ENEMY_SHOT, transform.gameObject, player_pos.x + xofs, player_pos.y + yofs, h, w, 0, 0 ); } break; default: break; } } //カメラの位置から表示位置を設定 { Vector2 camerapos = Camera2DControl.GetCamera( ); transform.position = Position - camerapos; } timer++; }
void Update() { /* Get Animation-Data-Referenced */ if((null != ScriptRoot.SpriteStudioDataReferenced) && (null == spriteStudioData)) { spriteStudioData = ScriptRoot.SpriteStudioDataReferenced.DataGetNode(ID); } /* Boot-Check */ if(null == WorkArea) { WorkArea = new Library_SpriteStudio.AnimationData.WorkAreaRuntime(); } /* Clear Instance-Part's Draw-List */ DrawListClearInstance(); /* Boot-Check */ if(null == DataMeshInformation) { DataMeshInformation = new Library_SpriteStudio.DrawManager.InformationMeshData(); } if(null == InstanceGameObjectPartsRootSub) { /* Get "Instance"-Parts" */ GameObject InstanceChild = null; Transform InstanceTransformChild = null; Script_SpriteStudio_PartsRoot InstancePartsRootSub = null; int CountChild = transform.childCount; for(int i=0; i<CountChild; i++) { InstanceTransformChild = transform.GetChild(i); if(null != InstanceTransformChild) { InstanceChild = InstanceTransformChild.gameObject; InstancePartsRootSub = InstanceChild.gameObject.GetComponent<Script_SpriteStudio_PartsRoot>(); if(null != InstancePartsRootSub) { InstanceGameObjectPartsRootSub = InstanceChild; scriptPartsRootSub = InstancePartsRootSub; scriptPartsRootSub.PartsRootOrigin = PartsRootGetOrigin(ScriptRoot); break; /* Exit for-Loop */ } } } } if(null != InstanceGameObjectPartsRootSub) { /* Update User-CallBack */ spriteStudioData.UpdateUserData(ScriptRoot.FrameNoNow, gameObject, ScriptRoot); /* Update Instance-Data */ bool FlagValidInstanceData = spriteStudioData.UpdateInstanceData(ScriptRoot.FrameNoNow, gameObject, ScriptRoot, this); /* Set Matrix for Transform (to the GameObject) */ if((true == spriteStudioData.UpdateGameObject(gameObject, ScriptRoot.FrameNoNow, CollisionComponent, WorkArea)) && (null != scriptPartsRootSub) && (true == FlagValidInstanceData) && (false == FlagHideForce)) { /* Show Instance */ /* MEMO: "Instance"-Parts has no mesh */ DataMeshInformation.DataMesh = null; DataMeshInformation.DataTransform = transform; DataMeshInformation.PartsInstance = this; spriteStudioData.DrawEntryInstance(DataMeshInformation, ScriptRoot.FrameNoNow, ScriptRoot); } } if(null != scriptPartsRootSub) { Script_SpriteStudio_PartsRoot PartsOrigin = scriptPartsRootSub.PartsRootOrigin; if(null != PartsOrigin) { // if(false == PartsOrigin.AnimationCheckPlay()) if((false == PartsOrigin.AnimationCheckPlay()) && (true == scriptPartsRootSub.AnimationCheckPlay())) { /* Parent is stopped */ scriptPartsRootSub.AnimationStop(); } } } }
public void UpdateUserData(int FrameNo, GameObject GameObjectNow, Script_SpriteStudio_PartsRoot ScriptRoot) { if(0 < AnimationDataUser.Length) { if(0 != (ScriptRoot.Status & Script_SpriteStudio_PartsRoot.BitStatus.DECODE_USERDATA)) { int FrameNoPrevious = (-1 == ScriptRoot.FrameNoPrevious) ? FrameNo : ScriptRoot.FrameNoPrevious; KeyFrame.ValueUser UserData = null; /* Decoding Skipped Frame */ if(0.0f > ScriptRoot.RateTimeAnimation) { /* backwards */ if(FrameNo > FrameNoPrevious) { /* Loop */ for(int i=(FrameNoPrevious - 1); i>=ScriptRoot.FrameNoStart; i--) { UserData = AnimationDataUser[i]; if(Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } for(int i=ScriptRoot.FrameNoEnd; i>FrameNo; i--) { UserData = AnimationDataUser[i]; if(Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } } else { /* Normal */ for(int i=(FrameNoPrevious - 1); i>FrameNo; i--) { UserData = AnimationDataUser[i]; if(Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } } } else { /* foward */ if(FrameNo < FrameNoPrevious) { /* Loop */ for(int i=(FrameNoPrevious + 1); i<=ScriptRoot.FrameNoEnd; i++) { UserData = AnimationDataUser[i]; if(Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } for(int i=ScriptRoot.FrameNoStart; i<FrameNo; i++) { UserData = AnimationDataUser[i]; if(Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } } else { /* Normal */ for(int i=(FrameNoPrevious + 1); i<FrameNo; i++) { UserData = AnimationDataUser[i]; if(Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, i, UserData); } } } } /* Decoding Just-Now Frame */ UserData = AnimationDataUser[FrameNo]; if(Library_SpriteStudio.KeyFrame.ValueUser.FlagData.CLEAR != UserData.Flag) { ScriptRoot.CallBackExecUserData(GameObjectNow.name, this, FrameNo, UserData); } } } }