Beispiel #1
0
        /// <summary>
        /// 全ての状態で表示する画像を設定する
        /// </summary>
        /// <param name="tName"></param>
        public bool ReplaceImage(string tName)
        {
            UIImage tImage = GetComponent <UIImage>();

            if (tImage == null || tImage.atlasSprite == null)
            {
                return(false);
            }

            Sprite tSprite = tImage.GetSpriteInAtlas(tName);

            if (tSprite == null)
            {
                return(false);
            }

            int i, l = transition.Count;

            for (i = 0; i < l; i++)
            {
                if (transition[i] != null)
                {
                    transition[i].sprite = tSprite;
                }
            }

            tImage.SetSpriteInAtlas(tName);

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// 指定の状態で表示する画像を設定する
        /// </summary>
        /// <param name="tState"></param>
        /// <param name="tName"></param>
        /// <returns></returns>
        public bool ReplaceImage(State tState, string tName)
        {
            UIImage tImage = GetComponent <UIImage>();

            if (tImage == null || tImage.atlasSprite == null)
            {
                return(false);
            }

            Sprite tSprite = tImage.GetSpriteInAtlas(tName);

            if (tSprite == null)
            {
                return(false);
            }

            int i = ( int )tState;

            if (transition[i] != null)
            {
                transition[i].sprite = tSprite;
            }

            if (m_State == tState)
            {
                tImage.SetSpriteInAtlas(tName);
            }

            return(true);
        }
Beispiel #3
0
        // スンスペクター描画
        public override void OnInspectorGUI()
        {
            // とりあえずデフォルト
            //		DrawDefaultInspector() ;

            //--------------------------------------------

            // ターゲットのインスタンス
            UITransition tTarget = target as UITransition;

            EditorGUILayout.Separator();                // 少し区切りスペース

            GUILayout.BeginHorizontal();                // 横並び
            {
                if (tTarget.transitionEnabled == false)
                {
                    GUILayout.Label("Transition Enabled" /*, GUILayout.Width( 116f ) */);
                }
                else
                {
                    tTarget.transitionFoldOut = EditorGUILayout.Foldout(tTarget.transitionFoldOut, "Transition Enabled");
                }

                bool tTransitionEnabled = EditorGUILayout.Toggle(tTarget.transitionEnabled, GUILayout.Width(24f));
                if (tTransitionEnabled != tTarget.transitionEnabled)
                {
                    Undo.RecordObject(tTarget, "UITransition : Transition Enabled Change");                             // アンドウバッファに登録
                    tTarget.transitionEnabled = tTransitionEnabled;
                    EditorUtility.SetDirty(tTarget);
                }
            }
            GUILayout.EndHorizontal();                          // 横並び終了

            if (tTarget.transitionEnabled == true && tTarget.transitionFoldOut == true)
            {
                // ワイドモードを有効にする
                bool tWideMode = EditorGUIUtility.wideMode;
                EditorGUIUtility.wideMode = true;

                //--------------------------------------------

                GUILayout.BeginHorizontal();                    // 横並び
                {
                    bool tSpriteOverwriteEnabled = EditorGUILayout.Toggle(tTarget.spriteOverwriteEnabled, GUILayout.Width(24f));
                    if (tSpriteOverwriteEnabled != tTarget.spriteOverwriteEnabled)
                    {
                        Undo.RecordObject(tTarget, "UITransition : Sprite Overwrite Enabled Change");                                   // アンドウバッファに登録
                        tTarget.spriteOverwriteEnabled = tSpriteOverwriteEnabled;
                        EditorUtility.SetDirty(tTarget);
                    }
                    GUILayout.Label("Sprite Overwrite Enabled" /*, GUILayout.Width( 116f ) */);
                }
                GUILayout.EndHorizontal();                              // 横並び終了

                // 選択中のトランジションタイプ
                UITransition.State tEditingState = (UITransition.State)EditorGUILayout.EnumPopup(" State", tTarget.editingState);
                if (tEditingState != tTarget.editingState)
                {
                    Undo.RecordObject(tTarget, "UITransition : Editing State Change");                          // アンドウバッファに登録
                    tTarget.editingState = tEditingState;
                    EditorUtility.SetDirty(tTarget);
//					UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty( UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene() ) ;
                }


                // ステートに応じた値を描画する
                int si = ( int )tTarget.editingState;

                if (tTarget.spriteOverwriteEnabled == true)
                {
                    UIImage tImage = tTarget.GetComponent <UIImage>();
                    if (tImage != null)
                    {
                        if (tImage.atlasSprite != null)
                        {
                            string[] tName = tImage.atlasSprite.GetNameList();
                            if (tName != null && tName.Length > 0)
                            {
                                if (tTarget.transition[si].sprite == null && tImage.sprite != null)
                                {
                                    Undo.RecordObject(tTarget, "UITransition : Editing State Change");                                          // アンドウバッファに登録
                                    tTarget.transition[si].sprite = tImage.sprite;
                                    EditorUtility.SetDirty(tTarget);
                                }

                                string tCurrentName = tTarget.transition[si].sprite.name;

                                int tIndexBase = -1;

                                int i, l = tName.Length;
                                for (i = 0; i < l; i++)
                                {
                                    if (tName[i] == tCurrentName)
                                    {
                                        tIndexBase = i;
                                        break;
                                    }
                                }

                                if (tIndexBase < 0)
                                {
                                    List <string> tList = new List <string>();
                                    tList.Add("Unknown");

                                    for (i = 0; i < l; i++)
                                    {
                                        tList.Add(tName[i]);
                                    }

                                    tName = tList.ToArray();

                                    tIndexBase = 0;
                                }

                                // フレーム番号
                                int tIndex = EditorGUILayout.Popup("  Selected Sprite", tIndexBase, tName);
                                if (tIndex != tIndexBase)
                                {
                                    Undo.RecordObject(tTarget, "UIImage Sprite : Change");                                              // アンドウバッファに登録
                                    tTarget.transition[si].sprite = tImage.GetSpriteInAtlas(tName[tIndex]);
                                    EditorUtility.SetDirty(tTarget);
                                    //								UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty( UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene() ) ;
                                }

                                // 確認用
                                Sprite tSprite = EditorGUILayout.ObjectField("", tImage.GetSpriteInAtlas(tName[tIndex]), typeof(Sprite), false, GUILayout.Width(60f), GUILayout.Height(60f)) as Sprite;
                                if (tSprite != tImage.GetSpriteInAtlas(tName[tIndex]))
                                {
                                }
                            }
                        }
                    }
                }

                UITransition.ProcessType tProcessType = (UITransition.ProcessType)EditorGUILayout.EnumPopup("  Process Type", tTarget.transition[si].processType);
                if (tProcessType != tTarget.transition[si].processType)
                {
                    Undo.RecordObject(tTarget, "UIButton : Process Type Change");                               // アンドウバッファに登録
                    tTarget.transition[si].processType = tProcessType;
                    EditorUtility.SetDirty(tTarget);
//					UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty( UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene() ) ;
                }

                /*			Vector3 tFadePosition = EditorGUILayout.Vector3Field( "   Fade Position",  tTarget.transition[ i ].fadePosition ) ;
                 *                      if( tFadePosition != tTarget.transition[ i ].fadePosition )
                 *                      {
                 *                              Undo.RecordObject( tTarget, "UIButton : Fade Position Change" ) ;	// アンドウバッファに登録
                 *                              tTarget.transition[ si ].fadePosition = tFadePosition ;
                 *                              EditorUtility.SetDirty( tTarget ) ;
                 *                      }*/

                Vector3 tFadeRotation = EditorGUILayout.Vector3Field("   Fade Rotation", tTarget.transition[si].fadeRotation);
                if (tFadeRotation != tTarget.transition[si].fadeRotation)
                {
                    Undo.RecordObject(tTarget, "UIButton : Fade Rotation Change");                              // アンドウバッファに登録
                    tTarget.transition[si].fadeRotation = tFadeRotation;
                    EditorUtility.SetDirty(tTarget);
                }

                Vector3 tFadeScale = EditorGUILayout.Vector3Field("   Fade Scale", tTarget.transition[si].fadeScale);
                if (tFadeScale != tTarget.transition[si].fadeScale)
                {
                    Undo.RecordObject(tTarget, "UIButton : Fade Scale    Change");                              // アンドウバッファに登録
                    tTarget.transition[si].fadeScale = tFadeScale;
                    EditorUtility.SetDirty(tTarget);
                }


                if (tTarget.transition[si].processType == UITransition.ProcessType.Ease)
                {
                    // イーズタイプ
                    UITransition.EaseType tFadeEaseType = (UITransition.EaseType)EditorGUILayout.EnumPopup("   Fade Ease Type", tTarget.transition[si].fadeEaseType);
                    if (tFadeEaseType != tTarget.transition[si].fadeEaseType)
                    {
                        Undo.RecordObject(tTarget, "UIButton : Fade Ease Type Change");                                 // アンドウバッファに登録
                        tTarget.transition[si].fadeEaseType = tFadeEaseType;
                        EditorUtility.SetDirty(tTarget);
                    }

                    DrawCurve(tTarget, tTarget.transition[si].fadeEaseType);

                    // デュアレーション
                    float tFadeDuration = EditorGUILayout.FloatField("   Fade Duration", tTarget.transition[si].fadeDuration);
                    if (tFadeDuration != tTarget.transition[si].fadeDuration)
                    {
                        Undo.RecordObject(tTarget, "UIButton : Fade Duration Change");                                  // アンドウバッファに登録
                        tTarget.transition[si].fadeDuration = tFadeDuration;
                    }
                }
                else
                if (tTarget.transition[si].processType == UITransition.ProcessType.AnimationCurve)
                {
                    tTarget.transition[si].fadeAnimationCurve = EditorGUILayout.CurveField("   Animation Curve", tTarget.transition[si].fadeAnimationCurve, GUILayout.Width(170f), GUILayout.Height(52f));

                    int      l             = tTarget.transition[si].fadeAnimationCurve.length;
                    Keyframe tKeyFrame     = tTarget.transition[si].fadeAnimationCurve[l - 1];                          // 最終キー
                    float    tFadeDuration = tKeyFrame.time;
                    EditorGUILayout.FloatField("   Fade Duration", tFadeDuration);
                }

                //--------------------------------------------

                EditorGUILayout.Separator();                    // 少し区切りスペース

                // フィニッシュの後にポーズするかどうか
                GUILayout.BeginHorizontal();                    // 横並び
                {
                    bool tPauseAfterFinished = EditorGUILayout.Toggle(tTarget.pauseAfterFinished, GUILayout.Width(24f));
                    if (tPauseAfterFinished != tTarget.pauseAfterFinished)
                    {
                        Undo.RecordObject(tTarget, "UITransition : Pause After Finished Change");                               // アンドウバッファに登録
                        tTarget.pauseAfterFinished = tPauseAfterFinished;
                        EditorUtility.SetDirty(tTarget);
                    }
                    GUILayout.Label("Pause After Finished");
                }
                GUILayout.EndHorizontal();                              // 横並び終了

                // フィニッシュの後にポーズするかどうか
                GUILayout.BeginHorizontal();                    // 横並び
                {
                    bool tColorTransmission = EditorGUILayout.Toggle(tTarget.colorTransmission, GUILayout.Width(24f));
                    if (tColorTransmission != tTarget.colorTransmission)
                    {
                        Undo.RecordObject(tTarget, "UITransition : Color Transmission Change");                                 // アンドウバッファに登録
                        tTarget.colorTransmission = tColorTransmission;
                        EditorUtility.SetDirty(tTarget);
                    }
                    GUILayout.Label("Color Transmission");
                }
                GUILayout.EndHorizontal();                              // 横並び終了



                // ポーズ状態
                GUILayout.BeginHorizontal();                    // 横並び
                {
                    bool tIsPausing = EditorGUILayout.Toggle(tTarget.isPauseing, GUILayout.Width(24f));
                    if (tIsPausing != tTarget.isPauseing)
                    {
                        Undo.RecordObject(tTarget, "UITransition : IsPausing Change");                                  // アンドウバッファに登録
                        tTarget.isPauseing = tIsPausing;
                        EditorUtility.SetDirty(tTarget);
                    }
                    GUILayout.Label("Is Pausing");
                }
                GUILayout.EndHorizontal();                              // 横並び終了

                //--------------------------------------------

                // ワイドモードを元に戻す
                EditorGUIUtility.wideMode = tWideMode;
            }
        }