init
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
namespace Dreamteck.Splines.Editor
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
public class ColorModifierEditor : SplineSampleModifierEditor
|
||||
{
|
||||
private float addTime = 0f;
|
||||
|
||||
public ColorModifierEditor(SplineUser user, SplineUserEditor editor, ColorModifier input) : base(user, editor, input)
|
||||
{
|
||||
module = input;
|
||||
title = "Color Modifiers";
|
||||
}
|
||||
|
||||
public void ClearSelection()
|
||||
{
|
||||
selected = -1;
|
||||
}
|
||||
|
||||
public override void DrawInspector()
|
||||
{
|
||||
base.DrawInspector();
|
||||
if (!isOpen) return;
|
||||
if (GUILayout.Button("Add New Color"))
|
||||
{
|
||||
((ColorModifier)module).AddKey(addTime - 0.1, addTime + 0.1);
|
||||
user.Rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void KeyGUI(SplineSampleModifier.Key key)
|
||||
{
|
||||
ColorModifier.ColorKey offsetKey = (ColorModifier.ColorKey)key;
|
||||
base.KeyGUI(key);
|
||||
offsetKey.color = EditorGUILayout.ColorField("Color", offsetKey.color);
|
||||
offsetKey.blendMode = (ColorModifier.ColorKey.BlendMode)EditorGUILayout.EnumPopup("Blend Mode", offsetKey.blendMode);
|
||||
}
|
||||
|
||||
protected override void KeyHandles(SplineSampleModifier.Key key, bool edit)
|
||||
{
|
||||
if (!isOpen) return;
|
||||
base.KeyHandles(key, edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4533e035e560d64aaa86e06610a58ed
|
||||
timeCreated: 1482695688
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,78 @@
|
||||
namespace Dreamteck.Splines.Editor
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
public class OffsetModifierEditor : SplineSampleModifierEditor
|
||||
{
|
||||
public bool allowSelection = true;
|
||||
private float addTime = 0f;
|
||||
Matrix4x4 matrix = new Matrix4x4();
|
||||
|
||||
public OffsetModifierEditor(SplineUser user, SplineUserEditor editor, OffsetModifier input) : base(user, editor, input)
|
||||
{
|
||||
module = input;
|
||||
title = "Offset Modifiers";
|
||||
}
|
||||
|
||||
public void ClearSelection()
|
||||
{
|
||||
selected = -1;
|
||||
}
|
||||
|
||||
public override void DrawInspector()
|
||||
{
|
||||
base.DrawInspector();
|
||||
if (!isOpen) return;
|
||||
if (GUILayout.Button("Add New Offset"))
|
||||
{
|
||||
((OffsetModifier)module).AddKey(Vector2.zero, addTime - 0.1, addTime + 0.1);
|
||||
user.Rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void KeyGUI(SplineSampleModifier.Key key)
|
||||
{
|
||||
OffsetModifier.OffsetKey offsetKey = (OffsetModifier.OffsetKey)key;
|
||||
base.KeyGUI(key);
|
||||
offsetKey.offset = EditorGUILayout.Vector2Field("Offset", offsetKey.offset);
|
||||
}
|
||||
|
||||
protected override void KeyHandles(SplineSampleModifier.Key key, bool edit)
|
||||
{
|
||||
if (!isOpen) return;
|
||||
bool is2D = user.spline != null && user.spline.is2D;
|
||||
SplineSample result = new SplineSample();
|
||||
OffsetModifier.OffsetKey offsetKey = (OffsetModifier.OffsetKey)key;
|
||||
user.spline.Evaluate(offsetKey.position, result);
|
||||
matrix.SetTRS(result.position, Quaternion.LookRotation(result.forward, result.up), Vector3.one * result.size);
|
||||
Vector3 pos = matrix.MultiplyPoint(offsetKey.offset);
|
||||
if (is2D)
|
||||
{
|
||||
Handles.DrawLine(result.position, result.position + result.right * offsetKey.offset.x * result.size);
|
||||
Handles.DrawLine(result.position, result.position - result.right * offsetKey.offset.x * result.size);
|
||||
}
|
||||
else Handles.DrawWireDisc(result.position, result.forward, offsetKey.offset.magnitude * result.size);
|
||||
Handles.DrawLine(result.position, pos);
|
||||
|
||||
if (edit)
|
||||
{
|
||||
Vector3 lastPos = pos;
|
||||
pos = SplineEditorHandles.FreeMoveRectangle(pos, HandleUtility.GetHandleSize(pos) * 0.1f);
|
||||
if (pos != lastPos)
|
||||
{
|
||||
pos = matrix.inverse.MultiplyPoint(pos);
|
||||
pos.z = 0f;
|
||||
if (is2D) offsetKey.offset = Vector2.right * pos.x;
|
||||
else offsetKey.offset = pos;
|
||||
user.Rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
base.KeyHandles(key, edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eaf21c57b8cb8f548984f66d80cfe07d
|
||||
timeCreated: 1482695688
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
namespace Dreamteck.Splines.Editor
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public class RotationModifierEditor : SplineSampleModifierEditor
|
||||
{
|
||||
public bool allowSelection = true;
|
||||
private float addTime = 0f;
|
||||
|
||||
public RotationModifierEditor(SplineUser user, SplineUserEditor parent, RotationModifier input) : base(user, parent, input)
|
||||
{
|
||||
title = "Rotation Modifiers";
|
||||
}
|
||||
|
||||
public void ClearSelection()
|
||||
{
|
||||
selected = -1;
|
||||
}
|
||||
|
||||
public override void DrawInspector()
|
||||
{
|
||||
base.DrawInspector();
|
||||
if (!isOpen) return;
|
||||
if (GUILayout.Button("Add New Rotation"))
|
||||
{
|
||||
((RotationModifier)module).AddKey(Vector3.zero, addTime - 0.1, addTime + 0.1);
|
||||
user.Rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void KeyGUI(SplineSampleModifier.Key key)
|
||||
{
|
||||
RotationModifier.RotationKey rotationKey = (RotationModifier.RotationKey)key;
|
||||
base.KeyGUI(key);
|
||||
if (!rotationKey.useLookTarget) rotationKey.rotation = EditorGUILayout.Vector3Field("Rotation", rotationKey.rotation);
|
||||
rotationKey.useLookTarget = EditorGUILayout.Toggle("Use Look Target", rotationKey.useLookTarget);
|
||||
if (rotationKey.useLookTarget) rotationKey.target = (Transform)EditorGUILayout.ObjectField("Target", rotationKey.target, typeof(Transform), true);
|
||||
}
|
||||
|
||||
protected override void KeyHandles(SplineSampleModifier.Key key, bool edit)
|
||||
{
|
||||
RotationModifier.RotationKey rotationKey = (RotationModifier.RotationKey)key;
|
||||
SplineSample result = new SplineSample();
|
||||
user.spline.Evaluate(rotationKey.position, result);
|
||||
if (rotationKey.useLookTarget)
|
||||
{
|
||||
if (rotationKey.target != null)
|
||||
{
|
||||
Handles.DrawDottedLine(result.position, rotationKey.target.position, 5f);
|
||||
if (edit)
|
||||
{
|
||||
Vector3 lastPos = rotationKey.target.position;
|
||||
rotationKey.target.position = Handles.PositionHandle(rotationKey.target.position, Quaternion.identity);
|
||||
if (lastPos != rotationKey.target.position) user.Rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Quaternion directionRot = Quaternion.LookRotation(result.forward, result.up);
|
||||
Quaternion rot = directionRot * Quaternion.Euler(rotationKey.rotation);
|
||||
SplineEditorHandles.DrawArrowCap(result.position, rot, HandleUtility.GetHandleSize(result.position));
|
||||
|
||||
if (edit)
|
||||
{
|
||||
Vector3 lastEuler = rot.eulerAngles;
|
||||
rot = Handles.RotationHandle(rot, result.position);
|
||||
rot = Quaternion.Inverse(directionRot) * rot;
|
||||
rotationKey.rotation = rot.eulerAngles;
|
||||
if (rot.eulerAngles != lastEuler) user.Rebuild();
|
||||
}
|
||||
}
|
||||
base.KeyHandles(key, edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 610b2b9894ff02a4abf2f483a19aeccc
|
||||
timeCreated: 1482695688
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace Dreamteck.Splines.Editor
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
public class SizeModifierEditor : SplineSampleModifierEditor
|
||||
{
|
||||
public bool allowSelection = true;
|
||||
private float addTime = 0f;
|
||||
|
||||
public SizeModifierEditor(SplineUser user, SplineUserEditor editor, SizeModifier input) : base(user, editor, input)
|
||||
{
|
||||
module = input;
|
||||
title = "Size Modifiers";
|
||||
}
|
||||
|
||||
public void ClearSelection()
|
||||
{
|
||||
selected = -1;
|
||||
}
|
||||
|
||||
public override void DrawInspector()
|
||||
{
|
||||
base.DrawInspector();
|
||||
if (!isOpen) return;
|
||||
if (GUILayout.Button("Add New Size"))
|
||||
{
|
||||
((SizeModifier)module).AddKey(addTime - 0.1, addTime + 0.1);
|
||||
user.Rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void KeyGUI(SplineSampleModifier.Key key)
|
||||
{
|
||||
SizeModifier.SizeKey offsetKey = (SizeModifier.SizeKey)key;
|
||||
base.KeyGUI(key);
|
||||
offsetKey.size = EditorGUILayout.FloatField("Size", offsetKey.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbfe0843022c91745a4144f758c78367
|
||||
timeCreated: 1482695688
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,147 @@
|
||||
namespace Dreamteck.Splines.Editor
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public class SplineSampleModifierEditor : SplineUserSubEditor
|
||||
{
|
||||
protected SplineSampleModifier module;
|
||||
protected int selected = -1;
|
||||
protected bool drawAllKeys = false;
|
||||
|
||||
public SplineSampleModifierEditor(SplineUser user, SplineUserEditor editor, SplineSampleModifier input) : base(user, editor)
|
||||
{
|
||||
module = input;
|
||||
title = "Tracer Module";
|
||||
}
|
||||
|
||||
public override void DrawInspector()
|
||||
{
|
||||
base.DrawInspector();
|
||||
if (!isOpen) return;
|
||||
List<SplineSampleModifier.Key> keys = module.GetKeys();
|
||||
if (keys.Count > 0) drawAllKeys = EditorGUILayout.Toggle("Draw all Modules", drawAllKeys);
|
||||
for (int i = 0; i < keys.Count; i++)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
if (selected == i)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
KeyGUI(keys[i]);
|
||||
if (EditorGUI.EndChangeCheck()) user.Rebuild();
|
||||
}
|
||||
else EditorGUILayout.LabelField(i + " [" + (Mathf.Round((float)keys[i].start * 10) / 10f) + " - " + (Mathf.Round((float)keys[i].end * 10) / 10f) + "]");
|
||||
EditorGUILayout.EndVertical();
|
||||
Rect lastRect = GUILayoutUtility.GetLastRect();
|
||||
if (lastRect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
if(Event.current.type == EventType.MouseDown)
|
||||
{
|
||||
if(Event.current.button == 0)
|
||||
{
|
||||
selected = i;
|
||||
editor.Repaint();
|
||||
} else if (Event.current.button == 1)
|
||||
{
|
||||
int index = i;
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddItem(new GUIContent("Delete"), false, delegate
|
||||
{
|
||||
keys.RemoveAt(index);
|
||||
module.SetKeys(keys);
|
||||
editor.Repaint();
|
||||
});
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (keys.Count > 0) module.blend = EditorGUILayout.Slider("Blend", module.blend, 0f, 1f);
|
||||
}
|
||||
|
||||
public override void DrawScene()
|
||||
{
|
||||
base.DrawScene();
|
||||
List<SplineSampleModifier.Key> keys = module.GetKeys();
|
||||
for (int i = 0; i < keys.Count; i++)
|
||||
{
|
||||
if(selected == i || drawAllKeys) KeyHandles(keys[i], selected == i);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void KeyGUI(SplineSampleModifier.Key key)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUIUtility.labelWidth = 50f;
|
||||
key.start = EditorGUILayout.Slider("Start", (float)key.start, 0f, 1f);
|
||||
key.end = EditorGUILayout.Slider("End", (float)key.end, 0f, 1f);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUIUtility.labelWidth = 0f;
|
||||
float centerStart = (float)key.centerStart, centerEnd = (float)key.centerEnd;
|
||||
EditorGUILayout.MinMaxSlider("Center", ref centerStart, ref centerEnd, 0f, 1f);
|
||||
key.centerStart = centerStart;
|
||||
key.centerEnd = centerEnd;
|
||||
if (key.interpolation == null) key.interpolation = AnimationCurve.Linear(0f, 0f, 1f, 1f);
|
||||
key.interpolation = EditorGUILayout.CurveField("Interpolation", key.interpolation);
|
||||
key.blend = EditorGUILayout.Slider("Blend", key.blend, 0f, 1f);
|
||||
}
|
||||
|
||||
protected virtual void KeyHandles(SplineSampleModifier.Key key, bool edit)
|
||||
{
|
||||
if (!isOpen) return;
|
||||
bool changed = false;
|
||||
double value = 0f;
|
||||
value = key.start;
|
||||
SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "Start", SplineEditorHandles.SplineSliderGizmo.ForwardTriangle, 0.8f);
|
||||
if (key.start != value)
|
||||
{
|
||||
key.start = value;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
value = key.globalCenterStart;
|
||||
SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "", SplineEditorHandles.SplineSliderGizmo.Rectangle, 0.6f);
|
||||
if (key.globalCenterStart != value)
|
||||
{
|
||||
key.globalCenterStart = value;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
value = key.globalCenterEnd;
|
||||
SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "", SplineEditorHandles.SplineSliderGizmo.Rectangle, 0.6f);
|
||||
if (key.globalCenterEnd != value)
|
||||
{
|
||||
key.globalCenterEnd = value;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
value = key.end;
|
||||
SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "End", SplineEditorHandles.SplineSliderGizmo.BackwardTriangle, 0.8f);
|
||||
if (key.end != value)
|
||||
{
|
||||
key.end = value;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
if (Event.current.control)
|
||||
{
|
||||
value = key.position;
|
||||
double lastValue = value;
|
||||
SplineEditorHandles.Slider(user.spline, ref value, user.spline.editorPathColor, "", SplineEditorHandles.SplineSliderGizmo.Circle, 0.4f);
|
||||
if (value != lastValue)
|
||||
{
|
||||
key.position = value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) user.Rebuild();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1cc10f0a74040154da18f19ce3fe2ccc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user