예제 #1
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            string[] dotweenEntries  = System.Array.FindAll(importedAssets, name => name.Contains("DOTween") && !name.EndsWith(".meta") && !name.EndsWith(".jpg") && !name.EndsWith(".png"));
            bool     dotweenImported = dotweenEntries.Length > 0;

            if (dotweenImported)
            {
                bool openSetupDialog = EditorUtils.DOTweenSetupRequired() &&
                                       (EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.Id) != Application.dataPath + DOTween.Version ||
                                        EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.IdPro) != Application.dataPath + EditorUtils.proVersion);
                if (openSetupDialog)
                {
                    EditorPrefs.SetString(Application.dataPath + DOTweenUtilityWindow.Id, Application.dataPath + DOTween.Version);
                    EditorPrefs.SetString(Application.dataPath + DOTweenUtilityWindow.IdPro, Application.dataPath + EditorUtils.proVersion);
                    EditorUtility.DisplayDialog("DOTween", "DOTween needs to be setup.\n\nSelect \"Tools > DOTween Utility Panel\" and press \"Setup DOTween...\" in the panel that opens.", "Ok");
                    // Opening window after a postProcess doesn't work on Unity 3 so check that
                    string[] vs           = Application.unityVersion.Split("."[0]);
                    int      majorVersion = System.Convert.ToInt32(vs[0]);
                    if (majorVersion >= 4)
                    {
                        DOTweenUtilityWindow.Open();
                    }
                }
            }
        }
예제 #2
0
        public static void Open()
        {
            DOTweenUtilityWindow window = EditorWindow.GetWindow <DOTweenUtilityWindow>(true, "DOTween Utility Panel", true);

            window.minSize = DOTweenUtilityWindow._WinSize;
            window.maxSize = DOTweenUtilityWindow._WinSize;
            window.ShowUtility();
            EditorPrefs.SetString("DOTweenVersion", DOTween.Version);
            EditorPrefs.SetString("DOTweenProVersion", EditorUtils.proVersion);
        }
예제 #3
0
        static void OnReset(DOTweenAnimation src)
        {
            DOTweenSettings settings = DOTweenUtilityWindow.GetDOTweenSettings();

            if (settings == null)
            {
                return;
            }

            Undo.RecordObject(src, "DOTweenAnimation");
            src.autoPlay = settings.defaultAutoPlay == AutoPlay.All || settings.defaultAutoPlay == AutoPlay.AutoPlayTweeners;
            src.autoKill = settings.defaultAutoKill;
            EditorUtility.SetDirty(src);
        }
예제 #4
0
        static bool _setupDialogRequested; // Used to prevent OnPostProcessAllAssets firing twice (because of a Unity bug/feature)

        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            if (_setupDialogRequested)
            {
                return;
            }

            string[] dotweenEntries  = System.Array.FindAll(importedAssets, name => name.Contains("DOTween") && !name.EndsWith(".meta") && !name.EndsWith(".jpg") && !name.EndsWith(".png"));
            bool     dotweenImported = dotweenEntries.Length > 0;

            if (dotweenImported)
            {
                // Delete old DOTween files
                EditorUtils.DeleteLegacyNoModulesDOTweenFiles();
                // Delete old DemiLib configuration
                EditorUtils.DeleteOldDemiLibCore();
                // Remove old legacy defines
                DOTweenDefines.RemoveAllLegacyDefines();
                // Reapply modules
                DOTweenUtilityWindowModules.ApplyModulesSettings();
                //
                bool differentCoreVersion = EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.Id) != Application.dataPath + DOTween.Version;
                bool differentProVersion  = EditorUtils.hasPro && EditorPrefs.GetString(Application.dataPath + DOTweenUtilityWindow.IdPro) != Application.dataPath + EditorUtils.proVersion;
                bool setupRequired        = differentCoreVersion || differentProVersion;
                if (setupRequired)
                {
                    _setupDialogRequested = true;
                    EditorPrefs.SetString(Application.dataPath + DOTweenUtilityWindow.Id, Application.dataPath + DOTween.Version);
                    if (EditorUtils.hasPro)
                    {
                        EditorPrefs.SetString(Application.dataPath + DOTweenUtilityWindow.IdPro, Application.dataPath + EditorUtils.proVersion);
                    }
//                    EditorUtility.DisplayDialog("DOTween",
//                        differentCoreVersion
//                        ? "New version of DOTween imported." +
//                          "\n\nSelect \"Setup DOTween...\" in DOTween's Utility Panel to add/remove Modules."
//                        : "New version of DOTween Pro imported." +
//                          " \n\nSelect \"Setup DOTween...\" in DOTween's Utility Panel to add/remove external Modules (TextMesh Pro/2DToolkit/etc).",
//                        "Ok"
//                    );
                    DOTweenUtilityWindow.Open();
                    // Opening window after a postProcess doesn't work on Unity 3 so check that
//                    string[] vs = Application.unityVersion.Split("."[0]);
//                    int majorVersion = System.Convert.ToInt32(vs[0]);
//                    if (majorVersion >= 4) EditorUtils.DelayedCall(0.5f, DOTweenUtilityWindow.Open);
//                    EditorUtils.DelayedCall(8, ()=> _setupDialogRequested = false);
                }
            }
        }
예제 #5
0
 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);
     }
 }
예제 #6
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);
        }
        void OnEnable()
        {
            _src      = target as DOTweenAnimation;
            _settings = DOTweenUtilityWindow.GetDOTweenSettings();

            onStartProperty        = base.serializedObject.FindProperty("onStart");
            onPlayProperty         = base.serializedObject.FindProperty("onPlay");
            onUpdateProperty       = base.serializedObject.FindProperty("onUpdate");
            onStepCompleteProperty = base.serializedObject.FindProperty("onStepComplete");
            onCompleteProperty     = base.serializedObject.FindProperty("onComplete");
            onRewindProperty       = base.serializedObject.FindProperty("onRewind");
            onTweenCreatedProperty = base.serializedObject.FindProperty("onTweenCreated");

            int len = _AnimationType.Length;

            _animationTypeNoSlashes = new string[len];
            for (int i = 0; i < len; ++i)
            {
                string a = _AnimationType[i];
                a = a.Replace("/", "");
                _animationTypeNoSlashes[i] = a;
            }
        }
예제 #8
0
 private static void ShowWindow()
 {
     DOTweenUtilityWindow.Open();
 }
예제 #9
0
        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);
            }
        }
예제 #10
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);
        }