Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        public static void Setup(bool partiallySilent = false)
        {
            if (EditorUtils.DOTweenSetupRequired())
            {
                string message = "Based on your Unity version (" + Application.unityVersion + ") and eventual plugins, DOTween will now activate additional tween elements, if available.";
                if (!EditorUtility.DisplayDialog("DOTween Setup", message, "Ok", "Cancel"))
                {
                    return;
                }
            }
            else
            {
                if (partiallySilent)
                {
                    return;
                }
                string message2 = "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("DOTween Setup", message2, "Force Setup", "Cancel"))
                {
                    return;
                }
            }
            string dotweenDir    = EditorUtils.dotweenDir;
            string dotweenProDir = EditorUtils.dotweenProDir;

            EditorUtility.DisplayProgressBar("DOTween Setup", "Please wait...", 0.25f);
            int num = 0;

            string[] array = Application.unityVersion.Split("."[0]);
            int      num2  = Convert.ToInt32(array[0]);
            int      num3  = Convert.ToInt32(array[1]);

            if (num2 < 4)
            {
                DOTweenSetupMenuItem.SetupComplete(dotweenDir, dotweenProDir, num);
            }
            else
            {
                if (num2 == 4)
                {
                    if (num3 < 3)
                    {
                        DOTweenSetupMenuItem.SetupComplete(dotweenDir, dotweenProDir, num);
                        return;
                    }
                    num += DOTweenSetupMenuItem.ImportAddons("43", dotweenDir);
                    if (num3 >= 6)
                    {
                        num += DOTweenSetupMenuItem.ImportAddons("46", dotweenDir);
                    }
                }
                else
                {
                    num += DOTweenSetupMenuItem.ImportAddons("43", dotweenDir);
                    num += DOTweenSetupMenuItem.ImportAddons("46", dotweenDir);
                    num += DOTweenSetupMenuItem.ImportAddons("50", dotweenDir);
                }
                if (EditorUtils.hasPro)
                {
                    if (DOTweenSetupMenuItem.Has2DToolkit())
                    {
                        num += DOTweenSetupMenuItem.ImportAddons("Tk2d", dotweenProDir);
                        DOTweenSetupMenuItem.ProEditor_AddGlobalDefine("DOTWEEN_TK2D");
                    }
                    else
                    {
                        DOTweenSetupMenuItem.ProEditor_RemoveGlobalDefine("DOTWEEN_TK2D");
                    }
                    if (DOTweenSetupMenuItem.HasTextMeshPro())
                    {
                        num += DOTweenSetupMenuItem.ImportAddons("TextMeshPro", dotweenProDir);
                        DOTweenSetupMenuItem.ProEditor_AddGlobalDefine("DOTWEEN_TMP");
                    }
                    else
                    {
                        DOTweenSetupMenuItem.ProEditor_RemoveGlobalDefine("DOTWEEN_TMP");
                    }
                }
                DOTweenSetupMenuItem.SetupComplete(dotweenDir, dotweenProDir, num);
            }
        }
Ejemplo n.º 3
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);
        }