private static bool Init() { if (properties == null){ TextAsset txt = Resources.Load<TextAsset>("vBug/vBugShaderData"); if (txt == null || string.IsNullOrEmpty(txt.text)) return false; properties = SerializeRuntimeHelper.DeserializeXML<ShaderProperties>(txt.text); propertiesTable.Clear(); } return properties != null; }
public static void UpdateShaderPropertiesXML(bool forceUpdate) { string path = IOEditorHelper.FindFileByName(Application.dataPath, "vBugShaderData.xml", true, true, false); if (string.IsNullOrEmpty(path)) path = Application.dataPath + "/" + "Resources/vBug/vBugShaderData.xml"; if (!forceUpdate && System.IO.File.Exists(path)) { double timestamp = vBugEnvironment.GetUnixTimestamp(); if (timestamp - lastUpdateTimeStamp < 60f) //max every minute return; lastUpdateTimeStamp = timestamp; } //--------------- Update -------------------- Shader[] shaders = GetAllShaders(); if (shaders != null && shaders.Length > 0){ int iMax = shaders.Length; ShaderProperties data = new ShaderProperties(iMax); for (int i = 0; i < iMax; i++){ Shader shader = shaders[i]; int propCount = ShaderUtil.GetPropertyCount(shader); ShaderProperties.Info info = data.shaders[i] = new ShaderProperties.Info(propCount); info.name = shader.name; for (int p = 0; p < propCount; p++){ info.propertyNames[p] = ShaderUtil.GetPropertyName(shader, p); info.propertyTypes[p] = (ShaderProperties.PropType)ShaderUtil.GetPropertyType(shader, p); info.textDimensions[p] = (ShaderProperties.TextDim)ShaderUtil.GetTexDim(shader, p); } } try { SerializeEditorHelper.SerializeAndSaveXML<ShaderProperties>(data, path); AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset)); AssetDatabase.Refresh(); } catch (Exception e) { if (vBugEditorSettings.DebugMode) Debug.LogError("UpdateShaderPropertiesXML - FAIL: " + e.Message + e.StackTrace); } } else { if (vBugEditorSettings.DebugMode) Debug.Log("Shaders null or empty"); } }