1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2026-02-09 08:38:45 +08:00

Added additional option when choosing DOTween settings location (Demigiant folder)

This commit is contained in:
Daniele Giardini 2015-04-11 19:13:06 +02:00
parent 9be6d63fd6
commit 472044c705
51 changed files with 98 additions and 55 deletions

View File

@ -1,7 +1,18 @@
fileFormatVersion: 2
guid: 11f311c200ce9de48b30e7dfedbfd165
MonoAssemblyImporter:
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +1,18 @@
fileFormatVersion: 2
guid: 847d6a28ef5c2f44f929171872a9ff2e
MonoAssemblyImporter:
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +1,7 @@
fileFormatVersion: 2
guid: 6c68a80831d8da74087b61dad131dcd6
guid: b4915b8ce4b86b54894a06a262c40129
folderAsset: yes
timeCreated: 1428751523
timeCreated: 1428772022
licenseType: Free
DefaultImporter:
userData:

View File

@ -27,7 +27,8 @@ namespace DG.Tweening.Core
public enum SettingsLocation
{
AssetsDirectory,
DOTweenDirectory
DOTweenDirectory,
DemigiantDirectory
}
public SettingsLocation storeSettingsLocation = SettingsLocation.AssetsDirectory;
}

View File

@ -21,7 +21,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.0.465";
public static readonly string Version = "1.0.470";
///////////////////////////////////////////////
// Options ////////////////////////////////////

View File

@ -18,6 +18,8 @@ namespace DG.DOTweenEditor.Core
public static string proVersion { get { if (!_hasCheckedForPro) CheckForPro(); return _proVersion; } }
// Editor path from Assets (not included) with final slash, in AssetDatabase format (/)
public static string editorADBDir { get { if (string.IsNullOrEmpty(_editorADBDir)) StoreEditorADBDir(); return _editorADBDir; } }
// With final slash (system based) - might be NULL in case users are not using a parent Demigiant folder
public static string demigiantDir { get { if (string.IsNullOrEmpty(_demigiantDir)) StoreDOTweenDirs(); return _demigiantDir; } }
// With final slash (system based)
public static string dotweenDir { get { if (string.IsNullOrEmpty(_dotweenDir)) StoreDOTweenDirs(); return _dotweenDir; } }
// With final slash (system based)
@ -30,6 +32,7 @@ namespace DG.DOTweenEditor.Core
static string _proVersion;
static bool _hasCheckedForPro;
static string _editorADBDir;
static string _demigiantDir; // with final slash
static string _dotweenDir; // with final slash
static string _dotweenProDir; // with final slash
@ -176,8 +179,13 @@ namespace DG.DOTweenEditor.Core
_dotweenProDir = _dotweenDir.Substring(0, _dotweenDir.LastIndexOf(pathSeparator));
_dotweenProDir = _dotweenProDir.Substring(0, _dotweenProDir.LastIndexOf(pathSeparator) + 1) + "DOTweenPro" + pathSeparator;
_demigiantDir = _dotweenDir.Substring(0, _dotweenDir.LastIndexOf(pathSeparator));
_demigiantDir = _demigiantDir.Substring(0, _demigiantDir.LastIndexOf(pathSeparator) + 1);
if (_demigiantDir.Substring(_demigiantDir.Length - 10, 9) != "Demigiant") _demigiantDir = null;
_dotweenDir = _dotweenDir.Replace(pathSlashToReplace, pathSlash);
_dotweenProDir = _dotweenProDir.Replace(pathSlashToReplace, pathSlash);
if (_demigiantDir != null) _demigiantDir = _demigiantDir.Replace(pathSlashToReplace, pathSlash);
}
static void CreateScriptableAsset<T>(string adbFilePath) where T : ScriptableObject

View File

