1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-22 10:16:04 +08:00

Modules Panel now doesn't close when upgrade compilation ends

This commit is contained in:
Demigiant 2018-08-02 14:21:55 +02:00
parent 2887a8b4a5
commit 1f5e48d269
15 changed files with 54 additions and 17 deletions

View File

@ -37,6 +37,7 @@ namespace DG.Tweening.Core
DemigiantDirectory DemigiantDirectory
} }
public SettingsLocation storeSettingsLocation = SettingsLocation.AssetsDirectory; public SettingsLocation storeSettingsLocation = SettingsLocation.AssetsDirectory;
public bool showModulesPanel;
// Editor-Only ► DOTween Inspector // Editor-Only ► DOTween Inspector
public bool showPlayingTweens, showPausedTweens; public bool showPlayingTweens, showPausedTweens;

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

View File

@ -29,7 +29,6 @@ namespace DG.DOTweenEditor.UI
bool _setupRequired; bool _setupRequired;
int _selectedTab; int _selectedTab;
bool _isModulesMode;
string[] _tabLabels = new[] { "Setup", "Preferences" }; string[] _tabLabels = new[] { "Setup", "Preferences" };
string[] _settingsLocation = new[] {"Assets > Resources", "DOTween > Resources", "Demigiant > Resources"}; string[] _settingsLocation = new[] {"Assets > Resources", "DOTween > Resources", "Demigiant > Resources"};
@ -87,9 +86,12 @@ namespace DG.DOTweenEditor.UI
_setupRequired = EditorUtils.DOTweenSetupRequired(); _setupRequired = EditorUtils.DOTweenSetupRequired();
} }
void OnDisable() void OnDestroy()
{ {
_isModulesMode = false; if (_src != null) {
_src.showModulesPanel = false;
EditorUtility.SetDirty(_src);
}
} }
void OnGUI() void OnGUI()
@ -110,10 +112,11 @@ namespace DG.DOTweenEditor.UI
GUILayout.Space(40); GUILayout.Space(40);
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
} else { } else {
if (_isModulesMode) { if (_src.showModulesPanel) {
if (DOTweenUtilityWindowModules.Draw()) { if (DOTweenUtilityWindowModules.Draw(this)) {
_setupRequired = EditorUtils.DOTweenSetupRequired(); _setupRequired = EditorUtils.DOTweenSetupRequired();
_isModulesMode = false; _src.showModulesPanel = false;
EditorUtility.SetDirty(_src);
} }
} else { } else {
Rect areaRect = new Rect(0, 0, _headerSize.x, 30); Rect areaRect = new Rect(0, 0, _headerSize.x, 30);
@ -129,6 +132,8 @@ namespace DG.DOTweenEditor.UI
} }
} }
} }
if (GUI.changed) EditorUtility.SetDirty(_src);
} }
// =================================================================================== // ===================================================================================
@ -155,7 +160,8 @@ namespace DG.DOTweenEditor.UI
// DOTweenDefines.Setup(); // DOTweenDefines.Setup();
// _setupRequired = EditorUtils.DOTweenSetupRequired(); // _setupRequired = EditorUtils.DOTweenSetupRequired();
DOTweenUtilityWindowModules.Refresh(); DOTweenUtilityWindowModules.Refresh();
_isModulesMode = true; _src.showModulesPanel = true;
EditorUtility.SetDirty(_src);
EditorUtils.DeleteLegacyNoModulesDOTweenFiles(); EditorUtils.DeleteLegacyNoModulesDOTweenFiles();
EditorUtils.DeleteDOTweenUpgradeManagerFiles(); EditorUtils.DeleteDOTweenUpgradeManagerFiles();
return; return;
@ -253,8 +259,6 @@ namespace DG.DOTweenEditor.UI
_src.defaultEasePeriod = EditorGUILayout.FloatField("Ease Period", _src.defaultEasePeriod); _src.defaultEasePeriod = EditorGUILayout.FloatField("Ease Period", _src.defaultEasePeriod);
_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 (UnityEngine.GUI.changed) EditorUtility.SetDirty(_src);
} }
// =================================================================================== // ===================================================================================

View File

@ -3,6 +3,7 @@
// 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.Tweening.Core;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@ -10,6 +11,7 @@ namespace DG.DOTweenEditor.UI
{ {
public static class DOTweenUtilityWindowModules public static class DOTweenUtilityWindowModules
{ {
static bool _refreshed;
static bool _hasAudioModule; static bool _hasAudioModule;
static bool _hasPhysicsModule; static bool _hasPhysicsModule;
static bool _hasPhysics2DModule; static bool _hasPhysics2DModule;
@ -19,8 +21,13 @@ namespace DG.DOTweenEditor.UI
static bool _hasTextMeshProModule; static bool _hasTextMeshProModule;
static bool _hasTk2DModule; static bool _hasTk2DModule;
static EditorWindow _editor;
static bool _isWaitingForCompilation;
public static void Refresh() public static void Refresh()
{ {
_refreshed = true;
_hasAudioModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_AudioModule); _hasAudioModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_AudioModule);
_hasPhysicsModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_PhysicsModule); _hasPhysicsModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_PhysicsModule);
_hasPhysics2DModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_Physics2DModule); _hasPhysics2DModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_Physics2DModule);
@ -32,10 +39,16 @@ namespace DG.DOTweenEditor.UI
} }
// Returns TRUE if it should be closed // Returns TRUE if it should be closed
public static bool Draw() public static bool Draw(EditorWindow editor)
{ {
_editor = editor;
if (!_refreshed) Refresh();
GUILayout.Label("Add/Remove Modules", EditorGUIUtils.titleStyle); GUILayout.Label("Add/Remove Modules", EditorGUIUtils.titleStyle);
if (EditorApplication.isCompiling) WaitForCompilation();
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); _hasAudioModule = EditorGUILayout.Toggle("Audio", _hasAudioModule);
@ -58,14 +71,12 @@ namespace DG.DOTweenEditor.UI
Apply(); Apply();
return true; return true;
} }
if (GUILayout.Button("Cancel")) return true; if (GUILayout.Button("Cancel")) {
return true;
}
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
EditorGUI.EndDisabledGroup();
// EditorGUILayout.HelpBox(
// "NOTE: if you get \"PlayerSettings Validation\" or [CS0618] errors when you press apply don't worry:" +
// " it's ok and it allows the setup to work on all possible Unity versions",
// MessageType.Warning
// );
return false; return false;
} }
@ -91,5 +102,26 @@ namespace DG.DOTweenEditor.UI
else EditorUtils.RemoveGlobalDefine(defineId); else EditorUtils.RemoveGlobalDefine(defineId);
} }
} }
static void WaitForCompilation()
{
if (!_isWaitingForCompilation) {
_isWaitingForCompilation = true;
EditorApplication.update += WaitForCompilation_Update;
WaitForCompilation_Update();
}
EditorGUILayout.HelpBox("Waiting for Unity to finish the compilation process...", MessageType.Info);
}
static void WaitForCompilation_Update()
{
if (!EditorApplication.isCompiling) {
EditorApplication.update -= WaitForCompilation_Update;
_isWaitingForCompilation = false;
Refresh();
}
_editor.Repaint();
}
} }
} }

Binary file not shown.