示例#1
0
        public long GetOrAdd(UnityEngine.Object obj)
        {
            if (Application.isPlaying)
            {
                ES3Debug.LogError("GetOrAdd can only be called in the Editor, not during runtime");
                return(-1);
            }

            var id = Get(obj);

            if (id == -1 && UnityEditor.AssetDatabase.Contains(obj) && ES3ReferenceMgr.CanBeSaved(obj))
            {
                id = ES3ReferenceMgrBase.GetNewRefID();
                refId.Add(obj, id);

                UnityEditor.EditorUtility.SetDirty(this);
            }

            return(id);
        }
示例#2
0
        /*
         *  Given a path, it returns the directory that path points to.
         *  eg. "C:/myFolder/thisFolder/myFile.txt" will return "C:/myFolder/thisFolder".
         */
        public static string GetDirectoryPath(string path, char seperator = '/')
        {
            //return Path.GetDirectoryName(path);
            // Path.GetDirectoryName turns forward slashes to backslashes in some cases on Windows, which is why
            // Substring is used instead.
            char slashChar = UsesForwardSlash(path) ? '/' : '\\';

            int slash = path.LastIndexOf(slashChar);

            // Ignore trailing slash if necessary.
            if (slash == (path.Length - 1))
            {
                slash = path.Substring(0, slash).LastIndexOf(slashChar);
            }
            if (slash == -1)
            {
                ES3Debug.LogError("Path provided is not a directory path as it contains no slashes.");
            }
            return(path.Substring(0, slash));
        }
示例#3
0
 internal override void Write(string key, Type type, byte[] value)
 {
     ES3Debug.LogError("Not implemented");
 }