コード例 #1
0
ファイル: UCL_TC_Data.cs プロジェクト: tim099/UCL_Tween
        public UCL_TweenerComponent CreateTweenerComponent()
        {
            var aTC = UCL_TweenerComponent.Create(m_Type);

            aTC.LoadData(this);
            return(aTC);
        }
コード例 #2
0
        public static UCL_TweenerComponent Create(TC_Type iType)
        {
            UCL_TweenerComponent aTC = null;

            switch (iType)
            {
            case TC_Type.Move: {
                aTC = UCL_TC_Move.Create();
                break;
            }

            case TC_Type.Rotate: {
                aTC = UCL_TC_Rotate.Create();
                break;
            }

            case TC_Type.LookAt: {
                aTC = UCL_TC_LookAt.Create();
                break;
            }

            case TC_Type.Curve: {
                aTC = UCL_TC_Curve.Create();
                break;
            }

            case TC_Type.Action: {
                aTC = UCL_TC_Action.Create();
                break;
            }

            case TC_Type.Shake: {
                aTC = UCL_TC_Shake.Create();
                break;
            }

            case TC_Type.Scale: {
                aTC = UCL_TC_Scale.Create();
                break;
            }

            case TC_Type.Jump: {
                aTC = UCL_TC_Jump.Create();
                break;
            }

            case TC_Type.EulerRotation:
            {
                aTC = UCL_TC_EulerRotation.Create();
                break;
            }

            case TC_Type.Color:
            {
                aTC = UCL_TC_Color.Create();
                break;
            }

            case TC_Type.TweenerComponent: {
                aTC = new UCL_TweenerComponent();
                break;
            }

            case TC_Type.RectTransform:
            {
                aTC = UCL_TC_RectTransform.Create();
                break;
            }

            default: {
                string type_name = "UCL.TweenLib.UCL_TC_" + iType.ToString();
                Type   tc_type   = Type.GetType(type_name);
                if (tc_type != null)
                {
                    aTC = Activator.CreateInstance(tc_type) as UCL_TweenerComponent;
                }
                else
                {
                    Debug.LogError("type_name:" + type_name + ", not exist!!");
                }
                break;
            }
            }
            if (aTC == null)
            {
                aTC = new UCL_TweenerComponent();
            }
            return(aTC);
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            UCL_TB_Tweener aTB = target as UCL_TB_Tweener;

            GUILayout.BeginVertical();

            var  aSerializedComponents = serializedObject.FindProperty("m_TweenerComponents");
            var  aComponents           = aTB.m_TweenerComponents;
            int  add_at        = -1;
            int  delete_at     = -1;
            bool aIsModified   = false;
            int  aChangeTypeAt = -1;

            EditorGUI.BeginChangeCheck();
            if (aComponents != null)
            {
                for (int i = 0; i < aComponents.Count; i++)
                {
                    var aTC_Data        = aComponents[i];
                    var aSerializedData = aSerializedComponents.GetArrayElementAtIndex(i);
                    var aTweenComponent = UCL_TweenerComponent.Create(aTC_Data.m_Type);
                    var aType           = aTweenComponent.GetType();

                    /*
                     * if(GUILayout.Button("Insert TweenerComponent")) {
                     *  add_at = i;
                     *  break;
                     * }
                     */
                    UnityEditor.EditorGUILayout.BeginHorizontal();
                    aTC_Data.m_Foldout = UnityEditor.EditorGUILayout.Foldout(aTC_Data.m_Foldout, aType.Name, true);

                    if (GUILayout.Button("Delete", UCL.Core.UI.UCL_GUIStyle.ButtonTextRed))
                    {
                        delete_at = i;
                        break;
                    }

                    UnityEditor.EditorGUILayout.EndHorizontal();
                    if (aTC_Data.m_Foldout)
                    {
                        aIsModified = true;
                        var aTypeData = aSerializedData.FindPropertyRelative("m_Type");
                        var aTypeEnum = aTypeData.enumValueIndex;
                        UnityEditor.EditorGUILayout.PropertyField(aTypeData);
                        if (aTypeEnum != aTypeData.enumValueIndex)//Change Type
                        {
                            aChangeTypeAt = i;
                        }
                        else
                        {
                            aTweenComponent.OnInspectorGUIBasic(aTC_Data, aSerializedData, aTB.transform);
                            if (aTweenComponent.OnInspectorGUI(aTC_Data, aSerializedData))
                            {//serializedObject
                                UCL.Core.EditorLib.EditorUtilityMapper.SetDirty(aTB);
                            }
                        }
                    }
                }
            }
            if (aIsModified)
            {
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(target, "serializedObject.ApplyModifiedProperties()");
                    serializedObject.ApplyModifiedProperties();
                }
                //Undo.RecordObject(target, "serializedObject.ApplyModifiedProperties()");

                //if(EditorGUI.EndChangeCheck()) Undo.RecordObject(target, "serializedObject.ApplyModifiedProperties()");
            }
            if (aChangeTypeAt >= 0)
            {
                Undo.RecordObject(aTB, "m_TweenerComponents.Init()" + aChangeTypeAt);
                aComponents[aChangeTypeAt].Init();
                UCL.Core.EditorLib.EditorUtilityMapper.SetDirty(aTB);
                //serializedObject.Update();
            }
            if (aTB.m_TweenerComponents == null)
            {
                aTB.m_TweenerComponents = new List <UCL_TC_Data>();
            }
            if (GUILayout.Button("Add TweenerComponent"))
            {
                add_at = aTB.m_TweenerComponents.Count;
            }
            if (add_at >= 0)
            {
                //EditorGUI.BeginChangeCheck();
                Undo.RecordObject(aTB, "m_TweenerComponents.Insert_" + add_at);
                aTB.m_TweenerComponents.Insert(add_at, UCL_TC_Data.Create());
            }
            else if (delete_at >= 0)
            {
                //EditorGUI.BeginChangeCheck();
                Undo.RecordObject(target, "m_TweenerComponents.RemoveAt_" + delete_at);
                aTB.m_TweenerComponents.RemoveAt(delete_at);
                //if(EditorGUI.EndChangeCheck()) Undo.RecordObject(target, "m_TweenerComponents.RemoveAt_"+delete_at);
            }

            GUILayout.EndVertical();
        }
コード例 #4
0
ファイル: UCL_Tweener.cs プロジェクト: tim099/UCL_Tween
 virtual public UCL_Tweener AddComponent(UCL_TweenerComponent component)
 {
     //component.p_Tweener = this;
     m_Components.Add(component);
     return(this);
 }