Beispiel #1
0
        // ===================================================================================
        // MONOBEHAVIOUR METHODS -------------------------------------------------------------

        void OnEnable()
        {
            if (_settings == null)
            {
                _settings = Resources.Load(DOTweenSettings.AssetName) as DOTweenSettings;
            }

            _strBuilder.Remove(0, _strBuilder.Length);
            _strBuilder.Append("DOTween v").Append(DOTween.Version);
            if (TweenManager.isDebugBuild)
            {
                _strBuilder.Append(" [Debug build]");
            }
            else
            {
                _strBuilder.Append(" [Release build]");
            }

            if (EditorUtils.hasPro)
            {
                _strBuilder.Append("\nDOTweenPro v").Append(EditorUtils.proVersion);
            }
            else
            {
                _strBuilder.Append("\nDOTweenPro not installed");
            }
            _title = _strBuilder.ToString();
        }
        public static void Refresh(DOTweenSettings src, bool applySrcSettings = false)
        {
            _src       = src;
            _refreshed = true;

            AssetDatabase.StartAssetEditing();
            _audioModule.enabled     = ModuleIsEnabled(_audioModule);
            _physicsModule.enabled   = ModuleIsEnabled(_physicsModule);
            _physics2DModule.enabled = ModuleIsEnabled(_physics2DModule);
            _spriteModule.enabled    = ModuleIsEnabled(_spriteModule);
            _uiModule.enabled        = ModuleIsEnabled(_uiModule);
            //
            _textMeshProModule.enabled = ModuleIsEnabled(_textMeshProModule);
            _tk2DModule.enabled        = ModuleIsEnabled(_tk2DModule);

            CheckAutoModuleSettings(applySrcSettings, _audioModule, ref src.modules.audioEnabled);
            CheckAutoModuleSettings(applySrcSettings, _physicsModule, ref src.modules.physicsEnabled);
            CheckAutoModuleSettings(applySrcSettings, _physics2DModule, ref src.modules.physics2DEnabled);
            CheckAutoModuleSettings(applySrcSettings, _spriteModule, ref src.modules.spriteEnabled);
            CheckAutoModuleSettings(applySrcSettings, _uiModule, ref src.modules.uiEnabled);
            //
            CheckAutoModuleSettings(applySrcSettings, _textMeshProModule, ref src.modules.textMeshProEnabled);
            CheckAutoModuleSettings(applySrcSettings, _tk2DModule, ref src.modules.tk2DEnabled);
            AssetDatabase.StopAssetEditing();

            EditorUtility.SetDirty(_src);
        }
        // ===================================================================================
        // METHODS ---------------------------------------------------------------------------

        void Connect()
        {
            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 old mode (inside DOTween/Resources folder) and eventually move them
                string legacySrcDir      = EditorUtils.dotweenDir + "Resources";
                string legacySrcFilePath = legacySrcDir + 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(legacySrcDir));
                }

                _src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(adbSrcFilePath, true);
            }
        }
