internal void Eval(float t) { if (_caches.Length <= 0) { return; } // 一番最初に呼ばれるタイミングで値をキャッシュする if (!_isCacheDefaultValue) { CacheDefaultValue(); _isCacheDefaultValue = true; } t = Mathf.Clamp01(t); for (var i = 0; i < _caches.Length; i++) { for (var j = 0; j < 4; j++) { if (_param.Lock.HasFlag((LockValue)(1 << (j + 1)))) { _caches[i][j] = _begins[i][j]; continue; } _caches[i][j] = Ease.Eval(EaseType.Linear, _param.Curve.Evaluate(t), _param.BeginValue[j], _param.EndValue[j]); // 相対的ならデフォ値に加算 if (_param.IsRelative) { _caches[i][j] += _begins[i][j]; } } } SetValue(_caches); }
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); } } } } }