1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 17:26:03 +08:00

Refactoring and preparing to include DOTweenUpgradeManager library

This commit is contained in:
Demigiant 2018-07-16 18:34:38 +02:00
parent 927c38fa61
commit 431cf32a39
12 changed files with 182 additions and 180 deletions

View File

@ -1,7 +1,6 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using DG.Tweening; using DG.Tweening;
using DG.Tweening.CustomYieldInstructions;
using UnityEngine; using UnityEngine;
public class CustomYieldInstructions : BrainBase public class CustomYieldInstructions : BrainBase

View File

@ -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.000"; // Last version before modules: 1.1.755 public static readonly string Version = "1.2.001"; // Last version before modules: 1.1.755
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Options //////////////////////////////////// // Options ////////////////////////////////////

View File

@ -6,7 +6,6 @@
using System; using System;
using System.IO; using System.IO;
using DG.DOTweenEditor.Core;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@ -15,7 +14,7 @@ namespace DG.DOTweenEditor
/// <summary> /// <summary>
/// Not used as menu item anymore, but as a utiity function /// Not used as menu item anymore, but as a utiity function
/// </summary> /// </summary>
static class DOTweenSetup static class DOTweenDefines
{ {
// Modules // Modules
public const string GlobalDefine_AudioModule = "DOTAUDIO"; public const string GlobalDefine_AudioModule = "DOTAUDIO";

View File

@ -73,14 +73,15 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Core\DelayedCall.cs" /> <Compile Include="DelayedCall.cs" />
<Compile Include="Core\EditorGUIUtils.cs" /> <Compile Include="UI\EditorGUIUtils.cs" />
<Compile Include="Core\EditorUtils.cs" /> <Compile Include="EditorUtils.cs" />
<Compile Include="DOTweenInspector.cs" /> <Compile Include="UI\DOTweenInspector.cs" />
<Compile Include="DOTweenModulesSetupGUI.cs" /> <Compile Include="UI\DOTweenUtilityWindowModules.cs" />
<Compile Include="DOTweenSettingsInspector.cs" /> <Compile Include="DOTweenProcessors.cs" />
<Compile Include="DOTweenSetup.cs" /> <Compile Include="UI\DOTweenSettingsInspector.cs" />
<Compile Include="DOTweenUtilityWindow.cs" /> <Compile Include="DOTweenDefines.cs" />
<Compile Include="UI\DOTweenUtilityWindow.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -0,0 +1,94 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2018/07/16 18:07
// License Copyright (c) Daniele Giardini
// This work is subject to the terms at http://dotween.demigiant.com/license.php
using System.IO;
using DG.DOTweenEditor.UI;
using DG.Tweening;
using UnityEditor;
using UnityEngine;
namespace DG.DOTweenEditor
{
public class UtilityWindowModificationProcessor : UnityEditor.AssetModificationProcessor
{
// Checks if deleted folder contains DOTween Pro and in case removes scripting define symbols
static AssetDeleteResult OnWillDeleteAsset(string asset, RemoveAssetOptions options)
{
// Check if asset is a directory
string dir = EditorUtils.ADBPathToFullPath(asset);
if (!Directory.Exists(dir)) return AssetDeleteResult.DidNotDelete;
// Check if directory contains DOTween.dll
string[] files = Directory.GetFiles(dir, "DOTween.dll", SearchOption.AllDirectories);
int len = files.Length;
bool containsDOTween = false;
for (int i = 0; i < len; ++i) {
if (!files[i].EndsWith("DOTween.dll")) continue;
containsDOTween = true;
break;
}
if (!containsDOTween) return AssetDeleteResult.DidNotDelete;
Debug.Log("::: DOTween deleted");
// DOTween is being deleted: deal with it
// Remove EditorPrefs
EditorPrefs.DeleteKey(Application.dataPath + DOTweenUtilityWindow.Id);
EditorPrefs.DeleteKey(Application.dataPath + DOTweenUtilityWindow.IdPro);
// Remove scripting define symbols
DOTweenDefines.RemoveAllDefines();
//
EditorUtility.DisplayDialog("DOTween Deleted",
"DOTween was deleted and all of its scripting define symbols removed." +
"\n\nThis might show an error depending on your previous setup." +
" If this happens, please close and reopen Unity or reimport DOTween.",
"Ok"
);
return AssetDeleteResult.DidNotDelete;
}
}
public class UtilityWindowPostProcessor : AssetPostprocessor
{
static bool _setupDialogRequested; // Used to prevent OnPostProcessAllAssets firing twice (because of a Unity bug/feature)
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
Debug.Log("OnPostprocessAllAssets");
if (_setupDialogRequested) return;
string[] dotweenEntries = System.Array.FindAll(importedAssets, name => name.Contains("DOTween") && !name.EndsWith(".meta") && !name.EndsWith(".jpg") && !name.EndsWith(".png"));
bool dotweenImported = dotweenEntries.Length > 0;
if (dotweenImported) {
// Delete old DOTween files
EditorUtils.DeleteLegacyNoModulesDOTweenFiles();
// Delete old DemiLib configuration
EditorUtils.DeleteOldDemiLibCore();
// Remove old legacy defines
DOTweenDefines.RemoveAllLegacyDefines();
//
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 setupRequired = differentCoreVersion || differentProVersion;
if (setupRequired) {
_setupDialogRequested = true;
EditorPrefs.SetString(Application.dataPath + DOTweenUtilityWindow.Id, Application.dataPath + DOTween.Version);
if (EditorUtils.hasPro) EditorPrefs.SetString(Application.dataPath + DOTweenUtilityWindow.IdPro, Application.dataPath + EditorUtils.proVersion);
EditorUtility.DisplayDialog("DOTween",
differentCoreVersion
? "New version of DOTween imported." +
"\n\nSelect \"Setup DOTween...\" in DOTween's Utility Panel to add/remove Modules."
: "New version of DOTween Pro imported." +
" \n\nSelect \"Setup DOTween...\" in DOTween's Utility Panel to add/remove external Modules (TextMesh Pro/2DToolkit/etc).",
"Ok"
);
DOTweenUtilityWindow.Open();
// Opening window after a postProcess doesn't work on Unity 3 so check that
// string[] vs = Application.unityVersion.Split("."[0]);
// int majorVersion = System.Convert.ToInt32(vs[0]);
// if (majorVersion >= 4) EditorUtils.DelayedCall(0.5f, DOTweenUtilityWindow.Open);
// EditorUtils.DelayedCall(8, ()=> _setupDialogRequested = false);
}
}
}
}
}

View File

@ -5,7 +5,7 @@ using System;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
namespace DG.DOTweenEditor.Core namespace DG.DOTweenEditor
{ {
public class DelayedCall public class DelayedCall
{ {

View File

@ -2,15 +2,14 @@
// Created: 2014/12/24 13:50 // Created: 2014/12/24 13:50
using System; using System;
using System.Collections;
using System.Reflection;
using System.IO; using System.IO;
using System.Reflection;
using System.Text; using System.Text;
using DG.Tweening; using DG.Tweening;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
namespace DG.DOTweenEditor.Core namespace DG.DOTweenEditor
{ {
public static class EditorUtils public static class EditorUtils
{ {
@ -96,28 +95,29 @@ namespace DG.DOTweenEditor.Core
{ {
string adbDOTweenDir = FullPathToADBPath(dotweenDir); string adbDOTweenDir = FullPathToADBPath(dotweenDir);
AssetDatabase.StartAssetEditing(); AssetDatabase.StartAssetEditing();
Debug.Log(adbDOTweenDir + "DOTween43.dll");
DeleteAssetsIfExist(new[] { DeleteAssetsIfExist(new[] {
adbDOTweenDir + "/DOTween43.dll", adbDOTweenDir + "DOTween43.dll",
adbDOTweenDir + "/DOTween43.xml", adbDOTweenDir + "DOTween43.xml",
adbDOTweenDir + "/DOTween43.dll.mdb", adbDOTweenDir + "DOTween43.dll.mdb",
adbDOTweenDir + "/DOTween43.dll.addon", adbDOTweenDir + "DOTween43.dll.addon",
adbDOTweenDir + "/DOTween43.xml.addon", adbDOTweenDir + "DOTween43.xml.addon",
adbDOTweenDir + "/DOTween43.dll.mdb.addon", adbDOTweenDir + "DOTween43.dll.mdb.addon",
adbDOTweenDir + "/DOTween46.dll", adbDOTweenDir + "DOTween46.dll",
adbDOTweenDir + "/DOTween46.xml", adbDOTweenDir + "DOTween46.xml",
adbDOTweenDir + "/DOTween46.dll.mdb", adbDOTweenDir + "DOTween46.dll.mdb",
adbDOTweenDir + "/DOTween46.dll.addon", adbDOTweenDir + "DOTween46.dll.addon",
adbDOTweenDir + "/DOTween46.xml.addon", adbDOTweenDir + "DOTween46.xml.addon",
adbDOTweenDir + "/DOTween46.dll.mdb.addon", adbDOTweenDir + "DOTween46.dll.mdb.addon",
adbDOTweenDir + "/DOTween50.dll", adbDOTweenDir + "DOTween50.dll",
adbDOTweenDir + "/DOTween50.xml", adbDOTweenDir + "DOTween50.xml",
adbDOTweenDir + "/DOTween50.dll.mdb", adbDOTweenDir + "DOTween50.dll.mdb",
adbDOTweenDir + "/DOTween50.dll.addon", adbDOTweenDir + "DOTween50.dll.addon",
adbDOTweenDir + "/DOTween50.xml.addon", adbDOTweenDir + "DOTween50.xml.addon",
adbDOTweenDir + "/DOTween50.dll.mdb.addon", adbDOTweenDir + "DOTween50.dll.mdb.addon",
// //
adbDOTweenDir + "/DOTweenTextMeshPro.cs.addon", adbDOTweenDir + "DOTweenTextMeshPro.cs.addon",
adbDOTweenDir + "/DOTweenTk2d.cs.addon", adbDOTweenDir + "DOTweenTk2d.cs.addon",
}); });
AssetDatabase.StopAssetEditing(); AssetDatabase.StopAssetEditing();
} }

View File

@ -4,17 +4,13 @@
// 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;
using System.Collections.Generic;
using System.Reflection;
using System.Text; using System.Text;
using DG.DOTweenEditor.Core;
using DG.Tweening; using DG.Tweening;
using DG.Tweening.Core; using DG.Tweening.Core;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
namespace DG.DOTweenEditor namespace DG.DOTweenEditor.UI
{ {
[CustomEditor(typeof(DOTweenComponent))] [CustomEditor(typeof(DOTweenComponent))]
public class DOTweenInspector : Editor public class DOTweenInspector : Editor

View File

@ -3,9 +3,8 @@
using DG.Tweening.Core; using DG.Tweening.Core;
using UnityEditor; using UnityEditor;
using UnityEngine;
namespace DG.DOTweenEditor namespace DG.DOTweenEditor.UI
{ {
[CustomEditor(typeof(DOTweenSettings))] [CustomEditor(typeof(DOTweenSettings))]
public class DOTweenSettingsInspector : Editor public class DOTweenSettingsInspector : Editor
@ -22,11 +21,11 @@ namespace DG.DOTweenEditor
override public void OnInspectorGUI() override public void OnInspectorGUI()
{ {
GUI.enabled = false; UnityEngine.GUI.enabled = false;
DrawDefaultInspector(); DrawDefaultInspector();
GUI.enabled = true; UnityEngine.GUI.enabled = true;
} }
} }
} }

View File

@ -2,100 +2,14 @@
// Created: 2014/12/24 13:37 // Created: 2014/12/24 13:37
using System.IO; using System.IO;
using System.Reflection;
using DG.DOTweenEditor.Core;
using DG.Tweening; using DG.Tweening;
using DG.Tweening.Core; using DG.Tweening.Core;
using DG.Tweening.Core.Enums; using DG.Tweening.Core.Enums;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
namespace DG.DOTweenEditor namespace DG.DOTweenEditor.UI
{ {
public class UtilityWindowModificationProcessor : UnityEditor.AssetModificationProcessor
{
// Checks if deleted folder contains DOTween Pro and in case removes scripting define symbols
static AssetDeleteResult OnWillDeleteAsset(string asset, RemoveAssetOptions options)
{
// Check if asset is a directory
string dir = EditorUtils.ADBPathToFullPath(asset);
if (!Directory.Exists(dir)) return AssetDeleteResult.DidNotDelete;
// Check if directory contains DOTween.dll
string[] files = Directory.GetFiles(dir, "DOTween.dll", SearchOption.AllDirectories);
int len = files.Length;
bool containsDOTween = false;
for (int i = 0; i < len; ++i) {
if (!files[i].EndsWith("DOTween.dll")) continue;
containsDOTween = true;
break;
}
if (!containsDOTween) return AssetDeleteResult.DidNotDelete;
Debug.Log("::: DOTween deleted");
// DOTween is being deleted: deal with it
// Remove EditorPrefs
EditorPrefs.DeleteKey(Application.dataPath + DOTweenUtilityWindow.Id);
EditorPrefs.DeleteKey(Application.dataPath + DOTweenUtilityWindow.IdPro);
// Remove scripting define symbols
DOTweenSetup.RemoveAllDefines();
//
EditorUtility.DisplayDialog("DOTween Deleted",
"DOTween was deleted and all of its scripting define symbols removed." +
"\n\nThis might show an error depending on your previous setup." +
" If this happens, please close and reopen Unity or reimport DOTween.",
"Ok"
);
return AssetDeleteResult.DidNotDelete;
}
}
public class UtilityWindowPostProcessor : AssetPostprocessor
{
static bool _setupDialogRequested; // Used to prevent OnPostProcessAllAssets firing twice (because of a Unity bug/feature)
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
Debug.Log("::::::::::::::::::::: OnPostprocessAllAssets :::::::::::::::::::::::::::::");
if (_setupDialogRequested) return;
string[] dotweenEntries = System.Array.FindAll(importedAssets, name => name.Contains("DOTween") && !name.EndsWith(".meta") && !name.EndsWith(".jpg") && !name.EndsWith(".png"));
bool dotweenImported = dotweenEntries.Length > 0;
Debug.Log("::: DOTween imported: " + dotweenImported);
if (dotweenImported) {
// Delete old DOTween files
EditorUtils.DeleteLegacyNoModulesDOTweenFiles();
// Delete old DemiLib configuration
EditorUtils.DeleteOldDemiLibCore();
// Remove old legacy defines
DOTweenSetup.RemoveAllLegacyDefines();
//
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 setupRequired = differentCoreVersion || differentProVersion;
Debug.Log("::: Setup required: " + setupRequired + " - " + differentCoreVersion + "/" + differentProVersion);
if (setupRequired) {
_setupDialogRequested = true;
EditorPrefs.SetString(Application.dataPath + DOTweenUtilityWindow.Id, Application.dataPath + DOTween.Version);
if (EditorUtils.hasPro) EditorPrefs.SetString(Application.dataPath + DOTweenUtilityWindow.IdPro, Application.dataPath + EditorUtils.proVersion);
// DOTweenSetup.AddAllUnityDefines();
EditorUtility.DisplayDialog("DOTween",
differentCoreVersion
? "New version of DOTween imported." +
"\n\nSelect \"Setup DOTween...\" in DOTween's Utility Panel to add/remove Modules."
: "New version of DOTween Pro imported." +
" \n\nSelect \"Setup DOTween...\" in DOTween's Utility Panel to add/remove external Modules (TextMesh Pro/2DToolkit/etc).",
"Ok"
);
DOTweenUtilityWindow.Open();
// Opening window after a postProcess doesn't work on Unity 3 so check that
// string[] vs = Application.unityVersion.Split("."[0]);
// int majorVersion = System.Convert.ToInt32(vs[0]);
// if (majorVersion >= 4) EditorUtils.DelayedCall(0.5f, DOTweenUtilityWindow.Open);
// EditorUtils.DelayedCall(8, ()=> _setupDialogRequested = false);
}
}
}
}
class DOTweenUtilityWindow : EditorWindow class DOTweenUtilityWindow : EditorWindow
{ {
[MenuItem("Tools/Demigiant/" + _Title)] [MenuItem("Tools/Demigiant/" + _Title)]
@ -196,10 +110,10 @@ namespace DG.DOTweenEditor
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
} else { } else {
if (_isModulesMode) { if (_isModulesMode) {
if (DOTweenModulesSetupGUI.Draw()) _isModulesMode = false; if (DOTweenUtilityWindowModules.Draw()) _isModulesMode = false;
} else { } else {
Rect areaRect = new Rect(0, 0, _headerSize.x, 30); Rect areaRect = new Rect(0, 0, _headerSize.x, 30);
_selectedTab = GUI.Toolbar(areaRect, _selectedTab, _tabLabels); _selectedTab = UnityEngine.GUI.Toolbar(areaRect, _selectedTab, _tabLabels);
switch (_selectedTab) { switch (_selectedTab) {
case 1: case 1:
@ -219,28 +133,30 @@ namespace DG.DOTweenEditor
void DrawSetupGUI() void DrawSetupGUI()
{ {
Rect areaRect = new Rect(0, 30, _headerSize.x, _headerSize.y); Rect areaRect = new Rect(0, 30, _headerSize.x, _headerSize.y);
GUI.DrawTexture(areaRect, _headerImg, ScaleMode.StretchToFill, false); UnityEngine.GUI.DrawTexture(areaRect, _headerImg, ScaleMode.StretchToFill, false);
GUILayout.Space(areaRect.y + _headerSize.y + 2); GUILayout.Space(areaRect.y + _headerSize.y + 2);
GUILayout.Label(_innerTitle, DOTween.isDebugBuild ? EditorGUIUtils.redLabelStyle : EditorGUIUtils.boldLabelStyle); GUILayout.Label(_innerTitle, DOTween.isDebugBuild ? EditorGUIUtils.redLabelStyle : EditorGUIUtils.boldLabelStyle);
if (_setupRequired) { if (_setupRequired) {
GUI.backgroundColor = Color.red; UnityEngine.GUI.backgroundColor = Color.red;
GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
GUILayout.Label("DOTWEEN SETUP REQUIRED", EditorGUIUtils.setupLabelStyle); GUILayout.Label("DOTWEEN SETUP REQUIRED", EditorGUIUtils.setupLabelStyle);
GUILayout.EndVertical(); GUILayout.EndVertical();
GUI.backgroundColor = Color.white; UnityEngine.GUI.backgroundColor = Color.white;
} else GUILayout.Space(8); } else GUILayout.Space(8);
GUI.color = Color.green; UnityEngine.GUI.color = Color.green;
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
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)) {
// DOTweenSetup.Setup(); // DOTweenDefines.Setup();
// _setupRequired = EditorUtils.DOTweenSetupRequired(); // _setupRequired = EditorUtils.DOTweenSetupRequired();
DOTweenModulesSetupGUI.Refresh(); DOTweenUtilityWindowModules.Refresh();
_isModulesMode = true; _isModulesMode = true;
EditorUtils.DeleteLegacyNoModulesDOTweenFiles();
return;
} }
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUI.color = Color.white; UnityEngine.GUI.color = Color.white;
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.Space(8); GUILayout.Space(8);
@ -333,7 +249,7 @@ namespace DG.DOTweenEditor
_src.defaultAutoKill = EditorGUILayout.Toggle("AutoKill", _src.defaultAutoKill); _src.defaultAutoKill = EditorGUILayout.Toggle("AutoKill", _src.defaultAutoKill);
_src.defaultLoopType = (LoopType)EditorGUILayout.EnumPopup("Loop Type", _src.defaultLoopType); _src.defaultLoopType = (LoopType)EditorGUILayout.EnumPopup("Loop Type", _src.defaultLoopType);
if (GUI.changed) EditorUtility.SetDirty(_src); if (UnityEngine.GUI.changed) EditorUtility.SetDirty(_src);
} }
// =================================================================================== // ===================================================================================

View File

@ -3,14 +3,12 @@
// 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 DG.DOTweenEditor.Core;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using EditorUtils = DG.DOTweenEditor.Core.EditorUtils;
namespace DG.DOTweenEditor namespace DG.DOTweenEditor.UI
{ {
public static class DOTweenModulesSetupGUI public static class DOTweenUtilityWindowModules
{ {
static bool _hasAudioModule; static bool _hasAudioModule;
static bool _hasPhysicsModule; static bool _hasPhysicsModule;
@ -23,14 +21,14 @@ namespace DG.DOTweenEditor
public static void Refresh() public static void Refresh()
{ {
_hasAudioModule = EditorUtils.HasGlobalDefine(DOTweenSetup.GlobalDefine_AudioModule); _hasAudioModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_AudioModule);
_hasPhysicsModule = EditorUtils.HasGlobalDefine(DOTweenSetup.GlobalDefine_PhysicsModule); _hasPhysicsModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_PhysicsModule);
_hasPhysics2DModule = EditorUtils.HasGlobalDefine(DOTweenSetup.GlobalDefine_Physics2DModule); _hasPhysics2DModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_Physics2DModule);
_hasSpriteModule = EditorUtils.HasGlobalDefine(DOTweenSetup.GlobalDefine_SpriteModule); _hasSpriteModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_SpriteModule);
_hasUIModule = EditorUtils.HasGlobalDefine(DOTweenSetup.GlobalDefine_UIModule); _hasUIModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_UIModule);
_hasTextMeshProModule = EditorUtils.HasGlobalDefine(DOTweenSetup.GlobalDefine_TextMeshPro); _hasTextMeshProModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_TextMeshPro);
_hasTk2DModule = EditorUtils.HasGlobalDefine(DOTweenSetup.GlobalDefine_TK2D); _hasTk2DModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_TK2D);
} }
// Returns TRUE if it should be closed // Returns TRUE if it should be closed
@ -38,7 +36,7 @@ namespace DG.DOTweenEditor
{ {
GUILayout.Label("Add/Remove Modules", EditorGUIUtils.titleStyle); GUILayout.Label("Add/Remove Modules", EditorGUIUtils.titleStyle);
GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
GUILayout.Label("Unity", EditorGUIUtils.boldLabelStyle); GUILayout.Label("Unity", EditorGUIUtils.boldLabelStyle);
_hasAudioModule = EditorGUILayout.Toggle("Audio", _hasAudioModule); _hasAudioModule = EditorGUILayout.Toggle("Audio", _hasAudioModule);
_hasPhysicsModule = EditorGUILayout.Toggle("Physics", _hasPhysicsModule); _hasPhysicsModule = EditorGUILayout.Toggle("Physics", _hasPhysicsModule);
@ -47,7 +45,7 @@ namespace DG.DOTweenEditor
_hasUIModule = EditorGUILayout.Toggle("UI", _hasUIModule); _hasUIModule = EditorGUILayout.Toggle("UI", _hasUIModule);
EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical();
if (EditorUtils.hasPro) { if (EditorUtils.hasPro) {
GUILayout.BeginVertical(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); _hasTk2DModule = EditorGUILayout.Toggle("2D Toolkit", _hasTk2DModule);
_hasTextMeshProModule = EditorGUILayout.Toggle("TextMesh Pro", _hasTextMeshProModule); _hasTextMeshProModule = EditorGUILayout.Toggle("TextMesh Pro", _hasTextMeshProModule);
@ -73,15 +71,15 @@ namespace DG.DOTweenEditor
static void Apply() static void Apply()
{ {
ModifyDefineIfChanged(_hasAudioModule, DOTweenSetup.GlobalDefine_AudioModule); ModifyDefineIfChanged(_hasAudioModule, DOTweenDefines.GlobalDefine_AudioModule);
ModifyDefineIfChanged(_hasPhysicsModule, DOTweenSetup.GlobalDefine_PhysicsModule); ModifyDefineIfChanged(_hasPhysicsModule, DOTweenDefines.GlobalDefine_PhysicsModule);
ModifyDefineIfChanged(_hasPhysics2DModule, DOTweenSetup.GlobalDefine_Physics2DModule); ModifyDefineIfChanged(_hasPhysics2DModule, DOTweenDefines.GlobalDefine_Physics2DModule);
ModifyDefineIfChanged(_hasSpriteModule, DOTweenSetup.GlobalDefine_SpriteModule); ModifyDefineIfChanged(_hasSpriteModule, DOTweenDefines.GlobalDefine_SpriteModule);
ModifyDefineIfChanged(_hasUIModule, DOTweenSetup.GlobalDefine_UIModule); ModifyDefineIfChanged(_hasUIModule, DOTweenDefines.GlobalDefine_UIModule);
if (EditorUtils.hasPro) { if (EditorUtils.hasPro) {
ModifyDefineIfChanged(_hasTextMeshProModule, DOTweenSetup.GlobalDefine_TextMeshPro); ModifyDefineIfChanged(_hasTextMeshProModule, DOTweenDefines.GlobalDefine_TextMeshPro);
ModifyDefineIfChanged(_hasTk2DModule, DOTweenSetup.GlobalDefine_TK2D); ModifyDefineIfChanged(_hasTk2DModule, DOTweenDefines.GlobalDefine_TK2D);
} }
} }

View File

@ -6,7 +6,7 @@ using DG.Tweening;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
namespace DG.DOTweenEditor.Core namespace DG.DOTweenEditor.UI
{ {
public static class EditorGUIUtils public static class EditorGUIUtils
{ {
@ -101,16 +101,16 @@ namespace DG.DOTweenEditor.Core
// A button which works as a toggle // A button which works as a toggle
public static bool ToggleButton(bool toggled, GUIContent content, GUIStyle guiStyle = null, params GUILayoutOption[] options) public static bool ToggleButton(bool toggled, GUIContent content, GUIStyle guiStyle = null, params GUILayoutOption[] options)
{ {
Color orColor = GUI.backgroundColor; Color orColor = UnityEngine.GUI.backgroundColor;
GUI.backgroundColor = toggled ? Color.green : Color.white; UnityEngine.GUI.backgroundColor = toggled ? Color.green : Color.white;
bool clicked = guiStyle == null bool clicked = guiStyle == null
? GUILayout.Button(content, options) ? GUILayout.Button(content, options)
: GUILayout.Button(content, guiStyle, options); : GUILayout.Button(content, guiStyle, options);
if (clicked) { if (clicked) {
toggled = !toggled; toggled = !toggled;
GUI.changed = true; UnityEngine.GUI.changed = true;
} }
GUI.backgroundColor = orColor; UnityEngine.GUI.backgroundColor = orColor;
return toggled; return toggled;
} }
@ -120,7 +120,7 @@ namespace DG.DOTweenEditor.Core
_additionalStylesSet = true; _additionalStylesSet = true;
Vector2 footerSizeV = (Vector2)footerSize; Vector2 footerSizeV = (Vector2)footerSize;
btImgStyle = new GUIStyle(GUI.skin.button); btImgStyle = new GUIStyle(UnityEngine.GUI.skin.button);
btImgStyle.normal.background = null; btImgStyle.normal.background = null;
btImgStyle.imagePosition = ImagePosition.ImageOnly; btImgStyle.imagePosition = ImagePosition.ImageOnly;
btImgStyle.padding = new RectOffset(0, 0, 0, 0); btImgStyle.padding = new RectOffset(0, 0, 0, 0);
@ -131,18 +131,18 @@ namespace DG.DOTweenEditor.Core
if (!_stylesSet) { if (!_stylesSet) {
_stylesSet = true; _stylesSet = true;
boldLabelStyle = new GUIStyle(GUI.skin.label); boldLabelStyle = new GUIStyle(UnityEngine.GUI.skin.label);
boldLabelStyle.fontStyle = FontStyle.Bold; boldLabelStyle.fontStyle = FontStyle.Bold;
redLabelStyle = new GUIStyle(GUI.skin.label); redLabelStyle = new GUIStyle(UnityEngine.GUI.skin.label);
redLabelStyle.normal.textColor = Color.red; redLabelStyle.normal.textColor = Color.red;
setupLabelStyle = new GUIStyle(boldLabelStyle); setupLabelStyle = new GUIStyle(boldLabelStyle);
setupLabelStyle.alignment = TextAnchor.MiddleCenter; setupLabelStyle.alignment = TextAnchor.MiddleCenter;
wrapCenterLabelStyle = new GUIStyle(GUI.skin.label); wrapCenterLabelStyle = new GUIStyle(UnityEngine.GUI.skin.label);
wrapCenterLabelStyle.wordWrap = true; wrapCenterLabelStyle.wordWrap = true;
wrapCenterLabelStyle.alignment = TextAnchor.MiddleCenter; wrapCenterLabelStyle.alignment = TextAnchor.MiddleCenter;
btBigStyle = new GUIStyle(GUI.skin.button); btBigStyle = new GUIStyle(UnityEngine.GUI.skin.button);
btBigStyle.padding = new RectOffset(0, 0, 10, 10); btBigStyle.padding = new RectOffset(0, 0, 10, 10);
btSetup = new GUIStyle(btBigStyle); btSetup = new GUIStyle(btBigStyle);
@ -152,12 +152,12 @@ namespace DG.DOTweenEditor.Core
// //
titleStyle = new GUIStyle(GUI.skin.label) { titleStyle = new GUIStyle(UnityEngine.GUI.skin.label) {
fontSize = 12, fontSize = 12,
fontStyle = FontStyle.Bold fontStyle = FontStyle.Bold
}; };
handlelabelStyle = new GUIStyle(GUI.skin.label) { handlelabelStyle = new GUIStyle(UnityEngine.GUI.skin.label) {
normal = { textColor = Color.white }, normal = { textColor = Color.white },
alignment = TextAnchor.MiddleLeft alignment = TextAnchor.MiddleLeft
}; };
@ -166,20 +166,20 @@ namespace DG.DOTweenEditor.Core
fontStyle = FontStyle.Bold fontStyle = FontStyle.Bold
}; };
wordWrapLabelStyle = new GUIStyle(GUI.skin.label); wordWrapLabelStyle = new GUIStyle(UnityEngine.GUI.skin.label);
wordWrapLabelStyle.wordWrap = true; wordWrapLabelStyle.wordWrap = true;
wordWrapItalicLabelStyle = new GUIStyle(wordWrapLabelStyle); wordWrapItalicLabelStyle = new GUIStyle(wordWrapLabelStyle);
wordWrapItalicLabelStyle.fontStyle = FontStyle.Italic; wordWrapItalicLabelStyle.fontStyle = FontStyle.Italic;
logoIconStyle = new GUIStyle(GUI.skin.box); logoIconStyle = new GUIStyle(UnityEngine.GUI.skin.box);
logoIconStyle.active.background = logoIconStyle.normal.background = null; logoIconStyle.active.background = logoIconStyle.normal.background = null;
logoIconStyle.margin = new RectOffset(0, 0, 0, 0); logoIconStyle.margin = new RectOffset(0, 0, 0, 0);
logoIconStyle.padding = new RectOffset(0, 0, 0, 0); logoIconStyle.padding = new RectOffset(0, 0, 0, 0);
// //
sideBtStyle = new GUIStyle(GUI.skin.button); sideBtStyle = new GUIStyle(UnityEngine.GUI.skin.button);
sideBtStyle.margin.top = 1; sideBtStyle.margin.top = 1;
sideBtStyle.padding = new RectOffset(0, 0, 2, 2); sideBtStyle.padding = new RectOffset(0, 0, 2, 2);
@ -187,14 +187,14 @@ namespace DG.DOTweenEditor.Core
sideLogoIconBoldLabelStyle.alignment = TextAnchor.MiddleLeft; sideLogoIconBoldLabelStyle.alignment = TextAnchor.MiddleLeft;
sideLogoIconBoldLabelStyle.padding.top = 2; sideLogoIconBoldLabelStyle.padding.top = 2;
wordWrapTextArea = new GUIStyle(GUI.skin.textArea); wordWrapTextArea = new GUIStyle(UnityEngine.GUI.skin.textArea);
wordWrapTextArea.wordWrap = true; wordWrapTextArea.wordWrap = true;
popupButton = new GUIStyle(EditorStyles.popup); popupButton = new GUIStyle(EditorStyles.popup);
popupButton.fixedHeight = 18; popupButton.fixedHeight = 18;
popupButton.margin.top += 1; popupButton.margin.top += 1;
btIconStyle = new GUIStyle(GUI.skin.button); btIconStyle = new GUIStyle(UnityEngine.GUI.skin.button);
btIconStyle.padding.left -= 2; btIconStyle.padding.left -= 2;
btIconStyle.fixedWidth = 24; btIconStyle.fixedWidth = 24;
btIconStyle.stretchWidth = false; btIconStyle.stretchWidth = false;