Beispiel #4
0
 private static IDOTweenInit Init(DOTweenSettings settings, bool?recycleAllByDefault, bool?useSafeMode, LogBehaviour?logBehaviour)
 {
     DOTween.initialized = true;
     if (recycleAllByDefault.HasValue)
     {
         DOTween.defaultRecyclable = recycleAllByDefault.Value;
     }
     if (useSafeMode.HasValue)
     {
         DOTween.useSafeMode = useSafeMode.Value;
     }
     if (logBehaviour.HasValue)
     {
         DOTween.logBehaviour = logBehaviour.Value;
     }
     DOTweenComponent.Create();
     if (settings != null)
     {
         if (!useSafeMode.HasValue)
         {
             DOTween.useSafeMode = settings.useSafeMode;
         }
         if (!logBehaviour.HasValue)
         {
             DOTween.logBehaviour = settings.logBehaviour;
         }
         if (!recycleAllByDefault.HasValue)
         {
             DOTween.defaultRecyclable = settings.defaultRecyclable;
         }
         DOTween.timeScale                       = settings.timeScale;
         DOTween.useSmoothDeltaTime              = settings.useSmoothDeltaTime;
         DOTween.defaultRecyclable               = ((!recycleAllByDefault.HasValue) ? settings.defaultRecyclable : recycleAllByDefault.Value);
         DOTween.showUnityEditorReport           = settings.showUnityEditorReport;
         DOTween.drawGizmos                      = settings.drawGizmos;
         DOTween.defaultAutoPlay                 = settings.defaultAutoPlay;
         DOTween.defaultUpdateType               = settings.defaultUpdateType;
         DOTween.defaultTimeScaleIndependent     = settings.defaultTimeScaleIndependent;
         DOTween.defaultEaseType                 = settings.defaultEaseType;
         DOTween.defaultEaseOvershootOrAmplitude = settings.defaultEaseOvershootOrAmplitude;
         DOTween.defaultEasePeriod               = settings.defaultEasePeriod;
         DOTween.defaultAutoKill                 = settings.defaultAutoKill;
         DOTween.defaultLoopType                 = settings.defaultLoopType;
     }
     if (Debugger.logPriority >= 2)
     {
         Debugger.Log(string.Concat(new object[]
         {
             "DOTween initialization (useSafeMode: ",
             DOTween.useSafeMode,
             ", recycling: ",
             DOTween.defaultRecyclable ? "ON" : "OFF",
             ", logBehaviour: ",
             DOTween.logBehaviour,
             ")"
         }));
     }
     return(DOTween.instance);
 }
Beispiel #5
0
 private void Connect(bool forceReconnect = false)
 {
     if ((UnityEngine.Object) this._src != (UnityEngine.Object)null && !forceReconnect)
     {
         return;
     }
     this._src = DOTweenUtilityWindow.ConnectToSource(this._src, true, true);
 }
