Skip to content

Commit

Permalink
Merge pull request #52 from brunomikoski/feature/DOTween-script-defin…
Browse files Browse the repository at this point in the history
…ing-symbol

Feature/do tween script defining symbol
  • Loading branch information
brunomikoski authored Aug 21, 2022
2 parents 6c6a1ca + b91e63d commit 081a713
Show file tree
Hide file tree
Showing 54 changed files with 213 additions and 46 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## [0.3.9]
### Changed
- Fixed Unity 2021 support
- Added a new setup to help dealing with projects when DOTween is not available. The AnimationSequencer will try to find the DOTween asmdef and add a scripting defining symbol `DOTWEEN_ENABLED`. Keep in mind that if you remove DOTWEEN you will have to remove the asmdef by hand.

## [0.3.8]
### Changed
Expand Down
4 changes: 3 additions & 1 deletion Scripts/Editor/Core/AnimationControllerDefaults.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DG.Tweening;
#if DOTWEEN_ENABLED
using DG.Tweening;
using UnityEngine;

namespace BrunoMikoski.AnimationSequencer
Expand Down Expand Up @@ -63,3 +64,4 @@ public sealed class AnimationControllerDefaults : EditorDefaultResourceSingleton
public int Loops => loops;
}
}
#endif
10 changes: 6 additions & 4 deletions Scripts/Editor/Core/AnimationSequencerControllerCustomEditor.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
#if DOTWEEN_ENABLED
using System;
using DG.DOTweenEditor;
using DG.Tweening;
using UnityEditor;
using UnityEditor.Experimental.SceneManagement;

using UnityEditor.IMGUI.Controls;
using UnityEditorInternal;
using UnityEngine;
Expand Down Expand Up @@ -46,7 +47,7 @@ private void OnEnable()
reorderableList.onReorderCallback += OnListOrderChanged;
reorderableList.drawHeaderCallback += OnDrawerHeader;
EditorApplication.playModeStateChanged += OnEditorPlayModeChanged;
PrefabStage.prefabSaving += PrefabSaving;
UnityEditor.SceneManagement.PrefabStage.prefabSaving += PrefabSaving;
Repaint();
}

Expand All @@ -64,7 +65,7 @@ private void OnDisable()
reorderableList.onReorderCallback -= OnListOrderChanged;
reorderableList.drawHeaderCallback -= OnDrawerHeader;
EditorApplication.playModeStateChanged -= OnEditorPlayModeChanged;
PrefabStage.prefabSaving -= PrefabSaving;
UnityEditor.SceneManagement.PrefabStage.prefabSaving -= PrefabSaving;

if (!Application.isPlaying)
{
Expand Down Expand Up @@ -649,3 +650,4 @@ private void SetDefaults()
}
}
}
#endif
61 changes: 61 additions & 0 deletions Scripts/Editor/Core/AnimationSequencerSetupHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using UnityEditor;
using UnityEditor.Compilation;
using UnityEngine;

namespace BrunoMikoski.AnimationSequencer
{
[InitializeOnLoad]
public static class AnimationSequencerSetupHelper
{
private static string SCRIPTING_DEFINE_SYMBOL = "DOTWEEN_ENABLED";
private static string DOTWEEN_ASSEMBLY_NAME = "DOTween.Modules";
static AnimationSequencerSetupHelper()
{
Assembly[] availableAssemblies = CompilationPipeline.GetAssemblies(AssembliesType.PlayerWithoutTestAssemblies);

bool foundDOTween = false;
for (int i = availableAssemblies.Length - 1; i >= 0; i--)
{
if (availableAssemblies[i].name.IndexOf(DOTWEEN_ASSEMBLY_NAME, StringComparison.Ordinal) > -1)
{
foundDOTween = true;
break;
}
}

if (foundDOTween)
{
AddScriptingDefineSymbol();
}
else
{
RemoveScriptingDefineSymbol();
Debug.LogWarning("No DOTween found, animation sequencer will be disabled until DOTween setup is complete and asmdef files are created");
}
}

private static void AddScriptingDefineSymbol()
{
string scriptingDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
if (scriptingDefineSymbols.Contains(SCRIPTING_DEFINE_SYMBOL))
return;

PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup,
$"{scriptingDefineSymbols};{SCRIPTING_DEFINE_SYMBOL}");

Debug.Log($"Adding {SCRIPTING_DEFINE_SYMBOL} for {EditorUserBuildSettings.selectedBuildTargetGroup}");
}

private static void RemoveScriptingDefineSymbol()
{
string scriptingDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
if (!scriptingDefineSymbols.Contains(SCRIPTING_DEFINE_SYMBOL))
return;

scriptingDefineSymbols = scriptingDefineSymbols.Replace(SCRIPTING_DEFINE_SYMBOL, string.Empty);
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup,
scriptingDefineSymbols);
}
}
}
3 changes: 3 additions & 0 deletions Scripts/Editor/Core/AnimationSequencerSetupHelper.cs.meta

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