@ -58,7 +58,7 @@ namespace DG.DOTweenEditor
int _selectedTab;
string[] _tabLabels = new[] { "Setup", "Preferences" };
string[] _settingsLocation = new[] {"Assets > Resources", "DOTween > Resources"};
string[] _settingsLocation = new[] {"Assets > Resources", "DOTween > Resources", "Demigiant > Resources"};
// If force is FALSE opens the window only if DOTween's version has changed
// (set to FALSE by OnPostprocessAllAssets)
@ -184,7 +184,15 @@ namespace DG.DOTweenEditor
_src.logBehaviour = (LogBehaviour)EditorGUILayout.EnumPopup("Log Behaviour", _src.logBehaviour);
DOTweenSettings.SettingsLocation prevSettingsLocation = _src.storeSettingsLocation;
_src.storeSettingsLocation = (DOTweenSettings.SettingsLocation)EditorGUILayout.Popup("Settings Location", (int)_src.storeSettingsLocation, _settingsLocation);
if (_src.storeSettingsLocation != prevSettingsLocation) Connect(true);
if (_src.storeSettingsLocation != prevSettingsLocation) {
if (_src.storeSettingsLocation == DOTweenSettings.SettingsLocation.DemigiantDirectory && EditorUtils.demigiantDir == null) {
EditorUtility.DisplayDialog("Change DOTween Settings Location", "Demigiant directory not present (must be the parent of DOTween's directory)", "Ok");
if (prevSettingsLocation == DOTweenSettings.SettingsLocation.DemigiantDirectory) {
_src.storeSettingsLocation = DOTweenSettings.SettingsLocation.AssetsDirectory;
Connect(true);
} else _src.storeSettingsLocation = prevSettingsLocation;
} else Connect(true);
}
GUILayout.Space(8);
GUILayout.Label("DEFAULTS ▼");
_src.defaultRecyclable = EditorGUILayout.Toggle("Recycle Tweens", _src.defaultRecyclable);
@ -207,70 +215,74 @@ namespace DG.DOTweenEditor
{
if (_src != null && !forceReconnect) return;
string externalSrcDir = EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources";
string externalSrcFilePath = externalSrcDir + EditorUtils.pathSlash + DOTweenSettings.AssetName + ".asset";
string externalAdbSrcFilePath = EditorUtils.FullPathToADBPath(externalSrcFilePath);
string internalSrcDir = EditorUtils.dotweenDir + "Resources";
string internalSrcFilePath = internalSrcDir + EditorUtils.pathSlash + DOTweenSettings.AssetName + ".asset";
string internalAdbSrcFilePath = EditorUtils.FullPathToADBPath(internalSrcFilePath);
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>(externalAdbSrcFilePath, false);
if (_src == null) _src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(internalAdbSrcFilePath, false);
_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. Create it in external folder
if (!Directory.Exists(externalSrcDir)) AssetDatabase.CreateFolder("Assets", "Resources");
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(externalAdbSrcFilePath, true);
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:
if (!Directory.Exists(externalSrcDir)) AssetDatabase.CreateFolder("Assets", "Resources");
if (File.Exists(internalSrcFilePath)) {
// Move internal src file to correct folder
AssetDatabase.MoveAsset(internalAdbSrcFilePath, externalAdbSrcFilePath);
// Delete internal Resources folder
AssetDatabase.DeleteAsset(EditorUtils.FullPathToADBPath(internalSrcDir));
}
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(externalAdbSrcFilePath, true);
MoveSrc(new[] { dotweenLD, demigiantLD }, assetsLD);
break;
case DOTweenSettings.SettingsLocation.DOTweenDirectory:
if (!Directory.Exists(internalSrcDir)) AssetDatabase.CreateFolder(EditorUtils.FullPathToADBPath(EditorUtils.dotweenDir.Substring(0, EditorUtils.dotweenDir.LastIndexOf(EditorUtils.pathSlash))), "Resources");
if (File.Exists(externalSrcFilePath)) {
// Move external src file to correct folder
AssetDatabase.MoveAsset(externalAdbSrcFilePath, internalAdbSrcFilePath);
// Delete external settings
AssetDatabase.DeleteAsset(externalAdbSrcFilePath);
// Check if external Resources folder is empty and in case delete it
if (Directory.GetDirectories(externalSrcDir).Length == 0 && Directory.GetFiles(externalSrcDir).Length == 0) {
AssetDatabase.DeleteAsset(EditorUtils.FullPathToADBPath(externalSrcDir));
}
}
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(internalAdbSrcFilePath, true);
MoveSrc(new[] { assetsLD, demigiantLD }, dotweenLD);
break;
case DOTweenSettings.SettingsLocation.DemigiantDirectory:
MoveSrc(new[] { assetsLD, dotweenLD }, demigiantLD);
break;
}
}
// if (_src == null) {
// string srcDir = EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources";
// if (!Directory.Exists(srcDir)) AssetDatabase.CreateFolder("Assets", "Resources");
// string adbSrcFilePath = EditorUtils.FullPathToADBPath(srcDir + EditorUtils.pathSlash + DOTweenSettings.AssetName + ".asset");
//
// // Legacy: check if there are settings saved in previous mode and eventually move them
// string altSrcDir = EditorUtils.dotweenDir + "Resources";
// string legacySrcFilePath = altSrcDir + EditorUtils.pathSlash + DOTweenSettings.AssetName + ".asset";
// if (File.Exists(legacySrcFilePath)) {
// // Move legacy src file to correct folder
// AssetDatabase.MoveAsset(EditorUtils.FullPathToADBPath(legacySrcFilePath), adbSrcFilePath);
// // Delete legacy Resources folder
// AssetDatabase.DeleteAsset(EditorUtils.FullPathToADBPath(altSrcDir));
// }
//
// _src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(adbSrcFilePath, true);
// }
void MoveSrc(LocationData[] from, LocationData to)
{
if (!Directory.Exists(to.dir)) AssetDatabase.CreateFolder(to.adbParentDir, "Resources");
foreach (LocationData ld in from) {
if (File.Exists(ld.filePath)) {
// Move external src file to correct folder
AssetDatabase.MoveAsset(ld.adbFilePath, to.adbFilePath);
// Delete external settings
AssetDatabase.DeleteAsset(ld.adbFilePath);
// Check if external Resources folder is empty and in case delete it
if (Directory.GetDirectories(ld.dir).Length == 0 && Directory.GetFiles(ld.dir).Length == 0) {
AssetDatabase.DeleteAsset(EditorUtils.FullPathToADBPath(ld.dir));
}
}
}
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(to.adbFilePath, true);
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ||| INTERNAL CLASSES ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
struct LocationData
{
public string dir; // without final slash
public string filePath;
public string adbFilePath;
public string adbParentDir; // without final slash
public LocationData(string srcDir) : this()
{
dir = srcDir;
filePath = dir + EditorUtils.pathSlash + DOTweenSettings.AssetName + ".asset";
adbFilePath = EditorUtils.FullPathToADBPath(filePath);
adbParentDir = EditorUtils.FullPathToADBPath(dir.Substring(0, dir.LastIndexOf(EditorUtils.pathSlash)));
}
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.