Beispiel #6
0
        private void Connect(bool forceReconnect = false)
        {
            if ((UnityEngine.Object) this._src != (UnityEngine.Object)null && !forceReconnect)
            {
                return;
            }
            LocationData locationData  = new LocationData(EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources");
            LocationData locationData2 = new LocationData(EditorUtils.dotweenDir + "Resources");
            bool         flag          = EditorUtils.demigiantDir != null;
            LocationData locationData3 = flag ? new LocationData(EditorUtils.demigiantDir + "Resources") : default(LocationData);

            if ((UnityEngine.Object) this._src == (UnityEngine.Object)null)
            {
                this._src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(locationData.adbFilePath, false);
                if ((UnityEngine.Object) this._src == (UnityEngine.Object)null)
                {
                    this._src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(locationData2.adbFilePath, false);
                }
                if ((UnityEngine.Object) this._src == (UnityEngine.Object)null & flag)
                {
                    this._src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(locationData3.adbFilePath, false);
                }
            }
            if ((UnityEngine.Object) this._src == (UnityEngine.Object)null)
            {
                if (!Directory.Exists(locationData.dir))
                {
                    AssetDatabase.CreateFolder(locationData.adbParentDir, "Resources");
                }
                this._src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(locationData.adbFilePath, true);
            }
            switch (this._src.storeSettingsLocation)
            {
            case DOTweenSettings.SettingsLocation.AssetsDirectory:
                this.MoveSrc(new LocationData[2]
                {
                    locationData2,
                    locationData3
                }, locationData);
                break;

            case DOTweenSettings.SettingsLocation.DOTweenDirectory:
                this.MoveSrc(new LocationData[2]
                {
                    locationData,
                    locationData3
                }, locationData2);
                break;

            case DOTweenSettings.SettingsLocation.DemigiantDirectory:
                this.MoveSrc(new LocationData[2]
                {
                    locationData,
                    locationData2
                }, locationData3);
                break;
            }
        }
Beispiel #7
0
        // Returns TRUE if it should be closed
        public static bool Draw(EditorWindow editor, DOTweenSettings src)
        {
            _editor = editor;
            _src    = src;
            if (!_refreshed)
            {
                Refresh(_src);
            }

            GUILayout.Label("Add/Remove Modules", EditorGUIUtils.titleStyle);

            GUILayout.BeginVertical();
            EditorGUI.BeginDisabledGroup(EditorApplication.isCompiling);
            GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
            GUILayout.Label("Unity", EditorGUIUtils.boldLabelStyle);
            _audioModule.enabled     = EditorGUILayout.Toggle("Audio", _audioModule.enabled);
            _physicsModule.enabled   = EditorGUILayout.Toggle("Physics", _physicsModule.enabled);
            _physics2DModule.enabled = EditorGUILayout.Toggle("Physics2D", _physics2DModule.enabled);
            _spriteModule.enabled    = EditorGUILayout.Toggle("Sprites", _spriteModule.enabled);
            _uiModule.enabled        = EditorGUILayout.Toggle("UI", _uiModule.enabled);
            EditorGUILayout.EndVertical();
            if (EditorUtils.hasPro)
            {
                GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
                GUILayout.Label("External Assets (Pro)", EditorGUIUtils.boldLabelStyle);
                GUILayout.Label(
                    "<b>IMPORTANT:</b> these modules are for external Unity assets." +
                    "\n<i>DO NOT activate an external module</i> unless you have the relative asset in your project.",
                    EditorGUIUtils.wordWrapRichTextLabelStyle
                    );
                _textMeshProModule.enabled = EditorGUILayout.Toggle("TextMesh Pro", _textMeshProModule.enabled);
                _tk2DModule.enabled        = EditorGUILayout.Toggle("2D Toolkit", _tk2DModule.enabled);
                EditorGUILayout.EndVertical();
            }

            GUILayout.Space(2);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Apply"))
            {
                Apply();
                Refresh(_src);
                return(true);
            }
            if (GUILayout.Button("Cancel"))
            {
                return(true);
            }
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();
            GUILayout.EndVertical();

            if (EditorApplication.isCompiling)
            {
                WaitForCompilation();
            }

            return(false);
        }
        // Also called via Reflection by Autorun
        public static void ApplyModulesSettings()
        {
            DOTweenSettings src = DOTweenUtilityWindow.GetDOTweenSettings();

            if (src != null)
            {
                Refresh(src, true);
            }
        }
        static DOTweenSettings ConnectToSource(DOTweenSettings src, bool createIfMissing, bool fullSetup)
        {
            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>(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.
                if (!createIfMissing)
                {
                    return(null);                  // Stop here
                }
                // Create it in external folder
                if (!Directory.Exists(assetsLD.dir))
                {
                    AssetDatabase.CreateFolder(assetsLD.adbParentDir, "Resources");
                }
                src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(assetsLD.adbFilePath, true);
            }

            if (fullSetup)
            {
                // Move eventual settings from previous location and setup everything correctly
                DOTweenSettings.SettingsLocation settingsLoc = src.storeSettingsLocation;
                switch (settingsLoc)
                {
                case DOTweenSettings.SettingsLocation.AssetsDirectory:
                    src = MoveSrc(new[] { dotweenLD, demigiantLD }, assetsLD);
                    break;

                case DOTweenSettings.SettingsLocation.DOTweenDirectory:
                    src = MoveSrc(new[] { assetsLD, demigiantLD }, dotweenLD);
                    break;

                case DOTweenSettings.SettingsLocation.DemigiantDirectory:
                    src = MoveSrc(new[] { assetsLD, dotweenLD }, demigiantLD);
                    break;
                }
            }

            return(src);
        }
Beispiel #10
0
        public static void ApplyModulesSettings()
        {
            DOTweenSettings doTweenSettings = DOTweenUtilityWindow.GetDOTweenSettings();

            if (!((Object)doTweenSettings != (Object)null))
            {
                return;
            }
            DOTweenUtilityWindowModules.Refresh(doTweenSettings, true);
        }
        void ConnectToSource(bool forceReconnection = false)
        {
            _headerImg = AssetDatabase.LoadAssetAtPath("Assets/" + EditorUtils.editorADBDir + "Imgs/DOTweenIcon.png", typeof(Texture2D)) as Texture2D;

            if (_settings == null || forceReconnection)
            {
                _settings = _isRuntime
                    ? Resources.Load(DOTweenSettings.AssetName) as DOTweenSettings
                    : DOTweenUtilityWindow.GetDOTweenSettings();
            }
        }
        // Returns TRUE if it should be closed
        public static bool Draw(EditorWindow editor, DOTweenSettings src)
        {
            _editor = editor;
            _src    = src;
            if (!_refreshed)
            {
                Refresh(_src);
            }

            GUILayout.Label("Add/Remove Modules", EditorGUIUtils.titleStyle);

            GUILayout.BeginVertical();
            EditorGUI.BeginDisabledGroup(EditorApplication.isCompiling);
            GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
            GUILayout.Label("Unity", EditorGUIUtils.boldLabelStyle);
            _audioModule.enabled     = EditorGUILayout.Toggle("Audio", _audioModule.enabled);
            _physicsModule.enabled   = EditorGUILayout.Toggle("Physics", _physicsModule.enabled);
            _physics2DModule.enabled = EditorGUILayout.Toggle("Physics2D", _physics2DModule.enabled);
            _spriteModule.enabled    = EditorGUILayout.Toggle("Sprites", _spriteModule.enabled);
            _uiModule.enabled        = EditorGUILayout.Toggle("UI", _uiModule.enabled);
            EditorGUILayout.EndVertical();
            if (EditorUtils.hasPro)
            {
                GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
                GUILayout.Label("External Assets (Pro)", EditorGUIUtils.boldLabelStyle);
                _textMeshProModule.enabled = EditorGUILayout.Toggle("TextMesh Pro", _textMeshProModule.enabled);
                _tk2DModule.enabled        = EditorGUILayout.Toggle("2D Toolkit", _tk2DModule.enabled);
                EditorGUILayout.EndVertical();
            }

            GUILayout.Space(2);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Apply"))
            {
                Apply();
                Refresh(_src);
                return(true);
            }
            if (GUILayout.Button("Cancel"))
            {
                return(true);
            }
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();
            GUILayout.EndVertical();

            if (EditorApplication.isCompiling)
            {
                WaitForCompilation();
            }

            return(false);
        }
        private void Connect(bool forceReconnect = false)
        {
            if ((this._src == null) || forceReconnect)
            {
                LocationData to    = new LocationData(EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources");
                LocationData data2 = new LocationData(EditorUtils.dotweenDir + "Resources");
                bool         flag  = EditorUtils.demigiantDir != null;
                LocationData data3 = flag ? new LocationData(EditorUtils.demigiantDir + "Resources") : new LocationData();
                if (this._src == null)
                {
                    this._src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(to.adbFilePath, false);
                    if (this._src == null)
                    {
                        this._src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(data2.adbFilePath, false);
                    }
                    if ((this._src == null) & flag)
                    {
                        this._src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(data3.adbFilePath, false);
                    }
                }
                if (this._src == null)
                {
                    if (!Directory.Exists(to.dir))
                    {
                        AssetDatabase.CreateFolder(to.adbParentDir, "Resources");
                    }
                    this._src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(to.adbFilePath, true);
                }
                switch (this._src.storeSettingsLocation)
                {
                case DOTweenSettings.SettingsLocation.AssetsDirectory:
                {
                    LocationData[] from = new LocationData[] { data2, data3 };
                    this.MoveSrc(from, to);
                    return;
                }

                case DOTweenSettings.SettingsLocation.DOTweenDirectory:
                {
                    LocationData[] dataArray2 = new LocationData[] { to, data3 };
                    this.MoveSrc(dataArray2, data2);
                    return;
                }

                case DOTweenSettings.SettingsLocation.DemigiantDirectory:
                {
                    LocationData[] dataArray3 = new LocationData[] { to, data2 };
                    this.MoveSrc(dataArray3, data3);
                    return;
                }
                }
            }
        }
        // ===================================================================================
        // METHODS ---------------------------------------------------------------------------

        void Connect(bool forceReconnect = false)
        {
            if (_src != null && !forceReconnect)
            {
                return;
            }

            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>(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(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:
                MoveSrc(new[] { dotweenLD, demigiantLD }, assetsLD);
                break;

            case DOTweenSettings.SettingsLocation.DOTweenDirectory:
                MoveSrc(new[] { assetsLD, demigiantLD }, dotweenLD);
                break;

            case DOTweenSettings.SettingsLocation.DemigiantDirectory:
                MoveSrc(new[] { assetsLD, dotweenLD }, demigiantLD);
                break;
            }
        }
Beispiel #15
0
        public static IDOTweenInit Init(bool?recycleAllByDefault = null, bool?useSafeMode = null, LogBehaviour?logBehaviour = null)
        {
            if (DOTween.initialized)
            {
                return(DOTween.instance);
            }
            if (!Application.isPlaying || DOTween.isQuitting)
            {
                return(null);
            }
            DOTweenSettings settings = Resources.Load(DOTweenSettings.AssetName) as DOTweenSettings;

            return(DOTween.Init(settings, recycleAllByDefault, useSafeMode, logBehaviour));
        }
 public static void RefreshExistingASMDEFFiles()
 {
     ASMDEFManager.Refresh();
     if (!ASMDEFManager.hasModulesASMDEF)
     {
         if (!ASMDEFManager.hasProASMDEF)
         {
             return;
         }
         ASMDEFManager.RemoveASMDEF(ASMDEFManager.ASMDEFType.DOTweenPro);
     }
     else if (EditorUtils.hasPro && !ASMDEFManager.hasProASMDEF)
     {
         ASMDEFManager.CreateASMDEF(ASMDEFManager.ASMDEFType.DOTweenPro, false);
     }
     else if (EditorUtils.hasPro)
     {
         DOTweenSettings doTweenSettings = DOTweenUtilityWindow.GetDOTweenSettings();
         if ((Object)doTweenSettings == (Object)null)
         {
             return;
         }
         bool flag = false;
         using (StreamReader streamReader = new StreamReader(EditorUtils.dotweenProDir + "DOTweenPro.Scripts.asmdef"))
         {
             string str;
             while ((str = streamReader.ReadLine()) != null)
             {
                 if (str.Contains("Unity.TextMeshPro"))
                 {
                     flag = true;
                     break;
                 }
             }
         }
         if (flag == doTweenSettings.modules.textMeshProEnabled)
         {
             return;
         }
         ASMDEFManager.CreateASMDEF(ASMDEFManager.ASMDEFType.DOTweenPro, true);
     }
 }
Beispiel #17
0
 private void MoveSrc(LocationData[] from, LocationData to)
 {
     if (!Directory.Exists(to.dir))
     {
         AssetDatabase.CreateFolder(to.adbParentDir, "Resources");
     }
     foreach (LocationData locationData in from)
     {
         if (File.Exists(locationData.filePath))
         {
             AssetDatabase.MoveAsset(locationData.adbFilePath, to.adbFilePath);
             AssetDatabase.DeleteAsset(locationData.adbFilePath);
             if (Directory.GetDirectories(locationData.dir).Length == 0 && Directory.GetFiles(locationData.dir).Length == 0)
             {
                 AssetDatabase.DeleteAsset(EditorUtils.FullPathToADBPath(locationData.dir));
             }
         }
     }
     this._src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(to.adbFilePath, true);
 }
Beispiel #18
0
        public static void RefreshExistingASMDEFFiles()
        {
            Refresh();

            if (!hasModulesASMDEF)
            {
                if (hasProASMDEF)
                {
                    RemoveASMDEF(ASMDEFType.DOTweenPro);
                }
                if (hasProEditorASMDEF)
                {
                    RemoveASMDEF(ASMDEFType.DOTweenProEditor);
                }
                return;
            }
            if (EditorUtils.hasPro)
            {
                if (!hasProASMDEF)
                {
                    CreateASMDEF(ASMDEFType.DOTweenPro);
                }
                if (!hasProEditorASMDEF)
                {
                    CreateASMDEF(ASMDEFType.DOTweenProEditor);
                }
            }

            // Pro ASMDEF present: check that they contain correct elements
            DOTweenSettings src = DOTweenUtilityWindow.GetDOTweenSettings();

            if (src == null)
            {
                return;
            }

            ValidateProASMDEFReferences(src, ASMDEFType.DOTweenPro, EditorUtils.dotweenProDir + _ProASMDEFFile);
            ValidateProASMDEFReferences(src, ASMDEFType.DOTweenProEditor, EditorUtils.dotweenProEditorDir + _ProEditorASMDEFFile);
        }
Beispiel #19
0
 public static void Refresh(DOTweenSettings src, bool applySrcSettings = false)
 {
     DOTweenUtilityWindowModules._src       = src;
     DOTweenUtilityWindowModules._refreshed = true;
     AssetDatabase.StartAssetEditing();
     DOTweenUtilityWindowModules._audioModule.enabled       = DOTweenUtilityWindowModules.ModuleIsEnabled(DOTweenUtilityWindowModules._audioModule);
     DOTweenUtilityWindowModules._physicsModule.enabled     = DOTweenUtilityWindowModules.ModuleIsEnabled(DOTweenUtilityWindowModules._physicsModule);
     DOTweenUtilityWindowModules._physics2DModule.enabled   = DOTweenUtilityWindowModules.ModuleIsEnabled(DOTweenUtilityWindowModules._physics2DModule);
     DOTweenUtilityWindowModules._spriteModule.enabled      = DOTweenUtilityWindowModules.ModuleIsEnabled(DOTweenUtilityWindowModules._spriteModule);
     DOTweenUtilityWindowModules._uiModule.enabled          = DOTweenUtilityWindowModules.ModuleIsEnabled(DOTweenUtilityWindowModules._uiModule);
     DOTweenUtilityWindowModules._textMeshProModule.enabled = DOTweenUtilityWindowModules.ModuleIsEnabled(DOTweenUtilityWindowModules._textMeshProModule);
     DOTweenUtilityWindowModules._tk2DModule.enabled        = DOTweenUtilityWindowModules.ModuleIsEnabled(DOTweenUtilityWindowModules._tk2DModule);
     DOTweenUtilityWindowModules.CheckAutoModuleSettings(applySrcSettings, DOTweenUtilityWindowModules._audioModule, ref src.modules.audioEnabled);
     DOTweenUtilityWindowModules.CheckAutoModuleSettings(applySrcSettings, DOTweenUtilityWindowModules._physicsModule, ref src.modules.physicsEnabled);
     DOTweenUtilityWindowModules.CheckAutoModuleSettings(applySrcSettings, DOTweenUtilityWindowModules._physics2DModule, ref src.modules.physics2DEnabled);
     DOTweenUtilityWindowModules.CheckAutoModuleSettings(applySrcSettings, DOTweenUtilityWindowModules._spriteModule, ref src.modules.spriteEnabled);
     DOTweenUtilityWindowModules.CheckAutoModuleSettings(applySrcSettings, DOTweenUtilityWindowModules._uiModule, ref src.modules.uiEnabled);
     DOTweenUtilityWindowModules.CheckAutoModuleSettings(applySrcSettings, DOTweenUtilityWindowModules._textMeshProModule, ref src.modules.textMeshProEnabled);
     DOTweenUtilityWindowModules.CheckAutoModuleSettings(applySrcSettings, DOTweenUtilityWindowModules._tk2DModule, ref src.modules.tk2DEnabled);
     AssetDatabase.StopAssetEditing();
     EditorUtility.SetDirty((Object)DOTweenUtilityWindowModules._src);
 }
Beispiel #20
0
        static void ValidateProASMDEFReferences(DOTweenSettings src, ASMDEFType asmdefType, string asmdefFilepath)
        {
            bool hasTextMeshProRef = false;

            using (StreamReader sr = new StreamReader(asmdefFilepath)) {
                string s;
                while ((s = sr.ReadLine()) != null)
                {
                    if (!s.Contains(_RefTextMeshPro))
                    {
                        continue;
                    }
                    hasTextMeshProRef = true;
                    break;
                }
            }
            bool recreate = hasTextMeshProRef != src.modules.textMeshProEnabled;

            if (recreate)
            {
                CreateASMDEF(asmdefType, 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);
 }
        // ===================================================================================
        // MONOBEHAVIOUR METHODS -------------------------------------------------------------

        void OnEnable()
        {
            _src = target as DOTweenSettings;
        }
Beispiel #23
0
        static void CreateASMDEF(ASMDEFType type, bool forceOverwrite = false)
        {
            Refresh();
            bool   alreadyPresent = false;
            string asmdefId       = null;
            string asmdefFile     = null;
            string asmdefDir      = null; // with final OS slash

            switch (type)
            {
            case ASMDEFType.Modules:
                alreadyPresent = hasModulesASMDEF;
                asmdefId       = _ModulesId;
                asmdefFile     = _ModulesASMDEFFile;
                asmdefDir      = EditorUtils.dotweenModulesDir;
                break;

            case ASMDEFType.DOTweenPro:
                alreadyPresent = hasProASMDEF;
                asmdefId       = _ProId;
                asmdefFile     = _ProASMDEFFile;
                asmdefDir      = EditorUtils.dotweenProDir;
                break;

            case ASMDEFType.DOTweenProEditor:
                alreadyPresent = hasProEditorASMDEF;
                asmdefId       = _ProEditorId;
                asmdefFile     = _ProEditorASMDEFFile;
                asmdefDir      = EditorUtils.dotweenProEditorDir;
                break;
            }
            if (alreadyPresent && !forceOverwrite)
            {
                EditorUtility.DisplayDialog("Create ASMDEF", asmdefFile + " already exists", "Ok");
                return;
            }
            if (!Directory.Exists(asmdefDir))
            {
                EditorUtility.DisplayDialog(
                    "Create ASMDEF",
                    string.Format("Directory not found\n({0})", asmdefDir),
                    "Ok"
                    );
                return;
            }

            string asmdefFilePath = asmdefDir + asmdefFile;

            using (StreamWriter sw = File.CreateText(asmdefFilePath)) {
                sw.WriteLine("{");
                switch (type)
                {
                case ASMDEFType.Modules:
                    sw.WriteLine("\t\"name\": \"{0}\"", asmdefId);
                    break;

                case ASMDEFType.DOTweenPro:
                case ASMDEFType.DOTweenProEditor:
                    sw.WriteLine("\t\"name\": \"{0}\",", asmdefId);
                    sw.WriteLine("\t\"references\": [");
                    DOTweenSettings src = DOTweenUtilityWindow.GetDOTweenSettings();
                    if (src != null)
                    {
                        if (src.modules.textMeshProEnabled)
                        {
                            sw.WriteLine("\t\t\"{0}\",", _RefTextMeshPro);
                        }
                    }
                    if (type == ASMDEFType.DOTweenProEditor)
                    {
                        sw.WriteLine("\t\t\"{0}\",", _ModulesId);
                        sw.WriteLine("\t\t\"{0}\"", _ProId);
                        sw.WriteLine("\t],");
                        sw.WriteLine("\t\"includePlatforms\": [");
                        sw.WriteLine("\t\t\"Editor\"");
                        sw.WriteLine("\t],");
                        sw.WriteLine("\t\"autoReferenced\": false");
                    }
                    else
                    {
                        sw.WriteLine("\t\t\"{0}\"", _ModulesId);
                        sw.WriteLine("\t]");
                    }
                    break;
                }
                sw.WriteLine("}");
            }
            string adbFilePath = EditorUtils.FullPathToADBPath(asmdefFilePath);

            AssetDatabase.ImportAsset(adbFilePath, ImportAssetOptions.ForceUpdate);
            Refresh();
            LogASMDEFChange(type, alreadyPresent ? ChangeType.Overwritten : ChangeType.Created);
        }
        private static void CreateASMDEF(ASMDEFManager.ASMDEFType type, bool forceOverwrite = false)
        {
            ASMDEFManager.Refresh();
            bool   flag = false;
            string str1 = (string)null;
            string str2 = (string)null;
            string path = (string)null;

            switch (type)
            {
            case ASMDEFManager.ASMDEFType.Modules:
                flag = ASMDEFManager.hasModulesASMDEF;
                str1 = "DOTween.Modules";
                str2 = "DOTween.Modules.asmdef";
                path = EditorUtils.dotweenModulesDir;
                break;

            case ASMDEFManager.ASMDEFType.DOTweenPro:
                flag = ASMDEFManager.hasProASMDEF;
                str1 = "DOTweenPro.Scripts";
                str2 = "DOTweenPro.Scripts.asmdef";
                path = EditorUtils.dotweenProDir;
                break;
            }
            if (flag && !forceOverwrite)
            {
                EditorUtility.DisplayDialog("Create ASMDEF", str2 + " already exists", "Ok");
            }
            else if (!Directory.Exists(path))
            {
                EditorUtility.DisplayDialog("Create ASMDEF", string.Format("Directory not found\n({0})", (object)path), "Ok");
            }
            else
            {
                string str3 = path + str2;
                using (StreamWriter text = File.CreateText(str3))
                {
                    text.WriteLine("{");
                    switch (type)
                    {
                    case ASMDEFManager.ASMDEFType.Modules:
                        text.WriteLine("\t\"name\": \"{0}\"", (object)str1);
                        break;

                    case ASMDEFManager.ASMDEFType.DOTweenPro:
                        text.WriteLine("\t\"name\": \"{0}\",", (object)str1);
                        text.WriteLine("\t\"references\": [");
                        DOTweenSettings doTweenSettings = DOTweenUtilityWindow.GetDOTweenSettings();
                        if ((Object)doTweenSettings != (Object)null && doTweenSettings.modules.textMeshProEnabled)
                        {
                            text.WriteLine("\t\t\"{0}\",", (object)"Unity.TextMeshPro");
                        }
                        text.WriteLine("\t\t\"{0}\"", (object)"DOTween.Modules");
                        text.WriteLine("\t]");
                        break;
                    }
                    text.WriteLine("}");
                }
                AssetDatabase.ImportAsset(EditorUtils.FullPathToADBPath(str3), ImportAssetOptions.ForceUpdate);
                ASMDEFManager.Refresh();
                ASMDEFManager.LogASMDEFChange(type, flag ? ASMDEFManager.ChangeType.Overwritten : ASMDEFManager.ChangeType.Created);
            }
        }
Beispiel #25
0
        private static DOTweenSettings ConnectToSource(DOTweenSettings src, bool createIfMissing, bool fullSetup)
        {
            DOTweenUtilityWindow.LocationData to1 = new DOTweenUtilityWindow.LocationData(EditorUtils.assetsPath + EditorUtils.pathSlash + "Resources");
            DOTweenUtilityWindow.LocationData to2 = new DOTweenUtilityWindow.LocationData(EditorUtils.dotweenDir + "Resources");
            bool flag = EditorUtils.demigiantDir != null;

            DOTweenUtilityWindow.LocationData to3 = flag ? new DOTweenUtilityWindow.LocationData(EditorUtils.demigiantDir + "Resources") : new DOTweenUtilityWindow.LocationData();
            if ((UnityEngine.Object)src == (UnityEngine.Object)null)
            {
                src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(to1.adbFilePath, false);
                if ((UnityEngine.Object)src == (UnityEngine.Object)null)
                {
                    src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(to2.adbFilePath, false);
                }
                if ((UnityEngine.Object)src == (UnityEngine.Object)null & flag)
                {
                    src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(to3.adbFilePath, false);
                }
            }
            if ((UnityEngine.Object)src == (UnityEngine.Object)null)
            {
                if (!createIfMissing)
                {
                    return((DOTweenSettings)null);
                }
                if (!Directory.Exists(to1.dir))
                {
                    AssetDatabase.CreateFolder(to1.adbParentDir, "Resources");
                }
                src = EditorUtils.ConnectToSourceAsset <DOTweenSettings>(to1.adbFilePath, true);
            }
            if (fullSetup)
            {
                switch (src.storeSettingsLocation)
                {
                case DOTweenSettings.SettingsLocation.AssetsDirectory:
                    src = DOTweenUtilityWindow.MoveSrc(new DOTweenUtilityWindow.LocationData[2]
                    {
                        to2,
                        to3
                    }, to1);
                    break;

                case DOTweenSettings.SettingsLocation.DOTweenDirectory:
                    src = DOTweenUtilityWindow.MoveSrc(new DOTweenUtilityWindow.LocationData[2]
                    {
                        to1,
                        to3
                    }, to2);
                    break;

                case DOTweenSettings.SettingsLocation.DemigiantDirectory:
                    src = DOTweenUtilityWindow.MoveSrc(new DOTweenUtilityWindow.LocationData[2]
                    {
                        to1,
                        to2
                    }, to3);
                    break;
                }
            }
            return(src);
        }
Beispiel #26
0
        private static void AutoInit()
        {
            DOTweenSettings settings = Resources.Load(DOTweenSettings.AssetName) as DOTweenSettings;

            DOTween.Init(settings, null, null, null);
        }
Beispiel #27
0
 private void OnEnable()
 {
     this._src = (base.target as DOTweenSettings);
 }