4 changes: 3 additions & 1 deletion Scripts/Editor/Core/AnimationStepAdvancedDropdown.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
Expand Down Expand Up @@ -50,3 +51,4 @@ public void Show(Rect rect, Action<AnimationStepAdvancedDropdownItem> onItemSele
}
}
}
#endif
4 changes: 3 additions & 1 deletion Scripts/Editor/Core/AnimationStepAdvancedDropdownItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using UnityEditor.IMGUI.Controls;

namespace BrunoMikoski.AnimationSequencer
Expand All @@ -14,3 +15,4 @@ public AnimationStepAdvancedDropdownItem(AnimationStepBase animationStepBase, st
}
}
}
#endif
4 changes: 3 additions & 1 deletion Scripts/Editor/Core/CustomEase/CustomEaseAdvancedDropdown.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using DG.Tweening;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
Expand Down Expand Up @@ -58,3 +59,4 @@ public void Show(Rect rect, Action<CustomEaseAdvancedDropdownItem> onItemSelecte
}
}
}
#endif
4 changes: 3 additions & 1 deletion Scripts/Editor/Core/CustomEase/CustomEasePropertyDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DG.Tweening;
#if DOTWEEN_ENABLED
using DG.Tweening;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
Expand Down Expand Up @@ -78,3 +79,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
Expand Down Expand Up @@ -231,3 +232,4 @@ internal static GUIContent SaveAsDefaultButtonGUIContent
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -57,3 +58,4 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using System.Linq;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
Expand Down Expand Up @@ -104,3 +105,4 @@ private bool IsTypeAlreadyInUse(SerializedProperty actionsSerializedProperty, Ty
}
}
}
#endif
4 changes: 3 additions & 1 deletion Scripts/Editor/Core/Steps/AnimationStepBasePropertyDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -65,3 +66,4 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -216,3 +217,4 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent
}
}
}
#endif
1 change: 1 addition & 0 deletions Scripts/Runtime/BrunoMikoski.AnimationSequencer.asmdef
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "BrunoMikoski.AnimationSequencer",
"rootNamespace": "",
"references": [
"DOTween.Modules",
"Unity.TextMeshPro"
Expand Down
4 changes: 3 additions & 1 deletion Scripts/Runtime/Core/AnimationSequencerController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using System.Collections;
using DG.Tweening;
using UnityEngine;
Expand Down Expand Up @@ -404,3 +405,4 @@ public bool TryGetStepAtIndex<T>(int index, out T result) where T : AnimationSte
}
}
}
#endif
4 changes: 3 additions & 1 deletion Scripts/Runtime/Core/CustomEase/CustomEase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using BrunoMikoski.AnimationSequencer;
using DG.Tweening;
using DG.Tweening.Core.Easing;
Expand Down Expand Up @@ -127,3 +128,4 @@ public static T SetEase<T>(this T t, CustomEase customEase) where T : Tween
}
}
}
#endif
4 changes: 3 additions & 1 deletion Scripts/Runtime/Core/CustomEase/CustomEaseConstants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DG.Tweening;
#if DOTWEEN_ENABLED
using DG.Tweening;

namespace BrunoMikoski.AnimationSequencer
{
Expand Down Expand Up @@ -41,3 +42,4 @@ public partial class CustomEase
public static CustomEase InOutFlash => new CustomEase(Ease.InOutFlash);
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
Expand Down Expand Up @@ -54,3 +55,4 @@ public override void ResetToInitialState()
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using UnityEngine;

namespace BrunoMikoski.AnimationSequencer
Expand All @@ -23,3 +24,4 @@ protected override Vector2 GetPosition()
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using UnityEngine;

namespace BrunoMikoski.AnimationSequencer
Expand All @@ -22,3 +23,4 @@ protected override Vector2 GetPosition()
}
}
}
#endif
4 changes: 3 additions & 1 deletion Scripts/Runtime/Core/DOTweenActions/ColorGraphicDOTWeen.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
Expand Down Expand Up @@ -65,3 +66,4 @@ public override void ResetToInitialState()
}
}

#endif
4 changes: 3 additions & 1 deletion Scripts/Runtime/Core/DOTweenActions/DOTweenActionBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using DG.Tweening;
using UnityEngine;

Expand Down Expand Up @@ -59,3 +60,4 @@ public Tween GenerateTween(GameObject target, float duration)
public abstract void ResetToInitialState();
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
Expand Down Expand Up @@ -51,3 +52,4 @@ public override void ResetToInitialState()
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if DOTWEEN_ENABLED
using System;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
Expand Down Expand Up @@ -66,3 +67,4 @@ public override void ResetToInitialState()
}
}
}
#endif
2 changes: 2 additions & 0 deletions Scripts/Runtime/Core/DOTweenActions/FillImageDOTweenAction.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if DOTWEEN_ENABLED
using System;
using DG.Tweening;
using DG.Tweening.Core;
Expand Down Expand Up @@ -50,3 +51,4 @@ public override void ResetToInitialState()
}
}
}
#endif
Loading

0 comments on commit 081a713

Please sign in to comment.