mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2026-02-13 10:38:49 +08:00
Improved Utility Panel's Setup
This commit is contained in:
parent
90453dc667
commit
a0701f26a2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -32,7 +32,7 @@ namespace DG.Tweening
|
||||
public class DOTween
|
||||
{
|
||||
/// <summary>DOTween's version</summary>
|
||||
public static readonly string Version = "1.0.645";
|
||||
public static readonly string Version = "1.0.655";
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Options ////////////////////////////////////
|
||||
|
||||
@ -18,10 +18,8 @@ namespace DG.DOTweenEditor
|
||||
/// </summary>
|
||||
class DOTweenSetupMenuItem
|
||||
{
|
||||
// [MenuItem("Tools/" + _Title)]
|
||||
// static void StartSetup() { Setup(); }
|
||||
|
||||
const string _Title = "DOTween Setup";
|
||||
static Assembly _proEditorAssembly;
|
||||
|
||||
/// <summary>
|
||||
/// Setups DOTween
|
||||
@ -31,21 +29,19 @@ namespace DG.DOTweenEditor
|
||||
{
|
||||
bool setupRequired = EditorUtils.DOTweenSetupRequired();
|
||||
if (setupRequired) {
|
||||
string msg = "Based on your Unity version (" + Application.unityVersion + ") and eventual plugins, DOTween will now import additional tween elements, if available.";
|
||||
string msg = "Based on your Unity version (" + Application.unityVersion + ") and eventual plugins, DOTween will now activate additional tween elements, if available.";
|
||||
if (!EditorUtility.DisplayDialog(_Title, msg, "Ok", "Cancel")) return;
|
||||
} else {
|
||||
if (!partiallySilent) {
|
||||
string msg = "This project has already been setup for your version of DOTween.\nUpdate to a new DOTween version before running the setup again.";
|
||||
EditorUtility.DisplayDialog(_Title, msg, "Ok");
|
||||
}
|
||||
return;
|
||||
string msg = "This project has already been setup for your version of DOTween.\nReimport DOTween if you added new compatible external assets or upgraded your Unity version.";
|
||||
if (!EditorUtility.DisplayDialog(_Title, msg, "Force Setup", "Cancel")) return;
|
||||
} else return;
|
||||
}
|
||||
|
||||
string addonsDir = EditorUtils.dotweenDir;
|
||||
string proAddonsDir = EditorUtils.dotweenProDir;
|
||||
string projectPath = Application.dataPath + EditorUtils.pathSlash;
|
||||
|
||||
EditorUtility.DisplayProgressBar(_Title, "Importing additional DOTween elements based on your Unity version and eventual plugins...", 0.25f);
|
||||
EditorUtility.DisplayProgressBar(_Title, "Please wait...", 0.25f);
|
||||
|
||||
int totImported = 0;
|
||||
// Unity version-based files
|
||||
@ -72,14 +68,16 @@ namespace DG.DOTweenEditor
|
||||
// Additional plugin files
|
||||
// Pro plugins
|
||||
if (EditorUtils.hasPro) {
|
||||
if (Directory.GetDirectories(EditorUtils.projectPath, "TK2DROOT", SearchOption.AllDirectories).Length > 0) {
|
||||
// PRO > 2DToolkit shortcuts
|
||||
// PRO > 2DToolkit shortcuts
|
||||
if (Has2DToolkit()) {
|
||||
totImported += ImportAddons("Tk2d", proAddonsDir);
|
||||
}
|
||||
if (Directory.GetDirectories(EditorUtils.projectPath, "TextMesh Pro", SearchOption.AllDirectories).Length > 0) {
|
||||
// PRO > TextMeshPro shortcuts
|
||||
ProEditor_AddGlobalDefine("DOTWEEN_TK2D");
|
||||
} else ProEditor_RemoveGlobalDefine("DOTWEEN_TK2D");
|
||||
// PRO > TextMeshPro shortcuts
|
||||
if (HasTextMeshPro()) {
|
||||
totImported += ImportAddons("TextMeshPro", proAddonsDir);
|
||||
}
|
||||
ProEditor_AddGlobalDefine("DOTWEEN_TMP");
|
||||
} else ProEditor_RemoveGlobalDefine("DOTWEEN_TMP");
|
||||
}
|
||||
|
||||
SetupComplete(addonsDir, proAddonsDir, totImported);
|
||||
@ -87,31 +85,44 @@ namespace DG.DOTweenEditor
|
||||
|
||||
static void SetupComplete(string addonsDir, string proAddonsDir, int totImported)
|
||||
{
|
||||
int totRemoved = 0;
|
||||
|
||||
// Delete all remaining addon files
|
||||
string[] leftoverAddonFiles = Directory.GetFiles(addonsDir, "*.addon");
|
||||
if (leftoverAddonFiles.Length > 0) {
|
||||
EditorUtility.DisplayProgressBar(_Title, "Removing " + leftoverAddonFiles.Length + " unused additional files...", 0.5f);
|
||||
foreach (string leftoverAddonFile in leftoverAddonFiles) File.Delete(leftoverAddonFile);
|
||||
foreach (string leftoverAddonFile in leftoverAddonFiles) {
|
||||
totRemoved++;
|
||||
File.Delete(leftoverAddonFile);
|
||||
}
|
||||
}
|
||||
if (EditorUtils.hasPro) {
|
||||
leftoverAddonFiles = Directory.GetFiles(proAddonsDir, "*.addon");
|
||||
if (leftoverAddonFiles.Length > 0) {
|
||||
EditorUtility.DisplayProgressBar(_Title, "Removing " + leftoverAddonFiles.Length + " unused additional files...", 0.5f);
|
||||
foreach (string leftoverAddonFile in leftoverAddonFiles) File.Delete(leftoverAddonFile);
|
||||
foreach (string leftoverAddonFile in leftoverAddonFiles) {
|
||||
totRemoved++;
|
||||
File.Delete(leftoverAddonFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Delete all remaining addon meta files
|
||||
leftoverAddonFiles = Directory.GetFiles(addonsDir, "*.addon.meta");
|
||||
if (leftoverAddonFiles.Length > 0) {
|
||||
EditorUtility.DisplayProgressBar(_Title, "Removing " + leftoverAddonFiles.Length + " unused additional meta files...", 0.75f);
|
||||
foreach (string leftoverAddonFile in leftoverAddonFiles) File.Delete(leftoverAddonFile);
|
||||
foreach (string leftoverAddonFile in leftoverAddonFiles) {
|
||||
totRemoved++;
|
||||
File.Delete(leftoverAddonFile);
|
||||
}
|
||||
}
|
||||
if (EditorUtils.hasPro) {
|
||||
leftoverAddonFiles = Directory.GetFiles(proAddonsDir, "*.addon.meta");
|
||||
if (leftoverAddonFiles.Length > 0) {
|
||||
EditorUtility.DisplayProgressBar(_Title, "Removing " + leftoverAddonFiles.Length + " unused additional meta files...", 0.75f);
|
||||
foreach (string leftoverAddonFile in leftoverAddonFiles) File.Delete(leftoverAddonFile);
|
||||
foreach (string leftoverAddonFile in leftoverAddonFiles) {
|
||||
totRemoved++;
|
||||
File.Delete(leftoverAddonFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +130,11 @@ namespace DG.DOTweenEditor
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
EditorUtility.ClearProgressBar();
|
||||
EditorUtility.DisplayDialog(_Title, "DOTween setup is now complete." + (totImported == 0 ? "" : "\n" + totImported + " additional libraries were imported or updated."), "Ok");
|
||||
EditorUtility.DisplayDialog(_Title, "DOTween setup is now complete." +
|
||||
(totImported == 0 ? "" : "\n" + totImported + " additional libraries were imported or updated.") +
|
||||
(totRemoved == 0 ? "" : "\n" + totRemoved + " extra files were removed."),
|
||||
"Ok"
|
||||
);
|
||||
}
|
||||
|
||||
// Removes relative .addon extension thus activating files
|
||||
@ -147,5 +162,46 @@ namespace DG.DOTweenEditor
|
||||
|
||||
return imported ? 1 : 0;
|
||||
}
|
||||
|
||||
static bool Has2DToolkit()
|
||||
{
|
||||
string[] rootDirs = Directory.GetDirectories(EditorUtils.projectPath, "TK2DROOT", SearchOption.AllDirectories);
|
||||
if (rootDirs.Length == 0) return false;
|
||||
foreach (string rootDir in rootDirs) {
|
||||
if (Directory.GetFiles(rootDir, "tk2dSprite.cs", SearchOption.AllDirectories).Length > 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static bool HasTextMeshPro()
|
||||
{
|
||||
string[] rootDirs = Directory.GetDirectories(EditorUtils.projectPath, "TextMesh Pro", SearchOption.AllDirectories);
|
||||
if (rootDirs.Length == 0) return false;
|
||||
foreach (string rootDir in rootDirs) {
|
||||
if (Directory.GetFiles(rootDir, "TextMeshPro.cs", SearchOption.AllDirectories).Length > 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static Assembly ProEditorAssembly()
|
||||
{
|
||||
if (_proEditorAssembly == null) _proEditorAssembly = Assembly.LoadFile(EditorUtils.dotweenProDir + "Editor" + EditorUtils.pathSlash + "DOTweenProEditor.dll");
|
||||
return _proEditorAssembly;
|
||||
}
|
||||
// Uses reflection to call DOTweenPro's AddGlobalDefine method (because older version of Unity didn't have it)
|
||||
static void ProEditor_AddGlobalDefine(string id)
|
||||
{
|
||||
if (!EditorUtils.hasPro || ProEditorAssembly() == null) return;
|
||||
|
||||
Type type = _proEditorAssembly.GetType("DG.DOTweenEditor.Core.ProEditorUtils");
|
||||
type.GetMethod("AddGlobalDefine", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { id });
|
||||
}
|
||||
// Uses reflection to call DOTweenPro's RemoveGlobalDefine method (because older version of Unity didn't have it)
|
||||
static void ProEditor_RemoveGlobalDefine(string id)
|
||||
{
|
||||
if (!EditorUtils.hasPro || ProEditorAssembly() == null) return;
|
||||
|
||||
Type type = _proEditorAssembly.GetType("DG.DOTweenEditor.Core.ProEditorUtils");
|
||||
type.GetMethod("RemoveGlobalDefine", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { id });
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user