Skip to content

Commit

Permalink
add: meta changes and settings file
Browse files Browse the repository at this point in the history
  • Loading branch information
brunomikoski committed Sep 21, 2022
1 parent e9c30f6 commit 6717c9b
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 12 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [0.5.0]
### Changed
- Added support to control AnimationSequencer though regular unity animations, in both runtime / playtime
- Fixed issue with color tweens no working on the editor > 2021
- Added a settings menu on `Edit/Preferences/AnimationSequencer`
- You can now disable the auto foldout of the steps while previewing on the Settings

## [0.4.0]
### Changed
- Fixed Unity 2020 compability
Expand Down Expand Up @@ -185,6 +192,7 @@ Thanks for all the [suggestions](https://github.com/brunomikoski/Animation-Seque
### Added
- First initial working version

[0.5.0]: https://github.com/brunomikoski/Animation-Sequencer/releases/tag/v0.5.0
[0.4.0]: https://github.com/brunomikoski/Animation-Sequencer/releases/tag/v0.4.0
[0.3.9]: https://github.com/brunomikoski/Animation-Sequencer/releases/tag/v0.3.9
[0.3.8]: https://github.com/brunomikoski/Animation-Sequencer/releases/tag/v0.3.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ private void EditorUpdate()
{
if (Application.isPlaying)
return;

SerializedProperty progressSP = serializedObject.FindProperty("progress");
if (Mathf.Approximately(progressSP.floatValue, -1))
return;

SetProgress(progressSP.floatValue);
}

private void OnEditorPlayModeChanged(PlayModeStateChange playModeState)
{
if (playModeState == PlayModeStateChange.ExitingEditMode)
Expand Down Expand Up @@ -448,7 +448,7 @@ private void PlaySequence()
}

wasShowingStepsPanel = showStepsPanel;
showStepsPanel = false;
showStepsPanel = !AnimationSequencerSettings.GetInstance().AutoHideStepsWhenPreviewing;
}

private void DrawProgressSlider()
Expand Down
18 changes: 18 additions & 0 deletions Scripts/Editor/Core/AnimationSequencerSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using UnityEditor;
using UnityEngine;

namespace BrunoMikoski.AnimationSequencer
{
public sealed class AnimationSequencerSettings : ScriptableObjectForPreferences<AnimationSequencerSettings>
{
[SerializeField]
private bool autoHideStepsWhenPreviewing = true;
public bool AutoHideStepsWhenPreviewing => autoHideStepsWhenPreviewing;

[SettingsProvider]
private static SettingsProvider SettingsProvider()
{
return CreateSettingsProvider("Animation Sequencer", null);
}
}
}
3 changes: 3 additions & 0 deletions Scripts/Editor/Core/AnimationSequencerSettings.cs.meta

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

82 changes: 82 additions & 0 deletions Scripts/Editor/Utility/ScriptableObjectForPreferences.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace BrunoMikoski.AnimationSequencer
{
//From https://github.com/baba-s/UniScriptableObjectForPreferences/blob/master/Editor/ScriptableObjectForPreferences.cs
public abstract class ScriptableObjectForPreferences<T> : ScriptableObject
where T : ScriptableObjectForPreferences<T>
{
private static string ConfigName => typeof(T).Name;
private static T instance;

public static T GetInstance()
{
if (instance != null)
{
return instance;
}

instance = CreateInstance<T>();
string json = EditorUserSettings.GetConfigValue(ConfigName);
EditorJsonUtility.FromJsonOverwrite(json, instance);
if (instance == null)
{
instance = CreateInstance<T>();
}

return instance;
}

public static SettingsProvider CreateSettingsProvider(
string settingsProviderPath = null,
Action<SerializedObject> onGUI = null,
Action<SerializedObject> onGUIExtra = null
)
{
if (settingsProviderPath == null)
{
settingsProviderPath = $"{typeof(T).Name}";
}

T foundInstance = GetInstance();
SerializedObject serializedObject = new SerializedObject(foundInstance);
IEnumerable<string> keywords = SettingsProvider.GetSearchKeywordsFromSerializedObject(serializedObject);
SettingsProvider provider = new SettingsProvider(settingsProviderPath, SettingsScope.User, keywords);
provider.guiHandler += _ => OnGuiHandler(onGUI, onGUIExtra);
return provider;
}

private static void OnGuiHandler(Action<SerializedObject> onGUI,
Action<SerializedObject> onGUIExtra)
{
T foundInstance = GetInstance();
Editor editor = Editor.CreateEditor(foundInstance);
using (EditorGUI.ChangeCheckScope scope = new EditorGUI.ChangeCheckScope())
{
SerializedObject serializedObject = editor.serializedObject;
serializedObject.Update();
if (onGUI != null)
{
onGUI(serializedObject);
}
else
{
editor.DrawDefaultInspector();
}

onGUIExtra?.Invoke(serializedObject);
if (!scope.changed)
{
return;
}

serializedObject.ApplyModifiedProperties();
string json = EditorJsonUtility.ToJson(editor.target);
EditorUserSettings.SetConfigValue(ConfigName, json);
}
}
}
}
3 changes: 3 additions & 0 deletions Scripts/Editor/Utility/ScriptableObjectForPreferences.cs.meta

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

11 changes: 3 additions & 8 deletions Scripts/Runtime/Core/DOTweenActions/ColorGraphicDOTWeen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ public sealed class ColorGraphicDOTWeen : DOTweenActionBase

[SerializeField]
private Color color;
public Color Color
{
get => color;
set => color = value;
}

private Graphic targetGraphic;
private Color previousColor;
Expand All @@ -40,15 +35,15 @@ protected override Tweener GenerateTween_Internal(GameObject target, float durat
previousColor = targetGraphic.color;
TweenerCore<Color, Color, ColorOptions> graphicTween = targetGraphic.DOColor(color, duration);

#if UNITY_EDITOR
#if UNITY_EDITOR
if (!Application.isPlaying)
{
// Work around a Unity bug where updating the colour does not cause any visual change outside of PlayMode.
// https://forum.unity.com/threads/editor-scripting-force-color-update.798663/
graphicTween.OnUpdate(() =>
{
targetGraphic.enabled = false;
targetGraphic.enabled = true;
targetGraphic.transform.localScale = new Vector3(1.001f, 1.001f, 1.001f);
targetGraphic.transform.localScale = new Vector3(1, 1, 1);
});
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.brunomikoski.animationsequencer",
"displayName": "Animation Sequencer",
"version": "0.4.0",
"version": "0.5.0",
"unity": "2018.4",
"description": "Animation sequencer is a way to create complex animations of sequence of events by a friendly user interface. Requires DOTween v1.2.632",
"keywords": [
Expand Down

0 comments on commit 6717c9b

Please sign in to comment.