mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-20 17:26:03 +08:00
Merge branch 'feature/002_modules_via_filemods' into develop
This commit is contained in:
commit
7458d5b28f
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2018/07/13
|
// Created: 2018/07/13
|
||||||
|
|
||||||
#if DOTAUDIO
|
#if true // MODULE_MARKER
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Audio;
|
using UnityEngine.Audio;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2018/07/13
|
// Created: 2018/07/13
|
||||||
|
|
||||||
#if DOTPHYSICS
|
#if true // MODULE_MARKER
|
||||||
using System;
|
using System;
|
||||||
using DG.Tweening.Core;
|
using DG.Tweening.Core;
|
||||||
using DG.Tweening.Core.Enums;
|
using DG.Tweening.Core.Enums;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2018/07/13
|
// Created: 2018/07/13
|
||||||
|
|
||||||
#if DOTPHYSICS2D && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER)
|
#if true && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2018/07/13
|
// Created: 2018/07/13
|
||||||
|
|
||||||
#if DOTSPRITE && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER)
|
#if true && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using DG.Tweening.Core;
|
using DG.Tweening.Core;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2018/07/13
|
// Created: 2018/07/13
|
||||||
|
|
||||||
#if DOTUI && (UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER)
|
#if true && (UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|||||||
@ -46,7 +46,7 @@ namespace DG.Tweening
|
|||||||
// Called via DOTweenExternalCommand callback
|
// Called via DOTweenExternalCommand callback
|
||||||
public static void SetOrientationOnPath(PathOptions options, Tween t, Quaternion newRot, Transform trans)
|
public static void SetOrientationOnPath(PathOptions options, Tween t, Quaternion newRot, Transform trans)
|
||||||
{
|
{
|
||||||
#if DOTPHYSICS
|
#if true // PHYSICS_MARKER
|
||||||
if (options.isRigidbody) ((Rigidbody)t.target).rotation = newRot;
|
if (options.isRigidbody) ((Rigidbody)t.target).rotation = newRot;
|
||||||
else trans.rotation = newRot;
|
else trans.rotation = newRot;
|
||||||
#else
|
#else
|
||||||
@ -57,7 +57,7 @@ namespace DG.Tweening
|
|||||||
// Returns FALSE if the DOTween's Physics2D Module is disabled, or if there's no Rigidbody2D attached
|
// Returns FALSE if the DOTween's Physics2D Module is disabled, or if there's no Rigidbody2D attached
|
||||||
public static bool HasRigidbody2D(Component target)
|
public static bool HasRigidbody2D(Component target)
|
||||||
{
|
{
|
||||||
#if DOTPHYSICS2D
|
#if true // PHYSICS2D_MARKER
|
||||||
return target.GetComponent<Rigidbody2D>() != null;
|
return target.GetComponent<Rigidbody2D>() != null;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
@ -71,7 +71,7 @@ namespace DG.Tweening
|
|||||||
// Returns FALSE if the DOTween's Physics Module is disabled, or if there's no rigidbody attached
|
// Returns FALSE if the DOTween's Physics Module is disabled, or if there's no rigidbody attached
|
||||||
public static bool HasRigidbody(Component target)
|
public static bool HasRigidbody(Component target)
|
||||||
{
|
{
|
||||||
#if DOTPHYSICS
|
#if true // PHYSICS_MARKER
|
||||||
return target.GetComponent<Rigidbody>() != null;
|
return target.GetComponent<Rigidbody>() != null;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
@ -83,7 +83,7 @@ namespace DG.Tweening
|
|||||||
MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode
|
MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode
|
||||||
){
|
){
|
||||||
TweenerCore<Vector3, Path, PathOptions> t;
|
TweenerCore<Vector3, Path, PathOptions> t;
|
||||||
#if DOTPHYSICS
|
#if true // PHYSICS_MARKER
|
||||||
Rigidbody rBody = tweenRigidbody ? target.GetComponent<Rigidbody>() : null;
|
Rigidbody rBody = tweenRigidbody ? target.GetComponent<Rigidbody>() : null;
|
||||||
if (tweenRigidbody && rBody != null) {
|
if (tweenRigidbody && rBody != null) {
|
||||||
t = isLocal
|
t = isLocal
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2015/02/05 10:28
|
// Created: 2015/02/05 10:28
|
||||||
|
|
||||||
|
using System;
|
||||||
using DG.Tweening.Core.Enums;
|
using DG.Tweening.Core.Enums;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -37,9 +38,27 @@ namespace DG.Tweening.Core
|
|||||||
DemigiantDirectory
|
DemigiantDirectory
|
||||||
}
|
}
|
||||||
public SettingsLocation storeSettingsLocation = SettingsLocation.AssetsDirectory;
|
public SettingsLocation storeSettingsLocation = SettingsLocation.AssetsDirectory;
|
||||||
public bool showModulesPanel;
|
public ModulesSetup modules = new ModulesSetup();
|
||||||
|
|
||||||
// Editor-Only ► DOTween Inspector
|
// Editor-Only ► DOTween Inspector
|
||||||
public bool showPlayingTweens, showPausedTweens;
|
public bool showPlayingTweens, showPausedTweens;
|
||||||
|
|
||||||
|
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
|
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
|
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ModulesSetup // Editor-only
|
||||||
|
{
|
||||||
|
public bool showPanel;
|
||||||
|
|
||||||
|
public bool audioEnabled = true;
|
||||||
|
public bool physicsEnabled = true;
|
||||||
|
public bool physics2DEnabled = true;
|
||||||
|
public bool spriteEnabled = true;
|
||||||
|
public bool uiEnabled = true;
|
||||||
|
public bool textMeshProEnabled;
|
||||||
|
public bool tk2DEnabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ namespace DG.Tweening
|
|||||||
public class DOTween
|
public class DOTween
|
||||||
{
|
{
|
||||||
/// <summary>DOTween's version</summary>
|
/// <summary>DOTween's version</summary>
|
||||||
public static readonly string Version = "1.2.020"; // Last version before modules: 1.1.755
|
public static readonly string Version = "1.2.050"; // Last version before modules: 1.1.755
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
// Options ////////////////////////////////////
|
// Options ////////////////////////////////////
|
||||||
|
|||||||
@ -16,47 +16,38 @@ namespace DG.DOTweenEditor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
static class DOTweenDefines
|
static class DOTweenDefines
|
||||||
{
|
{
|
||||||
|
// Legacy (in versions older than 1.2.050)
|
||||||
// Modules
|
// Modules
|
||||||
public const string GlobalDefine_AudioModule = "DOTAUDIO";
|
public const string GlobalDefine_Legacy_AudioModule = "DOTAUDIO";
|
||||||
public const string GlobalDefine_PhysicsModule = "DOTPHYSICS";
|
public const string GlobalDefine_Legacy_PhysicsModule = "DOTPHYSICS";
|
||||||
public const string GlobalDefine_Physics2DModule = "DOTPHYSICS2D";
|
public const string GlobalDefine_Legacy_Physics2DModule = "DOTPHYSICS2D";
|
||||||
public const string GlobalDefine_SpriteModule = "DOTSPRITE";
|
public const string GlobalDefine_Legacy_SpriteModule = "DOTSPRITE";
|
||||||
public const string GlobalDefine_UIModule = "DOTUI";
|
public const string GlobalDefine_Legacy_UIModule = "DOTUI";
|
||||||
// External assets defines
|
// External assets defines
|
||||||
public const string GlobalDefine_TK2D = "DOTWEEN_TK2D";
|
public const string GlobalDefine_Legacy_TK2D = "DOTWEEN_TK2D";
|
||||||
public const string GlobalDefine_TextMeshPro = "DOTWEEN_TMP";
|
public const string GlobalDefine_Legacy_TextMeshPro = "DOTWEEN_TMP";
|
||||||
// Legacy (in versions older than 1.2.000)
|
// Legacy (in versions older than 1.2.000)
|
||||||
public const string GlobalDefine_Legacy_NoRigidbody = "DOTWEEN_NORBODY";
|
public const string GlobalDefine_Legacy_NoRigidbody = "DOTWEEN_NORBODY";
|
||||||
|
|
||||||
// Removes all DOTween defines including the ones for external assets
|
// Removes all DOTween defines including the ones for external assets
|
||||||
public static void RemoveAllDefines()
|
public static void RemoveAllDefines()
|
||||||
{
|
{
|
||||||
EditorUtils.RemoveGlobalDefine(GlobalDefine_AudioModule);
|
// No defines currently in use
|
||||||
EditorUtils.RemoveGlobalDefine(GlobalDefine_PhysicsModule);
|
|
||||||
EditorUtils.RemoveGlobalDefine(GlobalDefine_Physics2DModule);
|
|
||||||
EditorUtils.RemoveGlobalDefine(GlobalDefine_SpriteModule);
|
|
||||||
EditorUtils.RemoveGlobalDefine(GlobalDefine_UIModule);
|
|
||||||
|
|
||||||
EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_NoRigidbody);
|
|
||||||
|
|
||||||
EditorUtils.RemoveGlobalDefine(GlobalDefine_TK2D);
|
|
||||||
EditorUtils.RemoveGlobalDefine(GlobalDefine_TextMeshPro);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes all legacy defines
|
// Removes all legacy defines
|
||||||
public static void RemoveAllLegacyDefines()
|
public static void RemoveAllLegacyDefines()
|
||||||
{
|
{
|
||||||
EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_NoRigidbody);
|
EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_AudioModule);
|
||||||
}
|
EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_PhysicsModule);
|
||||||
|
EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_Physics2DModule);
|
||||||
|
EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_SpriteModule);
|
||||||
|
EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_UIModule);
|
||||||
|
|
||||||
// Adds all Unity Modules defines but not the ones for external assets
|
EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_NoRigidbody);
|
||||||
public static void AddAllUnityDefines()
|
|
||||||
{
|
EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_TK2D);
|
||||||
EditorUtils.AddGlobalDefine(GlobalDefine_AudioModule);
|
EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_TextMeshPro);
|
||||||
EditorUtils.AddGlobalDefine(GlobalDefine_PhysicsModule);
|
|
||||||
EditorUtils.AddGlobalDefine(GlobalDefine_Physics2DModule);
|
|
||||||
EditorUtils.AddGlobalDefine(GlobalDefine_SpriteModule);
|
|
||||||
EditorUtils.AddGlobalDefine(GlobalDefine_UIModule);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -116,13 +107,13 @@ namespace DG.DOTweenEditor
|
|||||||
// // PRO > 2DToolkit shortcuts
|
// // PRO > 2DToolkit shortcuts
|
||||||
// if (Has2DToolkit()) {
|
// if (Has2DToolkit()) {
|
||||||
// totImported += ImportAddons("Tk2d", proAddonsDir);
|
// totImported += ImportAddons("Tk2d", proAddonsDir);
|
||||||
// EditorUtils.AddGlobalDefine(GlobalDefine_TK2D);
|
// EditorUtils.AddGlobalDefine(GlobalDefine_Legacy_TK2D);
|
||||||
// } else EditorUtils.RemoveGlobalDefine(GlobalDefine_TK2D);
|
// } else EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_TK2D);
|
||||||
// // PRO > TextMeshPro shortcuts
|
// // PRO > TextMeshPro shortcuts
|
||||||
// if (HasTextMeshPro()) {
|
// if (HasTextMeshPro()) {
|
||||||
// totImported += ImportAddons("TextMeshPro", proAddonsDir);
|
// totImported += ImportAddons("TextMeshPro", proAddonsDir);
|
||||||
// EditorUtils.AddGlobalDefine(GlobalDefine_TextMeshPro);
|
// EditorUtils.AddGlobalDefine(GlobalDefine_Legacy_TextMeshPro);
|
||||||
// } else EditorUtils.RemoveGlobalDefine(GlobalDefine_TextMeshPro);
|
// } else EditorUtils.RemoveGlobalDefine(GlobalDefine_Legacy_TextMeshPro);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// SetupComplete(addonsDir, proAddonsDir, totImported);
|
// SetupComplete(addonsDir, proAddonsDir, totImported);
|
||||||
|
|||||||
@ -45,6 +45,8 @@ namespace DG.DOTweenEditor
|
|||||||
);
|
);
|
||||||
return AssetDeleteResult.DidNotDelete;
|
return AssetDeleteResult.DidNotDelete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UtilityWindowPostProcessor : AssetPostprocessor
|
public class UtilityWindowPostProcessor : AssetPostprocessor
|
||||||
@ -64,6 +66,8 @@ namespace DG.DOTweenEditor
|
|||||||
EditorUtils.DeleteOldDemiLibCore();
|
EditorUtils.DeleteOldDemiLibCore();
|
||||||
// Remove old legacy defines
|
// Remove old legacy defines
|
||||||
DOTweenDefines.RemoveAllLegacyDefines();
|
DOTweenDefines.RemoveAllLegacyDefines();
|
||||||
|
// Reapply modules
|
||||||
|
DOTweenUtilityWindowModules.ApplyModulesSettings();
|
||||||
//
|
//
|
||||||
bool differentCoreVersion = EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.Id) != Application.dataPath + DOTween.Version;
|
bool differentCoreVersion = EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.Id) != Application.dataPath + DOTween.Version;
|
||||||
bool differentProVersion = EditorUtils.hasPro && EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.IdPro) != Application.dataPath + EditorUtils.proVersion;
|
bool differentProVersion = EditorUtils.hasPro && EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.IdPro) != Application.dataPath + EditorUtils.proVersion;
|
||||||
|
|||||||
@ -131,6 +131,7 @@ namespace DG.DOTweenEditor
|
|||||||
adbDOTweenDir + "DOTween50.dll.mdb.addon",
|
adbDOTweenDir + "DOTween50.dll.mdb.addon",
|
||||||
//
|
//
|
||||||
adbDOTweenDir + "DOTweenTextMeshPro.cs.addon",
|
adbDOTweenDir + "DOTweenTextMeshPro.cs.addon",
|
||||||
|
adbDOTweenDir + "DOTweenTextMeshPro_mod.cs",
|
||||||
adbDOTweenDir + "DOTweenTk2d.cs.addon",
|
adbDOTweenDir + "DOTweenTk2d.cs.addon",
|
||||||
});
|
});
|
||||||
AssetDatabase.StopAssetEditing();
|
AssetDatabase.StopAssetEditing();
|
||||||
|
|||||||
@ -37,7 +37,7 @@ namespace DG.DOTweenEditor.UI
|
|||||||
// NOTE: this is also called via Reflection by UpgradeWindow
|
// NOTE: this is also called via Reflection by UpgradeWindow
|
||||||
public static void Open()
|
public static void Open()
|
||||||
{
|
{
|
||||||
EditorWindow window = EditorWindow.GetWindow<DOTweenUtilityWindow>(true, _Title, true);
|
DOTweenUtilityWindow window = EditorWindow.GetWindow<DOTweenUtilityWindow>(true, _Title, true);
|
||||||
window.minSize = _WinSize;
|
window.minSize = _WinSize;
|
||||||
window.maxSize = _WinSize;
|
window.maxSize = _WinSize;
|
||||||
window.ShowUtility();
|
window.ShowUtility();
|
||||||
@ -89,7 +89,7 @@ namespace DG.DOTweenEditor.UI
|
|||||||
void OnDestroy()
|
void OnDestroy()
|
||||||
{
|
{
|
||||||
if (_src != null) {
|
if (_src != null) {
|
||||||
_src.showModulesPanel = false;
|
_src.modules.showPanel = false;
|
||||||
EditorUtility.SetDirty(_src);
|
EditorUtility.SetDirty(_src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,10 +112,10 @@ namespace DG.DOTweenEditor.UI
|
|||||||
GUILayout.Space(40);
|
GUILayout.Space(40);
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
} else {
|
} else {
|
||||||
if (_src.showModulesPanel) {
|
if (_src.modules.showPanel) {
|
||||||
if (DOTweenUtilityWindowModules.Draw(this)) {
|
if (DOTweenUtilityWindowModules.Draw(this, _src)) {
|
||||||
_setupRequired = EditorUtils.DOTweenSetupRequired();
|
_setupRequired = EditorUtils.DOTweenSetupRequired();
|
||||||
_src.showModulesPanel = false;
|
_src.modules.showPanel = false;
|
||||||
EditorUtility.SetDirty(_src);
|
EditorUtility.SetDirty(_src);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -159,10 +159,11 @@ namespace DG.DOTweenEditor.UI
|
|||||||
if (GUILayout.Button("<b>Setup DOTween...</b>\n(add/remove Modules)", EditorGUIUtils.btSetup)) {
|
if (GUILayout.Button("<b>Setup DOTween...</b>\n(add/remove Modules)", EditorGUIUtils.btSetup)) {
|
||||||
// DOTweenDefines.Setup();
|
// DOTweenDefines.Setup();
|
||||||
// _setupRequired = EditorUtils.DOTweenSetupRequired();
|
// _setupRequired = EditorUtils.DOTweenSetupRequired();
|
||||||
DOTweenUtilityWindowModules.Refresh();
|
DOTweenUtilityWindowModules.ApplyModulesSettings();
|
||||||
_src.showModulesPanel = true;
|
_src.modules.showPanel = true;
|
||||||
EditorUtility.SetDirty(_src);
|
EditorUtility.SetDirty(_src);
|
||||||
EditorUtils.DeleteLegacyNoModulesDOTweenFiles();
|
EditorUtils.DeleteLegacyNoModulesDOTweenFiles();
|
||||||
|
DOTweenDefines.RemoveAllLegacyDefines();
|
||||||
EditorUtils.DeleteDOTweenUpgradeManagerFiles();
|
EditorUtils.DeleteDOTweenUpgradeManagerFiles();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -264,43 +265,91 @@ namespace DG.DOTweenEditor.UI
|
|||||||
// ===================================================================================
|
// ===================================================================================
|
||||||
// METHODS ---------------------------------------------------------------------------
|
// METHODS ---------------------------------------------------------------------------
|
||||||
|
|
||||||
void Connect(bool forceReconnect = false)
|
public static DOTweenSettings GetDOTweenSettings()
|
||||||
{
|
{
|
||||||
if (_src != null && !forceReconnect) return;
|
return ConnectToSource(null, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DOTweenSettings ConnectToSource(DOTweenSettings src, bool createIfMissing, bool fullSetup)
|
||||||
|
{
|
||||||
LocationData assetsLD = new LocationData(EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources");
|
LocationData assetsLD = new LocationData(EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources");
|
||||||
LocationData dotweenLD = new LocationData(EditorUtils.dotweenDir + "Resources");
|
LocationData dotweenLD = new LocationData(EditorUtils.dotweenDir + "Resources");
|
||||||
bool hasDemigiantDir = EditorUtils.demigiantDir != null;
|
bool hasDemigiantDir = EditorUtils.demigiantDir != null;
|
||||||
LocationData demigiantLD = hasDemigiantDir ? new LocationData(EditorUtils.demigiantDir + "Resources") : new LocationData();
|
LocationData demigiantLD = hasDemigiantDir ? new LocationData(EditorUtils.demigiantDir + "Resources") : new LocationData();
|
||||||
|
|
||||||
if (_src == null) {
|
if (src == null) {
|
||||||
// Load eventual existing settings
|
// Load eventual existing settings
|
||||||
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(assetsLD.adbFilePath, false);
|
src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(assetsLD.adbFilePath, false);
|
||||||
if (_src == null) _src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(dotweenLD.adbFilePath, false);
|
if (src == null) src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(dotweenLD.adbFilePath, false);
|
||||||
if (_src == null && hasDemigiantDir) _src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(demigiantLD.adbFilePath, false);
|
if (src == null && hasDemigiantDir) src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(demigiantLD.adbFilePath, false);
|
||||||
}
|
}
|
||||||
if (_src == null) {
|
if (src == null) {
|
||||||
// Settings don't exist. Create it in external folder
|
// Settings don't exist.
|
||||||
|
if (!createIfMissing) return null; // Stop here
|
||||||
|
// Create it in external folder
|
||||||
if (!Directory.Exists(assetsLD.dir)) AssetDatabase.CreateFolder(assetsLD.adbParentDir, "Resources");
|
if (!Directory.Exists(assetsLD.dir)) AssetDatabase.CreateFolder(assetsLD.adbParentDir, "Resources");
|
||||||
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(assetsLD.adbFilePath, true);
|
src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(assetsLD.adbFilePath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fullSetup) {
|
||||||
// Move eventual settings from previous location and setup everything correctly
|
// Move eventual settings from previous location and setup everything correctly
|
||||||
DOTweenSettings.SettingsLocation settingsLoc = _src.storeSettingsLocation;
|
DOTweenSettings.SettingsLocation settingsLoc = src.storeSettingsLocation;
|
||||||
switch (settingsLoc) {
|
switch (settingsLoc) {
|
||||||
case DOTweenSettings.SettingsLocation.AssetsDirectory:
|
case DOTweenSettings.SettingsLocation.AssetsDirectory:
|
||||||
MoveSrc(new[] { dotweenLD, demigiantLD }, assetsLD);
|
src = MoveSrc(new[] { dotweenLD, demigiantLD }, assetsLD);
|
||||||
break;
|
break;
|
||||||
case DOTweenSettings.SettingsLocation.DOTweenDirectory:
|
case DOTweenSettings.SettingsLocation.DOTweenDirectory:
|
||||||
MoveSrc(new[] { assetsLD, demigiantLD }, dotweenLD);
|
src = MoveSrc(new[] { assetsLD, demigiantLD }, dotweenLD);
|
||||||
break;
|
break;
|
||||||
case DOTweenSettings.SettingsLocation.DemigiantDirectory:
|
case DOTweenSettings.SettingsLocation.DemigiantDirectory:
|
||||||
MoveSrc(new[] { assetsLD, dotweenLD }, demigiantLD);
|
src = MoveSrc(new[] { assetsLD, dotweenLD }, demigiantLD);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveSrc(LocationData[] from, LocationData to)
|
return src;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Connect(bool forceReconnect = false)
|
||||||
|
{
|
||||||
|
if (_src != null && !forceReconnect) return;
|
||||||
|
_src = ConnectToSource(_src, true, true);
|
||||||
|
|
||||||
|
// LocationData assetsLD = new LocationData(EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources");
|
||||||
|
// LocationData dotweenLD = new LocationData(EditorUtils.dotweenDir + "Resources");
|
||||||
|
// bool hasDemigiantDir = EditorUtils.demigiantDir != null;
|
||||||
|
// LocationData demigiantLD = hasDemigiantDir ? new LocationData(EditorUtils.demigiantDir + "Resources") : new LocationData();
|
||||||
|
//
|
||||||
|
// if (_src == null) {
|
||||||
|
// // Load eventual existing settings
|
||||||
|
// _src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(assetsLD.adbFilePath, false);
|
||||||
|
// if (_src == null) _src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(dotweenLD.adbFilePath, false);
|
||||||
|
// if (_src == null && hasDemigiantDir) _src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(demigiantLD.adbFilePath, false);
|
||||||
|
// }
|
||||||
|
// if (_src == null) {
|
||||||
|
// // Settings don't exist.
|
||||||
|
// if (!createSrcIfMissing) return; // Stop here
|
||||||
|
// // Create it in external folder
|
||||||
|
// if (!Directory.Exists(assetsLD.dir)) AssetDatabase.CreateFolder(assetsLD.adbParentDir, "Resources");
|
||||||
|
// _src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(assetsLD.adbFilePath, true);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Move eventual settings from previous location and setup everything correctly
|
||||||
|
// DOTweenSettings.SettingsLocation settingsLoc = _src.storeSettingsLocation;
|
||||||
|
// switch (settingsLoc) {
|
||||||
|
// case DOTweenSettings.SettingsLocation.AssetsDirectory:
|
||||||
|
// MoveSrc(new[] { dotweenLD, demigiantLD }, assetsLD);
|
||||||
|
// break;
|
||||||
|
// case DOTweenSettings.SettingsLocation.DOTweenDirectory:
|
||||||
|
// MoveSrc(new[] { assetsLD, demigiantLD }, dotweenLD);
|
||||||
|
// break;
|
||||||
|
// case DOTweenSettings.SettingsLocation.DemigiantDirectory:
|
||||||
|
// MoveSrc(new[] { assetsLD, dotweenLD }, demigiantLD);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
static DOTweenSettings MoveSrc(LocationData[] from, LocationData to)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(to.dir)) AssetDatabase.CreateFolder(to.adbParentDir, "Resources");
|
if (!Directory.Exists(to.dir)) AssetDatabase.CreateFolder(to.adbParentDir, "Resources");
|
||||||
foreach (LocationData ld in from) {
|
foreach (LocationData ld in from) {
|
||||||
@ -315,7 +364,7 @@ namespace DG.DOTweenEditor.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(to.adbFilePath, true);
|
return EditorUtils.ConnectToSourceAsset<DOTweenSettings>(to.adbFilePath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
// License Copyright (c) Daniele Giardini
|
// License Copyright (c) Daniele Giardini
|
||||||
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using DG.Tweening.Core;
|
using DG.Tweening.Core;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -11,38 +13,44 @@ namespace DG.DOTweenEditor.UI
|
|||||||
{
|
{
|
||||||
public static class DOTweenUtilityWindowModules
|
public static class DOTweenUtilityWindowModules
|
||||||
{
|
{
|
||||||
static bool _refreshed;
|
const string ModuleMarkerId = "MODULE_MARKER";
|
||||||
static bool _hasAudioModule;
|
|
||||||
static bool _hasPhysicsModule;
|
|
||||||
static bool _hasPhysics2DModule;
|
|
||||||
static bool _hasSpriteModule;
|
|
||||||
static bool _hasUIModule;
|
|
||||||
|
|
||||||
static bool _hasTextMeshProModule;
|
static readonly ModuleInfo _audioModule = new ModuleInfo("Modules/DOTweenModuleAudio.cs", "AUDIO");
|
||||||
static bool _hasTk2DModule;
|
static readonly ModuleInfo _physicsModule = new ModuleInfo("Modules/DOTweenModulePhysics.cs", "PHYSICS");
|
||||||
|
static readonly ModuleInfo _physics2DModule = new ModuleInfo("Modules/DOTweenModulePhysics2D.cs", "PHYSICS2D");
|
||||||
|
static readonly ModuleInfo _spriteModule = new ModuleInfo("Modules/DOTweenModuleSprite.cs", "SPRITE");
|
||||||
|
static readonly ModuleInfo _uiModule = new ModuleInfo("Modules/DOTweenModuleUI.cs", "UI");
|
||||||
|
static readonly ModuleInfo _textMeshProModule = new ModuleInfo("DOTweenTextMeshPro.cs", "TEXTMESHPRO");
|
||||||
|
static readonly ModuleInfo _tk2DModule = new ModuleInfo("DOTweenTk2D.cs", "TK2D");
|
||||||
|
|
||||||
|
static readonly string _ModuleUtilsPath = "Modules/DOTweenModuleUtils.cs";
|
||||||
|
|
||||||
static EditorWindow _editor;
|
static EditorWindow _editor;
|
||||||
|
static DOTweenSettings _src;
|
||||||
|
static bool _refreshed;
|
||||||
static bool _isWaitingForCompilation;
|
static bool _isWaitingForCompilation;
|
||||||
|
static readonly List<int> _LinesToChange = new List<int>();
|
||||||
|
|
||||||
public static void Refresh()
|
static DOTweenUtilityWindowModules()
|
||||||
{
|
{
|
||||||
_refreshed = true;
|
_ModuleUtilsPath = EditorUtils.dotweenDir + _ModuleUtilsPath;
|
||||||
|
_audioModule.filePath = EditorUtils.dotweenDir + _audioModule.filePath;
|
||||||
_hasAudioModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_AudioModule);
|
_physicsModule.filePath = EditorUtils.dotweenDir + _physicsModule.filePath;
|
||||||
_hasPhysicsModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_PhysicsModule);
|
_physics2DModule.filePath = EditorUtils.dotweenDir + _physics2DModule.filePath;
|
||||||
_hasPhysics2DModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_Physics2DModule);
|
_spriteModule.filePath = EditorUtils.dotweenDir + _spriteModule.filePath;
|
||||||
_hasSpriteModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_SpriteModule);
|
_uiModule.filePath = EditorUtils.dotweenDir + _uiModule.filePath;
|
||||||
_hasUIModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_UIModule);
|
_textMeshProModule.filePath = EditorUtils.dotweenProDir + _textMeshProModule.filePath;
|
||||||
|
_tk2DModule.filePath = EditorUtils.dotweenProDir + _tk2DModule.filePath;
|
||||||
_hasTextMeshProModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_TextMeshPro);
|
|
||||||
_hasTk2DModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_TK2D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region GUI
|
||||||
|
|
||||||
// Returns TRUE if it should be closed
|
// Returns TRUE if it should be closed
|
||||||
public static bool Draw(EditorWindow editor)
|
public static bool Draw(EditorWindow editor, DOTweenSettings src)
|
||||||
{
|
{
|
||||||
_editor = editor;
|
_editor = editor;
|
||||||
if (!_refreshed) Refresh();
|
_src = src;
|
||||||
|
if (!_refreshed) Refresh(_src);
|
||||||
|
|
||||||
GUILayout.Label("Add/Remove Modules", EditorGUIUtils.titleStyle);
|
GUILayout.Label("Add/Remove Modules", EditorGUIUtils.titleStyle);
|
||||||
|
|
||||||
@ -50,17 +58,17 @@ namespace DG.DOTweenEditor.UI
|
|||||||
EditorGUI.BeginDisabledGroup(EditorApplication.isCompiling);
|
EditorGUI.BeginDisabledGroup(EditorApplication.isCompiling);
|
||||||
GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
|
GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
|
||||||
GUILayout.Label("Unity", EditorGUIUtils.boldLabelStyle);
|
GUILayout.Label("Unity", EditorGUIUtils.boldLabelStyle);
|
||||||
_hasAudioModule = EditorGUILayout.Toggle("Audio", _hasAudioModule);
|
_audioModule.enabled = EditorGUILayout.Toggle("Audio", _audioModule.enabled);
|
||||||
_hasPhysicsModule = EditorGUILayout.Toggle("Physics", _hasPhysicsModule);
|
_physicsModule.enabled = EditorGUILayout.Toggle("Physics", _physicsModule.enabled);
|
||||||
_hasPhysics2DModule = EditorGUILayout.Toggle("Physics2D", _hasPhysics2DModule);
|
_physics2DModule.enabled = EditorGUILayout.Toggle("Physics2D", _physics2DModule.enabled);
|
||||||
_hasSpriteModule = EditorGUILayout.Toggle("Sprites", _hasSpriteModule);
|
_spriteModule.enabled = EditorGUILayout.Toggle("Sprites", _spriteModule.enabled);
|
||||||
_hasUIModule = EditorGUILayout.Toggle("UI", _hasUIModule);
|
_uiModule.enabled = EditorGUILayout.Toggle("UI", _uiModule.enabled);
|
||||||
EditorGUILayout.EndVertical();
|
EditorGUILayout.EndVertical();
|
||||||
if (EditorUtils.hasPro) {
|
if (EditorUtils.hasPro) {
|
||||||
GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
|
GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
|
||||||
GUILayout.Label("External Assets (Pro)", EditorGUIUtils.boldLabelStyle);
|
GUILayout.Label("External Assets (Pro)", EditorGUIUtils.boldLabelStyle);
|
||||||
_hasTk2DModule = EditorGUILayout.Toggle("2D Toolkit", _hasTk2DModule);
|
_textMeshProModule.enabled = EditorGUILayout.Toggle("TextMesh Pro", _textMeshProModule.enabled);
|
||||||
_hasTextMeshProModule = EditorGUILayout.Toggle("TextMesh Pro", _hasTextMeshProModule);
|
_tk2DModule.enabled = EditorGUILayout.Toggle("2D Toolkit", _tk2DModule.enabled);
|
||||||
EditorGUILayout.EndVertical();
|
EditorGUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +76,7 @@ namespace DG.DOTweenEditor.UI
|
|||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
if (GUILayout.Button("Apply")) {
|
if (GUILayout.Button("Apply")) {
|
||||||
Apply();
|
Apply();
|
||||||
|
Refresh(_src);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (GUILayout.Button("Cancel")) {
|
if (GUILayout.Button("Cancel")) {
|
||||||
@ -82,29 +91,6 @@ namespace DG.DOTweenEditor.UI
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Apply()
|
|
||||||
{
|
|
||||||
ModifyDefineIfChanged(_hasAudioModule, DOTweenDefines.GlobalDefine_AudioModule);
|
|
||||||
ModifyDefineIfChanged(_hasPhysicsModule, DOTweenDefines.GlobalDefine_PhysicsModule);
|
|
||||||
ModifyDefineIfChanged(_hasPhysics2DModule, DOTweenDefines.GlobalDefine_Physics2DModule);
|
|
||||||
ModifyDefineIfChanged(_hasSpriteModule, DOTweenDefines.GlobalDefine_SpriteModule);
|
|
||||||
ModifyDefineIfChanged(_hasUIModule, DOTweenDefines.GlobalDefine_UIModule);
|
|
||||||
|
|
||||||
if (EditorUtils.hasPro) {
|
|
||||||
ModifyDefineIfChanged(_hasTextMeshProModule, DOTweenDefines.GlobalDefine_TextMeshPro);
|
|
||||||
ModifyDefineIfChanged(_hasTk2DModule, DOTweenDefines.GlobalDefine_TK2D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ModifyDefineIfChanged(bool wantsToBeSet, string defineId)
|
|
||||||
{
|
|
||||||
bool hasDefine = EditorUtils.HasGlobalDefine(defineId);
|
|
||||||
if (wantsToBeSet != hasDefine) {
|
|
||||||
if (wantsToBeSet) EditorUtils.AddGlobalDefine(defineId);
|
|
||||||
else EditorUtils.RemoveGlobalDefine(defineId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void WaitForCompilation()
|
static void WaitForCompilation()
|
||||||
{
|
{
|
||||||
if (!_isWaitingForCompilation) {
|
if (!_isWaitingForCompilation) {
|
||||||
@ -112,9 +98,6 @@ namespace DG.DOTweenEditor.UI
|
|||||||
EditorApplication.update += WaitForCompilation_Update;
|
EditorApplication.update += WaitForCompilation_Update;
|
||||||
WaitForCompilation_Update();
|
WaitForCompilation_Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rect r = GUILayoutUtility.GetLastRect();
|
|
||||||
// EditorGUI.HelpBox(r, "Waiting for Unity to finish the compilation process...", MessageType.Info);
|
|
||||||
EditorGUILayout.HelpBox("Waiting for Unity to finish the compilation process...", MessageType.Info);
|
EditorGUILayout.HelpBox("Waiting for Unity to finish the compilation process...", MessageType.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,9 +106,167 @@ namespace DG.DOTweenEditor.UI
|
|||||||
if (!EditorApplication.isCompiling) {
|
if (!EditorApplication.isCompiling) {
|
||||||
EditorApplication.update -= WaitForCompilation_Update;
|
EditorApplication.update -= WaitForCompilation_Update;
|
||||||
_isWaitingForCompilation = false;
|
_isWaitingForCompilation = false;
|
||||||
Refresh();
|
Refresh(_src);
|
||||||
}
|
}
|
||||||
_editor.Repaint();
|
_editor.Repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
// Also called via Reflection by Autorun
|
||||||
|
public static void ApplyModulesSettings()
|
||||||
|
{
|
||||||
|
DOTweenSettings src = DOTweenUtilityWindow.GetDOTweenSettings();
|
||||||
|
if (src != null) Refresh(src, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
public static void Refresh(DOTweenSettings src, bool applySrcSettings = false)
|
||||||
|
{
|
||||||
|
_src = src;
|
||||||
|
_refreshed = true;
|
||||||
|
|
||||||
|
AssetDatabase.StartAssetEditing();
|
||||||
|
_audioModule.enabled = ModuleIsEnabled(_audioModule);
|
||||||
|
_physicsModule.enabled = ModuleIsEnabled(_physicsModule);
|
||||||
|
_physics2DModule.enabled = ModuleIsEnabled(_physics2DModule);
|
||||||
|
_spriteModule.enabled = ModuleIsEnabled(_spriteModule);
|
||||||
|
_uiModule.enabled = ModuleIsEnabled(_uiModule);
|
||||||
|
//
|
||||||
|
_textMeshProModule.enabled = ModuleIsEnabled(_textMeshProModule);
|
||||||
|
_tk2DModule.enabled = ModuleIsEnabled(_tk2DModule);
|
||||||
|
|
||||||
|
CheckAutoModuleSettings(applySrcSettings, _audioModule, ref src.modules.audioEnabled);
|
||||||
|
CheckAutoModuleSettings(applySrcSettings, _physicsModule, ref src.modules.physicsEnabled);
|
||||||
|
CheckAutoModuleSettings(applySrcSettings, _physics2DModule, ref src.modules.physics2DEnabled);
|
||||||
|
CheckAutoModuleSettings(applySrcSettings, _spriteModule, ref src.modules.spriteEnabled);
|
||||||
|
CheckAutoModuleSettings(applySrcSettings, _uiModule, ref src.modules.uiEnabled);
|
||||||
|
//
|
||||||
|
CheckAutoModuleSettings(applySrcSettings, _textMeshProModule, ref src.modules.textMeshProEnabled);
|
||||||
|
CheckAutoModuleSettings(applySrcSettings, _tk2DModule, ref src.modules.tk2DEnabled);
|
||||||
|
AssetDatabase.StopAssetEditing();
|
||||||
|
|
||||||
|
EditorUtility.SetDirty(_src);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Apply()
|
||||||
|
{
|
||||||
|
AssetDatabase.StartAssetEditing();
|
||||||
|
ToggleModule(_audioModule);
|
||||||
|
ToggleModule(_physicsModule);
|
||||||
|
ToggleModule(_physics2DModule);
|
||||||
|
ToggleModule(_spriteModule);
|
||||||
|
ToggleModule(_uiModule);
|
||||||
|
|
||||||
|
if (EditorUtils.hasPro) {
|
||||||
|
ToggleModule(_textMeshProModule);
|
||||||
|
ToggleModule(_tk2DModule);
|
||||||
|
}
|
||||||
|
AssetDatabase.StopAssetEditing();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ModuleIsEnabled(ModuleInfo m)
|
||||||
|
{
|
||||||
|
if (!File.Exists(m.filePath)) return false;
|
||||||
|
|
||||||
|
using (StreamReader sr = new StreamReader(m.filePath)) {
|
||||||
|
string line = sr.ReadLine();
|
||||||
|
while (line != null) {
|
||||||
|
if (line.EndsWith(ModuleMarkerId) && line.StartsWith("#if")) return line.StartsWith("#if true");
|
||||||
|
line = sr.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CheckAutoModuleSettings(bool applySettings, ModuleInfo m, ref bool srcModuleEnabled)
|
||||||
|
{
|
||||||
|
if (m.enabled != srcModuleEnabled) {
|
||||||
|
if (applySettings) {
|
||||||
|
m.enabled = srcModuleEnabled;
|
||||||
|
ToggleModule(m);
|
||||||
|
} else {
|
||||||
|
srcModuleEnabled = m.enabled;
|
||||||
|
EditorUtility.SetDirty(_src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ToggleModule(ModuleInfo m)
|
||||||
|
{
|
||||||
|
if (!File.Exists(m.filePath)) return;
|
||||||
|
if (ModuleIsEnabled(m) == m.enabled) return; // Already set
|
||||||
|
|
||||||
|
_LinesToChange.Clear();
|
||||||
|
string[] lines = File.ReadAllLines(m.filePath);
|
||||||
|
for (int i = 0; i < lines.Length; ++i) {
|
||||||
|
string s = lines[i];
|
||||||
|
if (s.EndsWith(ModuleMarkerId) && (m.enabled && s.StartsWith("#if false") || !m.enabled && s.StartsWith("#if true"))) {
|
||||||
|
_LinesToChange.Add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_LinesToChange.Count > 0) {
|
||||||
|
using (StreamWriter sw = new StreamWriter(m.filePath)) {
|
||||||
|
for (int i = 0; i < lines.Length; ++i) {
|
||||||
|
string s = lines[i];
|
||||||
|
if (_LinesToChange.Contains(i)) {
|
||||||
|
s = m.enabled ? s.Replace("#if false", "#if true") : s.Replace("#if true", "#if false");
|
||||||
|
}
|
||||||
|
sw.WriteLine(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AssetDatabase.ImportAsset(EditorUtils.FullPathToADBPath(m.filePath), ImportAssetOptions.Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable/disable conditions inside DOTweenModuleUtils.cs
|
||||||
|
if (!File.Exists(_ModuleUtilsPath)) return;
|
||||||
|
string marker = m.id + "_MARKER";
|
||||||
|
lines = File.ReadAllLines(_ModuleUtilsPath);
|
||||||
|
_LinesToChange.Clear();
|
||||||
|
for (int i = 0; i < lines.Length; ++i) {
|
||||||
|
string s = lines[i];
|
||||||
|
if (s.EndsWith(marker) && (m.enabled && s.StartsWith("#if false") || !m.enabled && s.StartsWith("#if true"))) {
|
||||||
|
_LinesToChange.Add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_LinesToChange.Count > 0) {
|
||||||
|
using (StreamWriter sw = new StreamWriter(_ModuleUtilsPath)) {
|
||||||
|
for (int i = 0; i < lines.Length; ++i) {
|
||||||
|
string s = lines[i];
|
||||||
|
if (_LinesToChange.Contains(i)) {
|
||||||
|
s = m.enabled ? s.Replace("#if false", "#if true") : s.Replace("#if true", "#if false");
|
||||||
|
}
|
||||||
|
sw.WriteLine(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AssetDatabase.ImportAsset(EditorUtils.FullPathToADBPath(_ModuleUtilsPath), ImportAssetOptions.Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
_LinesToChange.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
|
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
|
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
|
||||||
|
|
||||||
|
class ModuleInfo
|
||||||
|
{
|
||||||
|
public bool enabled;
|
||||||
|
public string filePath;
|
||||||
|
public readonly string id; // ID is used exclusively with DOTweenModuleUtils, to determine if the line is related to this module
|
||||||
|
|
||||||
|
public ModuleInfo(string filePath, string id)
|
||||||
|
{
|
||||||
|
this.filePath = filePath;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,6 +4,7 @@
|
|||||||
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.Callbacks;
|
using UnityEditor.Callbacks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -25,12 +26,26 @@ namespace DG.DOTweenUpgradeManager
|
|||||||
|
|
||||||
public static void OnUpdate()
|
public static void OnUpdate()
|
||||||
{
|
{
|
||||||
if (!UpgradeWindowIsOpen()) UpgradeWindow.Open();
|
if (!UpgradeWindowIsOpen()) {
|
||||||
|
ApplyModulesSettings();
|
||||||
|
UpgradeWindow.Open();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool UpgradeWindowIsOpen()
|
static bool UpgradeWindowIsOpen()
|
||||||
{
|
{
|
||||||
return Resources.FindObjectsOfTypeAll<UpgradeWindow>().Length > 0;
|
return Resources.FindObjectsOfTypeAll<UpgradeWindow>().Length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ApplyModulesSettings()
|
||||||
|
{
|
||||||
|
Type doeditorT = Type.GetType("DG.DOTweenEditor.UI.DOTweenUtilityWindowModules, DOTweenEditor");
|
||||||
|
if (doeditorT != null) {
|
||||||
|
MethodInfo miOpen = doeditorT.GetMethod("ApplyModulesSettings", BindingFlags.Static | BindingFlags.Public);
|
||||||
|
if (miOpen != null) {
|
||||||
|
miOpen.Invoke(null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,8 +62,12 @@ namespace DG.DOTweenUpgradeManager
|
|||||||
GUILayout.FlexibleSpace();
|
GUILayout.FlexibleSpace();
|
||||||
if (GUILayout.Button("Open DOTween Utility Panel", GUILayout.Height(30))) {
|
if (GUILayout.Button("Open DOTween Utility Panel", GUILayout.Height(30))) {
|
||||||
Type doeditorT = Type.GetType("DG.DOTweenEditor.UI.DOTweenUtilityWindow, DOTweenEditor");
|
Type doeditorT = Type.GetType("DG.DOTweenEditor.UI.DOTweenUtilityWindow, DOTweenEditor");
|
||||||
|
if (doeditorT != null) {
|
||||||
MethodInfo miOpen = doeditorT.GetMethod("Open", BindingFlags.Static | BindingFlags.Public);
|
MethodInfo miOpen = doeditorT.GetMethod("Open", BindingFlags.Static | BindingFlags.Public);
|
||||||
|
if (miOpen != null) {
|
||||||
miOpen.Invoke(null, null);
|
miOpen.Invoke(null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
EditorApplication.update -= Autorun.OnUpdate;
|
EditorApplication.update -= Autorun.OnUpdate;
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2018/07/13
|
// Created: 2018/07/13
|
||||||
|
|
||||||
#if DOTAUDIO
|
#if true // MODULE_MARKER
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Audio;
|
using UnityEngine.Audio;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2018/07/13
|
// Created: 2018/07/13
|
||||||
|
|
||||||
#if DOTPHYSICS
|
#if true // MODULE_MARKER
|
||||||
using System;
|
using System;
|
||||||
using DG.Tweening.Core;
|
using DG.Tweening.Core;
|
||||||
using DG.Tweening.Core.Enums;
|
using DG.Tweening.Core.Enums;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2018/07/13
|
// Created: 2018/07/13
|
||||||
|
|
||||||
#if DOTPHYSICS2D && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER)
|
#if true && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2018/07/13
|
// Created: 2018/07/13
|
||||||
|
|
||||||
#if DOTSPRITE && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER)
|
#if true && (UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using DG.Tweening.Core;
|
using DG.Tweening.Core;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// Author: Daniele Giardini - http://www.demigiant.com
|
// Author: Daniele Giardini - http://www.demigiant.com
|
||||||
// Created: 2018/07/13
|
// Created: 2018/07/13
|
||||||
|
|
||||||
#if DOTUI && (UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER)
|
#if true && (UNITY_4_6 || UNITY_5 || UNITY_2017_1_OR_NEWER) // MODULE_MARKER
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|||||||
@ -46,7 +46,7 @@ namespace DG.Tweening
|
|||||||
// Called via DOTweenExternalCommand callback
|
// Called via DOTweenExternalCommand callback
|
||||||
public static void SetOrientationOnPath(PathOptions options, Tween t, Quaternion newRot, Transform trans)
|
public static void SetOrientationOnPath(PathOptions options, Tween t, Quaternion newRot, Transform trans)
|
||||||
{
|
{
|
||||||
#if DOTPHYSICS
|
#if true // PHYSICS_MARKER
|
||||||
if (options.isRigidbody) ((Rigidbody)t.target).rotation = newRot;
|
if (options.isRigidbody) ((Rigidbody)t.target).rotation = newRot;
|
||||||
else trans.rotation = newRot;
|
else trans.rotation = newRot;
|
||||||
#else
|
#else
|
||||||
@ -57,7 +57,7 @@ namespace DG.Tweening
|
|||||||
// Returns FALSE if the DOTween's Physics2D Module is disabled, or if there's no Rigidbody2D attached
|
// Returns FALSE if the DOTween's Physics2D Module is disabled, or if there's no Rigidbody2D attached
|
||||||
public static bool HasRigidbody2D(Component target)
|
public static bool HasRigidbody2D(Component target)
|
||||||
{
|
{
|
||||||
#if DOTPHYSICS2D
|
#if true // PHYSICS2D_MARKER
|
||||||
return target.GetComponent<Rigidbody2D>() != null;
|
return target.GetComponent<Rigidbody2D>() != null;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
@ -71,7 +71,7 @@ namespace DG.Tweening
|
|||||||
// Returns FALSE if the DOTween's Physics Module is disabled, or if there's no rigidbody attached
|
// Returns FALSE if the DOTween's Physics Module is disabled, or if there's no rigidbody attached
|
||||||
public static bool HasRigidbody(Component target)
|
public static bool HasRigidbody(Component target)
|
||||||
{
|
{
|
||||||
#if DOTPHYSICS
|
#if true // PHYSICS_MARKER
|
||||||
return target.GetComponent<Rigidbody>() != null;
|
return target.GetComponent<Rigidbody>() != null;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
@ -83,7 +83,7 @@ namespace DG.Tweening
|
|||||||
MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode
|
MonoBehaviour target, bool tweenRigidbody, bool isLocal, Path path, float duration, PathMode pathMode
|
||||||
){
|
){
|
||||||
TweenerCore<Vector3, Path, PathOptions> t;
|
TweenerCore<Vector3, Path, PathOptions> t;
|
||||||
#if DOTPHYSICS
|
#if true // PHYSICS_MARKER
|
||||||
Rigidbody rBody = tweenRigidbody ? target.GetComponent<Rigidbody>() : null;
|
Rigidbody rBody = tweenRigidbody ? target.GetComponent<Rigidbody>() : null;
|
||||||
if (tweenRigidbody && rBody != null) {
|
if (tweenRigidbody && rBody != null) {
|
||||||
t = isLocal
|
t = isLocal
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user