Skip to content

Commit

Permalink
Feature/v0.3.0 (#9)
Browse files Browse the repository at this point in the history
* 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
gabrieldechichi authored Jul 29, 2022
1 parent 3b13aca commit 9251050
Show file tree
Hide file tree
Showing 117 changed files with 3,545 additions and 1,210 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic
Versioning](http://semver.org/spec/v2.0.0.html).

## [0.3.0] – 2022-7-28

First version with a complete State Machine Visual Editor, some small BlobAsset changes

### Added

- State Machines visual editor
- Event Editor
- Clip Previews

### Changed

- StateMachineBlobAsset has more nested arrays now, making it easier to use (performance shouldn't be impacted since nested arrays are allocated inline in BlobAssets)

## [0.2.0] – 2022-7-24

This marks the first version ready for public use and with somewhat stable API.
Expand Down
6 changes: 3 additions & 3 deletions ...chine/Parameter_Bool_IsJumping.asset.meta → Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Editor/CustomEditors.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions Editor/CustomEditors/AnimationClipAssetEditor.cs
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);
}
}
}
}
12 changes: 12 additions & 0 deletions Editor/CustomEditors/AnimationClipAssetEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions Editor/CustomEditors/RectElement.cs
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;
}
}
}
}
3 changes: 3 additions & 0 deletions Editor/CustomEditors/RectElement.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Editor/CustomEditors/StateMachineAssetEditor.cs
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();
}
}
}
}
3 changes: 3 additions & 0 deletions Editor/CustomEditors/StateMachineAssetEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Editor/CustomEditors/StateMachineSubAssetEditor.cs
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();
}
}
}
}
3 changes: 3 additions & 0 deletions Editor/CustomEditors/StateMachineSubAssetEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Editor/DMotion.Editor.asmdef
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.

Loading

0 comments on commit 9251050

Please sign in to comment.