Exemplo n.º 1
0
        private void CheckSelfMod()
        {
            _Mod = null;
            var path = UnityEditor.AssetDatabase.GetAssetPath(this);

            if (!string.IsNullOrEmpty(path))
            {
                _Mod = "";
                if (path.StartsWith("Assets/Mods/"))
                {
                    path = path.Substring("Assets/Mods/".Length);
                    var im = path.IndexOf("/");
                    if (im > 0)
                    {
                        path = path.Substring(0, im);
                        _Mod = path;
                    }
                }
                else if (path.StartsWith("Packages/"))
                {
                    path = path.Substring("Packages/".Length);
                    var im = path.IndexOf("/");
                    if (im > 0)
                    {
                        path = path.Substring(0, im);
                        _Mod = EditorToClientUtils.GetModNameFromPackageName(path);
                    }
                }
            }
        }
 public static string GetModNameFromPackageName(string package)
 {
     return(EditorToClientUtils.GetModNameFromPackageName(package));
 }
        public static string GetAssetNormPath(string rawpath, out string type, out string mod, out string dist)
        {
            if (rawpath != null)
            {
                rawpath = rawpath.Replace('\\', '/');
                string norm = rawpath;
                mod = "";
                if (rawpath.StartsWith("Assets/Mods/"))
                {
                    var sub   = rawpath.Substring("Assets/Mods/".Length);
                    var index = sub.IndexOf('/');
                    if (index < 0)
                    {
                        mod  = sub;
                        type = null;
                        dist = "";
                        return("");
                    }
                    mod  = sub.Substring(0, index);
                    norm = sub.Substring(index + 1);
                }
                else if (rawpath.StartsWith("Packages/"))
                {
                    var sub   = rawpath.Substring("Packages/".Length);
                    var index = sub.IndexOf('/');
                    if (index < 0)
                    {
                        mod = sub;
                    }
                    else
                    {
                        mod  = sub.Substring(0, index);
                        norm = sub.Substring(index + 1);
                    }
#if UNITY_EDITOR
                    mod = EditorToClientUtils.GetModNameFromPackageName(mod);
#endif
                    if (index < 0)
                    {
                        type = null;
                        dist = "";
                        return("");
                    }
                }
                else if (rawpath.StartsWith("Assets/"))
                {
                    mod  = "";
                    norm = rawpath.Substring("Assets/".Length);
                }
                else
                {
                    mod  = "";
                    dist = "";
                    type = null;
                    return(rawpath);
                }
                if (norm.StartsWith("CapsSpt/"))
                {
                    type = "spt";
                    norm = norm.Substring("CapsSpt/".Length);
                }
                else if (norm.StartsWith("CapsRes/"))
                {
                    type = "res";
                    norm = norm.Substring("CapsRes/".Length);
                }
                else
                {
                    dist = "";
                    type = null;
                    if (string.IsNullOrEmpty(mod))
                    {
                        return(rawpath);
                    }
                    else
                    {
                        return(norm);
                    }
                }
                if (norm.StartsWith("dist/"))
                {
                    var sub   = norm.Substring("dist/".Length);
                    var index = sub.IndexOf('/');
                    if (index < 0)
                    {
                        dist = sub;
                        return("");
                    }
                    dist = sub.Substring(0, index);
                    norm = sub.Substring(index + 1);
                }
                else
                {
                    dist = "";
                }
                return(norm);
            }
            else
            {
                type = null;
                mod  = null;
                dist = null;
                return(null);
            }
        }