private Shader[] GetUserShaders() { var rootPath = Application.dataPath + (sLoadAllShaders ? "" : TCP2_ShaderGeneratorUtils.OutputPath); if (Directory.Exists(rootPath)) { var paths = TCP2_ShaderGeneratorUtils.GetFilesSafe(rootPath, "*.shader"); var shaderList = new List <Shader>(); foreach (var path in paths) { #if UNITY_EDITOR_WIN var assetPath = "Assets" + path.Replace(@"\", @"/").Replace(Application.dataPath, ""); #else string assetPath = "Assets" + path.Replace(Application.dataPath, ""); #endif var shaderImporter = ShaderImporter.GetAtPath(assetPath) as ShaderImporter; if (shaderImporter != null) { if (shaderImporter.userData.Contains("USER")) { var shader = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Shader)) as Shader; if (shader != null && !shaderList.Contains(shader)) { shaderList.Add(shader); } } } } return(shaderList.ToArray()); } return(new Shader[0]); }
private TextAsset[] LoadAllTemplates() { var list = new List <TextAsset>(); var systemPath = Application.dataPath + @"/JMO Assets/Toony Colors Pro/Editor/Shader Templates/"; if (!Directory.Exists(systemPath)) { var rootDir = TCP2_Utils.FindReadmePath(); systemPath = rootDir.Replace(@"\", "/") + "/Editor/Shader Templates/"; } if (Directory.Exists(systemPath)) { var txtFiles = TCP2_ShaderGeneratorUtils.GetFilesSafe(systemPath, "*.txt"); foreach (var sysPath in txtFiles) { var unityPath = sysPath; if (TCP2_Utils.SystemToUnityPath(ref unityPath)) { var textAsset = AssetDatabase.LoadAssetAtPath <TextAsset>(unityPath); if (textAsset != null && !list.Contains(textAsset)) { list.Add(textAsset); } } } list.Sort((x, y) => x.name.CompareTo(y.name)); return(list.ToArray()); } return(null); }