mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2026-03-04 06:39:15 +08:00
Added additional option when choosing DOTween settings location (Demigiant folder)
This commit is contained in:
parent
9be6d63fd6
commit
472044c705
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.
@ -1,7 +1,18 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 11f311c200ce9de48b30e7dfedbfd165
|
guid: 11f311c200ce9de48b30e7dfedbfd165
|
||||||
MonoAssemblyImporter:
|
PluginImporter:
|
||||||
serializedVersion: 1
|
serializedVersion: 1
|
||||||
iconMap: {}
|
iconMap: {}
|
||||||
executionOrder: {}
|
executionOrder: {}
|
||||||
|
isPreloaded: 0
|
||||||
|
platformData:
|
||||||
|
Any:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
Editor:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
userData:
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|||||||
@ -1,7 +1,18 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 847d6a28ef5c2f44f929171872a9ff2e
|
guid: 847d6a28ef5c2f44f929171872a9ff2e
|
||||||
MonoAssemblyImporter:
|
PluginImporter:
|
||||||
serializedVersion: 1
|
serializedVersion: 1
|
||||||
iconMap: {}
|
iconMap: {}
|
||||||
executionOrder: {}
|
executionOrder: {}
|
||||||
|
isPreloaded: 0
|
||||||
|
platformData:
|
||||||
|
Any:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
Editor:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
userData:
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 6c68a80831d8da74087b61dad131dcd6
|
guid: b4915b8ce4b86b54894a06a262c40129
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
timeCreated: 1428751523
|
timeCreated: 1428772022
|
||||||
licenseType: Free
|
licenseType: Free
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
userData:
|
userData:
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -27,7 +27,8 @@ namespace DG.Tweening.Core
|
|||||||
public enum SettingsLocation
|
public enum SettingsLocation
|
||||||
{
|
{
|
||||||
AssetsDirectory,
|
AssetsDirectory,
|
||||||
DOTweenDirectory
|
DOTweenDirectory,
|
||||||
|
DemigiantDirectory
|
||||||
}
|
}
|
||||||
public SettingsLocation storeSettingsLocation = SettingsLocation.AssetsDirectory;
|
public SettingsLocation storeSettingsLocation = SettingsLocation.AssetsDirectory;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,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.0.465";
|
public static readonly string Version = "1.0.470";
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
// Options ////////////////////////////////////
|
// Options ////////////////////////////////////
|
||||||
|
|||||||
@ -18,6 +18,8 @@ namespace DG.DOTweenEditor.Core
|
|||||||
public static string proVersion { get { if (!_hasCheckedForPro) CheckForPro(); return _proVersion; } }
|
public static string proVersion { get { if (!_hasCheckedForPro) CheckForPro(); return _proVersion; } }
|
||||||
// Editor path from Assets (not included) with final slash, in AssetDatabase format (/)
|
// Editor path from Assets (not included) with final slash, in AssetDatabase format (/)
|
||||||
public static string editorADBDir { get { if (string.IsNullOrEmpty(_editorADBDir)) StoreEditorADBDir(); return _editorADBDir; } }
|
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)
|
// With final slash (system based)
|
||||||
public static string dotweenDir { get { if (string.IsNullOrEmpty(_dotweenDir)) StoreDOTweenDirs(); return _dotweenDir; } }
|
public static string dotweenDir { get { if (string.IsNullOrEmpty(_dotweenDir)) StoreDOTweenDirs(); return _dotweenDir; } }
|
||||||
// With final slash (system based)
|
// With final slash (system based)
|
||||||
@ -30,6 +32,7 @@ namespace DG.DOTweenEditor.Core
|
|||||||
static string _proVersion;
|
static string _proVersion;
|
||||||
static bool _hasCheckedForPro;
|
static bool _hasCheckedForPro;
|
||||||
static string _editorADBDir;
|
static string _editorADBDir;
|
||||||
|
static string _demigiantDir; // with final slash
|
||||||
static string _dotweenDir; // with final slash
|
static string _dotweenDir; // with final slash
|
||||||
static string _dotweenProDir; // 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 = _dotweenDir.Substring(0, _dotweenDir.LastIndexOf(pathSeparator));
|
||||||
_dotweenProDir = _dotweenProDir.Substring(0, _dotweenProDir.LastIndexOf(pathSeparator) + 1) + "DOTweenPro" + 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);
|
_dotweenDir = _dotweenDir.Replace(pathSlashToReplace, pathSlash);
|
||||||
_dotweenProDir = _dotweenProDir.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
|
static void CreateScriptableAsset<T>(string adbFilePath) where T : ScriptableObject
|
||||||
|
|||||||
@ -58,7 +58,7 @@ namespace DG.DOTweenEditor
|
|||||||
|
|
||||||
int _selectedTab;
|
int _selectedTab;
|
||||||
string[] _tabLabels = new[] { "Setup", "Preferences" };
|
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
|
// If force is FALSE opens the window only if DOTween's version has changed
|
||||||
// (set to FALSE by OnPostprocessAllAssets)
|
// (set to FALSE by OnPostprocessAllAssets)
|
||||||
@ -184,7 +184,15 @@ namespace DG.DOTweenEditor
|
|||||||
_src.logBehaviour = (LogBehaviour)EditorGUILayout.EnumPopup("Log Behaviour", _src.logBehaviour);
|
_src.logBehaviour = (LogBehaviour)EditorGUILayout.EnumPopup("Log Behaviour", _src.logBehaviour);
|
||||||
DOTweenSettings.SettingsLocation prevSettingsLocation = _src.storeSettingsLocation;
|
DOTweenSettings.SettingsLocation prevSettingsLocation = _src.storeSettingsLocation;
|
||||||
_src.storeSettingsLocation = (DOTweenSettings.SettingsLocation)EditorGUILayout.Popup("Settings Location", (int)_src.storeSettingsLocation, _settingsLocation);
|
_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.Space(8);
|
||||||
GUILayout.Label("DEFAULTS ▼");
|
GUILayout.Label("DEFAULTS ▼");
|
||||||
_src.defaultRecyclable = EditorGUILayout.Toggle("Recycle Tweens", _src.defaultRecyclable);
|
_src.defaultRecyclable = EditorGUILayout.Toggle("Recycle Tweens", _src.defaultRecyclable);
|
||||||
@ -207,70 +215,74 @@ namespace DG.DOTweenEditor
|
|||||||
{
|
{
|
||||||
if (_src != null && !forceReconnect) return;
|
if (_src != null && !forceReconnect) return;
|
||||||
|
|
||||||
string externalSrcDir = EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources";
|
LocationData assetsLD = new LocationData(EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources");
|
||||||
string externalSrcFilePath = externalSrcDir + EditorUtils.pathSlash + DOTweenSettings.AssetName + ".asset";
|
LocationData dotweenLD = new LocationData(EditorUtils.dotweenDir + "Resources");
|
||||||
string externalAdbSrcFilePath = EditorUtils.FullPathToADBPath(externalSrcFilePath);
|
bool hasDemigiantDir = EditorUtils.demigiantDir != null;
|
||||||
string internalSrcDir = EditorUtils.dotweenDir + "Resources";
|
LocationData demigiantLD = hasDemigiantDir ? new LocationData(EditorUtils.demigiantDir + "Resources") : new LocationData();
|
||||||
string internalSrcFilePath = internalSrcDir + EditorUtils.pathSlash + DOTweenSettings.AssetName + ".asset";
|
|
||||||
string internalAdbSrcFilePath = EditorUtils.FullPathToADBPath(internalSrcFilePath);
|
|
||||||
|
|
||||||
if (_src == null) {
|
if (_src == null) {
|
||||||
// Load eventual existing settings
|
// Load eventual existing settings
|
||||||
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(externalAdbSrcFilePath, false);
|
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(assetsLD.adbFilePath, false);
|
||||||
if (_src == null) _src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(internalAdbSrcFilePath, 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) {
|
if (_src == null) {
|
||||||
// Settings don't exist. Create it in external folder
|
// Settings don't exist. Create it in external folder
|
||||||
if (!Directory.Exists(externalSrcDir)) AssetDatabase.CreateFolder("Assets", "Resources");
|
if (!Directory.Exists(assetsLD.dir)) AssetDatabase.CreateFolder(assetsLD.adbParentDir, "Resources");
|
||||||
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(externalAdbSrcFilePath, true);
|
_src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(assetsLD.adbFilePath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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:
|
||||||
if (!Directory.Exists(externalSrcDir)) AssetDatabase.CreateFolder("Assets", "Resources");
|
MoveSrc(new[] { dotweenLD, demigiantLD }, assetsLD);
|
||||||
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);
|
|
||||||
break;
|
break;
|
||||||
case DOTweenSettings.SettingsLocation.DOTweenDirectory:
|
case DOTweenSettings.SettingsLocation.DOTweenDirectory:
|
||||||
if (!Directory.Exists(internalSrcDir)) AssetDatabase.CreateFolder(EditorUtils.FullPathToADBPath(EditorUtils.dotweenDir.Substring(0, EditorUtils.dotweenDir.LastIndexOf(EditorUtils.pathSlash))), "Resources");
|
MoveSrc(new[] { assetsLD, demigiantLD }, dotweenLD);
|
||||||
if (File.Exists(externalSrcFilePath)) {
|
break;
|
||||||
// Move external src file to correct folder
|
case DOTweenSettings.SettingsLocation.DemigiantDirectory:
|
||||||
AssetDatabase.MoveAsset(externalAdbSrcFilePath, internalAdbSrcFilePath);
|
MoveSrc(new[] { assetsLD, dotweenLD }, demigiantLD);
|
||||||
// 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);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (_src == null) {
|
void MoveSrc(LocationData[] from, LocationData to)
|
||||||
// string srcDir = EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources";
|
{
|
||||||
// if (!Directory.Exists(srcDir)) AssetDatabase.CreateFolder("Assets", "Resources");
|
if (!Directory.Exists(to.dir)) AssetDatabase.CreateFolder(to.adbParentDir, "Resources");
|
||||||
// string adbSrcFilePath = EditorUtils.FullPathToADBPath(srcDir + EditorUtils.pathSlash + DOTweenSettings.AssetName + ".asset");
|
foreach (LocationData ld in from) {
|
||||||
//
|
if (File.Exists(ld.filePath)) {
|
||||||
// // Legacy: check if there are settings saved in previous mode and eventually move them
|
// Move external src file to correct folder
|
||||||
// string altSrcDir = EditorUtils.dotweenDir + "Resources";
|
AssetDatabase.MoveAsset(ld.adbFilePath, to.adbFilePath);
|
||||||
// string legacySrcFilePath = altSrcDir + EditorUtils.pathSlash + DOTweenSettings.AssetName + ".asset";
|
// Delete external settings
|
||||||
// if (File.Exists(legacySrcFilePath)) {
|
AssetDatabase.DeleteAsset(ld.adbFilePath);
|
||||||
// // Move legacy src file to correct folder
|
// Check if external Resources folder is empty and in case delete it
|
||||||
// AssetDatabase.MoveAsset(EditorUtils.FullPathToADBPath(legacySrcFilePath), adbSrcFilePath);
|
if (Directory.GetDirectories(ld.dir).Length == 0 && Directory.GetFiles(ld.dir).Length == 0) {
|
||||||
// // Delete legacy Resources folder
|
AssetDatabase.DeleteAsset(EditorUtils.FullPathToADBPath(ld.dir));
|
||||||
// AssetDatabase.DeleteAsset(EditorUtils.FullPathToADBPath(altSrcDir));
|
}
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// _src = EditorUtils.ConnectToSourceAsset<DOTweenSettings>(adbSrcFilePath, true);
|
_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.
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