protected void DrawFlipper(UIView tTarget) { EditorGUILayout.Separator(); // 少し区切りスペース // 存在している Tween コンポーネントを取得する UIFlipper[] tFlipperArray = tTarget.GetComponents <UIFlipper>(); // 1つ以上存在していればリストとして描画する int i, l = tFlipperArray.Length, j, c; string tIdentity; string[] tFlipperIdentityArray = new string[l]; for (i = 0; i < l; i++) { tFlipperIdentityArray[i] = tFlipperArray[i].identity; } for (i = 0; i < l; i++) { // 既に同じ名前が存在する場合は番号を振る tIdentity = tFlipperIdentityArray[i]; c = 0; for (j = i + 1; j < l; j++) { if (tFlipperIdentityArray[j] == tIdentity) { // 同じ名前を発見した c++; tFlipperIdentityArray[j] = tFlipperIdentityArray[j] + "(" + c + ")"; } } } //---------------------------------------------------- if (mRemoveFlipperIndexAnswer < 0) { GUILayout.BeginHorizontal(); // 横並び開始 { bool tAdd = false; GUI.backgroundColor = Color.cyan; if (GUILayout.Button("Add Flipper", GUILayout.Width(140f)) == true) { tAdd = true; } GUI.backgroundColor = Color.white; GUI.backgroundColor = Color.cyan; mAddFlipperIdentity = EditorGUILayout.TextField("", mAddFlipperIdentity, GUILayout.Width(120f)); GUI.backgroundColor = Color.white; if (tAdd == true) { if (string.IsNullOrEmpty(mAddFlipperIdentity) == false) { // Flipper を追加する UIFlipper tFlipper = tTarget.AddComponent <UIFlipper>(); tFlipper.identity = mAddFlipperIdentity; UIFlipper[] tFlipperList = tTarget.gameObject.GetComponents <UIFlipper>(); if (tFlipperList != null && tFlipperList.Length > 0) { for (i = 0; i < tFlipperList.Length; i++) { if (tFlipperList[i] != tFlipper) { break; } } if (i < tFlipperList.Length) { // 既にトゥイーンコンポーネントがアタッチされているので enable と PlayOnAwake を false にする tFlipper.enabled = false; tFlipper.playOnAwake = false; } } } else { EditorUtility.DisplayDialog("Add Flipper", GetMessage("InputIdentity"), "Close"); } } } GUILayout.EndHorizontal(); // 横並び終了 if (tFlipperArray != null && tFlipperArray.Length > 0) { GUILayout.BeginHorizontal(); // 横並び開始 { bool tRemove = false; GUI.backgroundColor = Color.red; // ボタンの下地を緑に if (GUILayout.Button("Remove Flipper", GUILayout.Width(140f)) == true) { tRemove = true; } GUI.backgroundColor = Color.white; // ボタンの下地を緑に if (mRemoveFlipperIndex >= tFlipperIdentityArray.Length) { mRemoveFlipperIndex = tFlipperIdentityArray.Length - 1; } mRemoveFlipperIndex = EditorGUILayout.Popup("", mRemoveFlipperIndex, tFlipperIdentityArray, GUILayout.Width(120f)); // フィールド名有りタイプ if (tRemove == true) { // 削除する mRemoveFlipperIndexAnswer = mRemoveFlipperIndex; } } GUILayout.EndHorizontal(); // 横並び終了 } } else { string tMessage = GetMessage("RemoveFlipperOK?").Replace("%1", tFlipperIdentityArray[mRemoveFlipperIndexAnswer]); GUILayout.Label(tMessage); GUILayout.BeginHorizontal(); // 横並び開始 { GUI.backgroundColor = Color.red; if (GUILayout.Button("OK", GUILayout.Width(100f)) == true) { // 本当に削除する Undo.RecordObject(tTarget, "UIView : Flipper Remove"); // アンドウバッファに登録 tTarget.removeFlipperIdentity = tFlipperArray[mRemoveFlipperIndexAnswer].identity; tTarget.removeFlipperInstance = tFlipperArray[mRemoveFlipperIndexAnswer].GetInstanceID(); EditorUtility.SetDirty(tTarget); UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); mRemoveFlipperIndexAnswer = -1; } GUI.backgroundColor = Color.white; if (GUILayout.Button("Cancel", GUILayout.Width(100f)) == true) { mRemoveFlipperIndexAnswer = -1; } } GUILayout.EndHorizontal(); // 横並び終了 } }