Beispiel #1
0
        static void LogASMDEFChange(ASMDEFType asmdefType, ChangeType changeType)
        {
            string asmdefTypeStr = "";

            switch (asmdefType)
            {
            case ASMDEFType.Modules:
                asmdefTypeStr = "DOTween/Modules/" + _ModulesASMDEFFile;
                break;

            case ASMDEFType.DOTweenPro:
                asmdefTypeStr = "DOTweenPro/" + _ProASMDEFFile;
                break;

            case ASMDEFType.DOTweenProEditor:
                asmdefTypeStr = "DOTweenPro/Editor/" + _ProEditorASMDEFFile;
                break;
            }
            Debug.Log(string.Format(
                          "<b>DOTween ASMDEF file <color=#{0}>{1}</color></b> ► {2}",
                          changeType == ChangeType.Deleted ? "ff0000" : changeType == ChangeType.Created ? "00ff00" : "ff6600",
                          changeType == ChangeType.Deleted ? "removed" : changeType == ChangeType.Created ? "created" : "changed",
                          asmdefTypeStr
                          ));
        }
Beispiel #2
0
        static void RemoveASMDEF(ASMDEFType type)
        {
            bool   alreadyPresent = false;
            string asmdefFile     = null;
            string asmdefDir      = null; // with final OS slash

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

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

            case ASMDEFType.DOTweenProEditor:
                alreadyPresent = hasProEditorASMDEF;
                asmdefFile     = _ProEditorASMDEFFile;
                asmdefDir      = EditorUtils.dotweenProEditorDir;
                break;
            }

            Refresh();
            if (!alreadyPresent)
            {
                EditorUtility.DisplayDialog("Remove ASMDEF", asmdefFile + " not present", "Ok");
                return;
            }

            string asmdefFilePath = asmdefDir + asmdefFile;

            AssetDatabase.DeleteAsset(EditorUtils.FullPathToADBPath(asmdefFilePath));
            Refresh();
            LogASMDEFChange(type, ChangeType.Deleted);
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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);
        }