コード例 #1
0
 internal ComponentTweener(ComponentTweenParam param, TweenTarget target)
 {
     _param  = param;
     _target = target;
 }
コード例 #2
0
        public void OnGUIDetail(float totalTime, Type[] moduleTypes, TweenTarget target)
        {
            using (new EditorGUILayout.VerticalScope("box"))
            {
                // Time
                using (new EditorGUILayout.HorizontalScope())
                {
                    var _cacheValue = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 50;

                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        Start = EditorGUILayout.FloatField("Start", Start);
                        // bool の場合は長さを指定できない
                        if (Module == null || Module.ParamType != typeof(bool))
                        {
                            Length = EditorGUILayout.FloatField("Length", Length);
                        }

                        if (check.changed)
                        {
                            Start = Mathf.Clamp(Start, 0, totalTime);
                            if (Module == null || Module.ParamType != typeof(bool))
                            {
                                Length = Mathf.Clamp(Length, 0.01f, totalTime - Start);
                            }
                        }
                    }

                    EditorGUIUtility.labelWidth = _cacheValue;
                }

                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var index = -1;
                    if (Module != null)
                    {
                        for (var i = 0; i < moduleTypes.Length; i++)
                        {
                            if (moduleTypes[i] == Module.GetType())
                            {
                                index = i;

                                break;
                            }
                        }
                    }

                    index = EditorGUILayout.Popup("Module", index, moduleTypes.Select(t => t.Name).ToArray());
                    if (check.changed)
                    {
                        Module = (ModuleAbstract)Activator.CreateInstance(moduleTypes[index]);
                        if (Module.ParamType != typeof(bool))
                        {
                            Length = 0f;
                        }
                        BeginValue.Value = EndValue.Value = Vector4.zero;
                        Lock             = 0;
                        IsRelative       = false;
                    }
                }

                if (Module != null)
                {
                    DrawParam();
                }

                if (Module == null || Module.ParamType != typeof(bool))
                {
                    IsRelative = EditorGUILayout.Toggle("IsRelative", IsRelative);
                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        EaseType = (EaseType)EditorGUILayout.EnumPopup("EaseType", EaseType);
                        Curve    = EditorGUILayout.CurveField("Curve", Curve);

                        if (check.changed)
                        {
                            Curve = new AnimationCurve();
                            if (EaseType != EaseType.Custom)
                            {
                                for (var t = 0f; t <= 1f; t += 0.025f)
                                {
                                    Curve.AddKey(t, Ease.Eval(EaseType, t, 0f, 1f));
                                }
                            }
                        }
                    }
                }

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField("Target Objects", EditorStyles.boldLabel);
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button(EditorGUIUtility.TrIconContent("Toolbar Plus"), "RL FooterButton"))
                    {
                        ArrayUtility.Add(ref target.TargetObjects, null);
                    }
                }

                for (var i = 0; i < target.TargetObjects.Length; i++)
                {
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        target.TargetObjects[i] =
                            (GameObject)EditorGUILayout.ObjectField(target.TargetObjects[i], typeof(GameObject), true);

                        if (GUILayout.Button(EditorGUIUtility.TrIconContent("Toolbar Minus"), "RL FooterButton",
                                             GUILayout.Width(16)))
                        {
                            ArrayUtility.RemoveAt(ref target.TargetObjects, i);
                        }
                    }
                }
            }
        }