-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
* Refactor StateMachineBlob * Create SubAssetsOnly property attribute * State Machine editor working! * Bug fixes + update samples * Raise event for all clips participating in blendin * Support end time transition * Re-add Editor scripts * Update versioning * Update samples * Make sure package works in 2020 * Remove all Undo support (either do it right or don't do it) * Make default editors for StateMachine assets readonly * Update samples * Update README * Update README again
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System.Runtime.CompilerServices; | ||
using DMotion.Authoring; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace DMotion.Editor | ||
{ | ||
[CustomEditor(typeof(AnimationClipAsset))] | ||
internal class AnimationClipAssetEditor : UnityEditor.Editor | ||
{ | ||
private SingleClipPreview preview; | ||
private AnimationClipAsset ClipTarget => (AnimationClipAsset)target; | ||
|
||
private SerializedProperty clipProperty; | ||
private AnimationEventsPropertyDrawer eventsPropertyDrawer; | ||
|
||
private void OnEnable() | ||
{ | ||
preview = new SingleClipPreview(ClipTarget.Clip); | ||
preview.Initialize(); | ||
clipProperty = serializedObject.FindProperty(nameof(AnimationClipAsset.Clip)); | ||
eventsPropertyDrawer = new AnimationEventsPropertyDrawer( | ||
ClipTarget, | ||
serializedObject.FindProperty(nameof(AnimationClipAsset.Events)), | ||
preview); | ||
} | ||
|
||
private void OnDisable() | ||
{ | ||
preview?.Dispose(); | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
using (new EditorGUILayout.HorizontalScope()) | ||
{ | ||
EditorGUILayout.LabelField("Preview Object"); | ||
preview.GameObject = (GameObject)EditorGUILayout.ObjectField(preview.GameObject, typeof(GameObject), true); | ||
} | ||
using (var c = new EditorGUI.ChangeCheckScope()) | ||
{ | ||
EditorGUILayout.PropertyField(clipProperty, true); | ||
preview.Clip = ClipTarget.Clip; | ||
|
||
if (c.changed) | ||
{ | ||
serializedObject.ApplyModifiedProperties(); | ||
serializedObject.Update(); | ||
} | ||
|
||
var drawerRect = EditorGUILayout.GetControlRect(); | ||
//TODO: This magic number is a right padding. Not why this is needed or of a better alternative | ||
drawerRect.xMax -= 60; | ||
eventsPropertyDrawer.OnInspectorGUI(drawerRect); | ||
} | ||
} | ||
|
||
public override bool HasPreviewGUI() | ||
{ | ||
return true; | ||
} | ||
|
||
public override void OnPreviewGUI(Rect r, GUIStyle background) | ||
{ | ||
if (AnimationMode.InAnimationMode()) | ||
{ | ||
preview?.DrawPreview(r, background); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using UnityEngine; | ||
|
||
namespace DMotion.Editor | ||
{ | ||
internal struct RectElement | ||
{ | ||
public Rect Rect; | ||
public float ControlWidth; | ||
public float VisualWidth; | ||
|
||
public RectElement(Rect rect, float controlWidth, float visualWidth) | ||
{ | ||
Rect = rect; | ||
ControlWidth = controlWidth; | ||
VisualWidth = visualWidth; | ||
} | ||
|
||
public Rect VisualRect | ||
{ | ||
get | ||
{ | ||
Rect.width = VisualWidth; | ||
return Rect; | ||
} | ||
} | ||
public Rect ControlRect | ||
{ | ||
get | ||
{ | ||
Rect.width = ControlWidth; | ||
return Rect; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using DMotion.Authoring; | ||
using UnityEditor; | ||
|
||
namespace DMotion.Editor | ||
{ | ||
[CustomEditor(typeof(StateMachineAsset))] | ||
internal class StateMachineAssetEditor : UnityEditor.Editor | ||
{ | ||
public override void OnInspectorGUI() | ||
{ | ||
EditorGUILayout.HelpBox("Double click the State Machine asset to open the visual editor", MessageType.Info); | ||
using (new EditorGUI.DisabledScope(true)) | ||
{ | ||
base.OnInspectorGUI(); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using DMotion.Authoring; | ||
using UnityEditor; | ||
|
||
namespace DMotion.Editor | ||
{ | ||
[CustomEditor(typeof(StateMachineSubAsset), true)] | ||
internal class StateMachineSubAssetEditor : UnityEditor.Editor | ||
{ | ||
public override void OnInspectorGUI() | ||
{ | ||
EditorGUILayout.HelpBox("You should use the Visual Editor to edit this asset.", MessageType.Warning); | ||
using (new EditorGUI.DisabledScope(true)) | ||
{ | ||
base.OnInspectorGUI(); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "DMotion.Editor", | ||
"rootNamespace": "", | ||
"references": [ | ||
"GUID:c39b61f68344c5e46ad36a286c992104" | ||
], | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.