static public int GetArrayElementPropIndex(SerializedProperty prop) { var ext = System.IO.Path.GetExtension(prop.propertyPath); var s = GKString.GetFromPrefix(ext, ".data[", false); if (string.IsNullOrEmpty(s)) { return(-1); } s = GKString.GetFromSuffix(s, "]", false); if (string.IsNullOrEmpty(s)) { return(-2); } int i; if (!int.TryParse(s, out i)) { return(-3); } return(i); }
static public T TryLoadResource <T>(string filename) where T : UnityEngine.Object { var fullpath = System.IO.Path.GetFullPath(filename).Replace('\\', '/'); var pwd = System.IO.Directory.GetCurrentDirectory().Replace('\\', '/') + "/"; var relPath = GKString.GetFromPrefix(fullpath, pwd, true); var o = (T)AssetDatabase.LoadAssetAtPath(relPath, typeof(T)); return(o); }