protected virtual bool ValidateSetting(Object asset, ScriptReferenceType type) { if (asset == null || type == ScriptReferenceType.TextAsset) { return(true); } string path = AssetDatabase.GetAssetPath(asset); LuaSettings luaSettings = LuaSettings.GetOrCreateSettings(); foreach (string root in luaSettings.SrcRoots) { if (path.StartsWith(root)) { return(true); } } if (path.IndexOf("Resources") >= 0) { return(true); } if (EditorUtility.DisplayDialog("Notice", string.Format("The file \"{0}\" is not in the source code folder of lua. Do you want to add a source code folder?", asset.name), "Yes", "Cancel")) { SettingsService.OpenProjectSettings("Project/LuaSettingsProvider"); return(false); } else { return(true); } }
protected virtual string GetFilename(Object asset) { if (asset == null) { return(null); } string path = AssetDatabase.GetAssetPath(asset); if (string.IsNullOrEmpty(path)) { return(null); } int start = path.LastIndexOf("/"); int dotIndex = path.IndexOf(".", start); if (dotIndex > -1) { path = path.Substring(0, dotIndex); } LuaSettings luaSettings = LuaSettings.GetOrCreateSettings(); foreach (string root in luaSettings.SrcRoots) { if (path.StartsWith(root)) { path = path.Replace(root + "/", "").Replace("/", "."); return(path); } } int index = path.IndexOf("Resources"); if (index >= 0) { path = path.Substring(index + 10); } path = path.Replace("/", "."); return(path); }