private static void Load() { if (linked_materials == null) { linked_materials = new Dictionary <string, List <Material> >(); string raw = FileHelper.ReadFileIntoString(PATH.LINKED_MATERIALS_FILE); string[][] parsed = Parser.ParseToObject <string[][]>(raw); if (parsed != null) { foreach (string[] material_cloud in parsed) { List <Material> materials = new List <Material>(); for (int i = 1; i < material_cloud.Length; i++) { string path = AssetDatabase.GUIDToAssetPath(material_cloud[i]); Material m = AssetDatabase.LoadAssetAtPath <Material>(path); if (m != null) { materials.Add(m); } } foreach (Material m in materials) { linked_materials.Add(GetKey(m, material_cloud[0]), materials); } } } } }
private static void LoadModule(ModuleCollectionInfo info, List <Module> modules) { WebHelper.DownloadStringASync(info.url, delegate(string data) { Module new_module = new Module(); new_module.url = info.url; new_module.author = info.author; new_module.id = info.id; new_module.available_module = Parser.ParseToObject <ModuleInfo>(data); new_module.available_module.version = new_module.available_module.version.Replace(",", "."); bool module_installed = LoadModuleLocationData(new_module); if (module_installed) { InitInstalledModule(new_module); } else if (Helper.ClassWithNamespaceExists(new_module.available_module.classname)) { CheckForUnregisteredInstall(new_module); } if (new_module.installed_module != null) { new_module.installed_module.version = new_module.installed_module.version.Replace(",", "."); } if (new_module.available_module.requirement != null) { new_module.available_requirement_fullfilled = new_module.available_module.requirement.Test(); } if (new_module.available_requirement_fullfilled && new_module.installed_module != null && Helper.CompareVersions(new_module.installed_module.version, new_module.available_module.version) == 1) { new_module.update_available = true; } modules.Add(new_module); UnityHelper.RepaintEditorWindow <Settings>(); }); }
//TODO save location data on install // delete location data on remove // destingish between public and private modules private static void InitInstalledModule(Module m) { bool remove = false; if (Helper.ClassWithNamespaceExists(m.location_data.classname)) { m.path = GetModuleDirectory(m); if (string.IsNullOrEmpty(m.path) == false) { m.installed_module = Parser.ParseToObject <ModuleInfo>(FileHelper.ReadFileIntoString(FindModuleFilePath(m.path))); string calced_guid = AssetDatabase.AssetPathToGUID(m.path); if (m.location_data.guid != calced_guid) { SaveModuleLocationData(m, calced_guid); } } else { remove = true; } } if (remove) { FileHelper.RemoveValueFromFile(m.id, PATH.MODULES_LOCATION__DATA); m.location_data = null; } }
private static void LoadModules() { modules_are_being_loaded = true; WebHelper.DownloadStringASync(URL.PUBLIC_MODULES_COLLECTION, delegate(string s) { modules = new List <ModuleHeader>(); List <string> module_urls = Parser.ParseToObject <List <string> >(s); foreach (string url in module_urls) { WebHelper.DownloadStringASync(url, delegate(string data) { ModuleHeader new_module = new ModuleHeader(); new_module.url = url; new_module.available_module = Parser.ParseToObject <ModuleInfo>(data); InitInstalledModule(new_module); if (new_module.available_module.requirement != null) { new_module.available_requirement_fullfilled = new_module.available_module.requirement.Test(); } modules.Add(new_module); //Debug.Log(Parser.ObjectToString(new_module)); UnityHelper.RepaintEditorWindow(typeof(Settings)); }); } }); }
private static bool LoadModuleLocationData(Module m) { string data = FileHelper.LoadValueFromFile(m.id, PATH.MODULES_LOCATION__DATA); if (data == "" || data == null) { return(false); } m.location_data = Parser.ParseToObject <ModuleLocationData>(data); return(true); }
public static void InstallModule(string url, string id) { WebHelper.DownloadStringASync(url, delegate(string data) { Module new_module = new Module(); new_module.url = url; new_module.id = id; new_module.available_module = Parser.ParseToObject <ModuleInfo>(data); InstallModule(new_module); }); }
private static void InitInstalledModule(ModuleHeader m) { if (Helper.ClassExists(m.available_module.classname)) { string path = GetModuleDirectoryPath(m) + "/module.json"; if (File.Exists(path)) { m.installed_module = Parser.ParseToObject <ModuleInfo>(Helper.ReadFileIntoString(path)); } } }
private static void CheckForUnregisteredInstall(Module module) { if (Helper.ClassExists(module.available_module.classname)) { module.path = ResolveFilesToDirectory(module.available_module.files.ToArray()); if (module.path != null) { module.installed_module = Parser.ParseToObject <ModuleInfo>(FileHelper.ReadFileIntoString(FindModuleFilePath(module.path))); SaveModuleLocationData(module, AssetDatabase.AssetPathToGUID(module.path)); } } }
private static void LoadThryEditorShaders() { string data = Helper.ReadFileIntoString(PATH.THRY_EDITOR_SHADERS); if (data != "") { shaders = Parser.ParseToObject <List <ThryEditorShader> >(data); } else { SearchAllShadersForThryEditorUsage(); } }
/// If gradient is saved get exact value, else tries to build it from texture public static Gradient GetGradient(Texture texture) { if (texture != null) { string gradient_data_string = Helper.LoadValueFromFile(texture.name, ".thry_gradients"); if (gradient_data_string != null) { return(Parser.ParseToObject <Gradient>(gradient_data_string)); } return(Converter.TextureToGradient(Helper.GetReadableTexture(texture))); } return(new Gradient()); }
public static Gradient GetGradient(Texture texture) { if (texture != null) { string gradient_data_string = FileHelper.LoadValueFromFile(texture.name, PATH.GRADIENT_INFO_FILE); if (gradient_data_string != null) { return(Parser.ParseToObject <Gradient>(gradient_data_string)); } return(Converter.TextureToGradient(GetReadableTexture(texture))); } return(new Gradient()); }
private static void CheckForUnregisteredInstall(Module module) { //Debug.Log(module.available_module.classname + ":" + Helper.ClassWithNamespaceExists(module.available_module.classname)); if (Helper.ClassWithNamespaceExists(module.available_module.classname)) { module.path = ResolveFilesToDirectory(module.available_module.files.ToArray()); if (string.IsNullOrEmpty(module.path) == false) { module.installed_module = Parser.ParseToObject <ModuleInfo>(FileHelper.ReadFileIntoString(FindModuleFilePath(module.path))); SaveModuleLocationData(module, AssetDatabase.AssetPathToGUID(module.path)); } } }
private static void InitValues() { string stringData = FileHelper.LoadValueFromFile("drp", ModuleSettings.MODULES_CONFIG); if (stringData != null) { data = Parser.ParseToObject <DRP_Data>(stringData); } else { data = new DRP_Data(); } ValuesInit = true; }
private static void LoadThryEditorShaders() { string data = FileHelper.ReadFileIntoString(PATH.THRY_EDITOR_SHADERS); if (data != "") { shaders = Parser.ParseToObject <List <ThryEditorShader> >(data); InitDictionary(); } else { dictionary = new Dictionary <string, ThryEditorShader>(); SearchAllShadersForThryEditorUsage(); } DeleteNull(); }
private static bool LoadModuleLocationData(Module m) { string data = FileHelper.LoadValueFromFile(m.id, PATH.MODULES_LOCATION__DATA); if (string.IsNullOrEmpty(data)) { return(false); } m.location_data = Parser.ParseToObject <ModuleLocationData>(data); if (AssetDatabase.GUIDToAssetPath(m.location_data.guid) == "") { m.location_data = null; return(false); } return(true); }
private static void LoadModules() { modules_are_being_loaded = true; WebHelper.DownloadStringASync(URL.MODULE_COLLECTION, delegate(string s) { first_party_modules = new List <Module>(); third_party_modules = new List <Module>(); ModuleCollection module_collection = Parser.ParseToObject <ModuleCollection>(s); foreach (ModuleCollectionInfo info in module_collection.first_party) { LoadModule(info, first_party_modules); } foreach (ModuleCollectionInfo info in module_collection.third_party) { LoadModule(info, third_party_modules); } }); }
public static TextureData GetTextureSettings(MaterialProperty prop) { TextureData defined_default = ThryEditor.currentlyDrawing.currentProperty.options.texture; string json_texture_settings = Helper.LoadValueFromFile("gradient_texture_options_" + prop.name, ".thry_persistent_data"); if (json_texture_settings != null) { return(Parser.ParseToObject <TextureData>(json_texture_settings)); } else if (defined_default != null) { return(defined_default); } else { return(new TextureData()); } }
private static void InstallModule(string url, string name) { EditorUtility.DisplayProgressBar(name + " download progress", "", 0); WebHelper.DownloadStringASync(url, delegate(string s) { if (s.StartsWith("404")) { Debug.LogWarning(s); return; } //Debug.Log(s); ModuleInfo module_info = Parser.ParseToObject <ModuleInfo>(s); string thry_modules_path = ThryEditor.GetThryEditorDirectoryPath(); string temp_path = "temp_" + name; if (thry_modules_path == null) { thry_modules_path = "Assets"; } thry_modules_path += "/thry_modules"; string install_path = thry_modules_path + "/" + name; string base_url = url.RemoveFileName(); FileHelper.WriteStringToFile(s, temp_path + "/module.json"); int i = 0; foreach (string f in module_info.files) { //Debug.Log(base_url + f); WebHelper.DownloadFileASync(base_url + f, temp_path + "/" + f, delegate(string data) { i++; EditorUtility.DisplayProgressBar("Downloading files for " + name, "Downloaded " + base_url + f, (float)i / module_info.files.Count); if (i == module_info.files.Count) { EditorUtility.ClearProgressBar(); if (!Directory.Exists(thry_modules_path)) { Directory.CreateDirectory(thry_modules_path); } Directory.Move(temp_path, install_path); AssetDatabase.Refresh(); } }); } }); }
private static TextureData LoadTextureSettings(MaterialProperty prop, TextureData predefinedTextureSettings, bool force_texture_options) { if (force_texture_options && predefinedTextureSettings != null) { return(predefinedTextureSettings); } string json_texture_settings = FileHelper.LoadValueFromFile("gradient_texture_options_" + prop.name, PATH.PERSISTENT_DATA); if (json_texture_settings != null) { return(Parser.ParseToObject <TextureData>(json_texture_settings)); } else if (predefinedTextureSettings != null) { return(predefinedTextureSettings); } else { return(new TextureData()); } }
private PropertyOptions ExtractExtraOptionsFromDisplayName(ref string displayName) { if (displayName.Contains(EXTRA_OPTIONS_PREFIX)) { string[] parts = displayName.Split(new string[] { EXTRA_OPTIONS_PREFIX }, 2, System.StringSplitOptions.None); displayName = parts[0]; PropertyOptions options = Parser.ParseToObject <PropertyOptions>(parts[1]); if (options != null) { if (options.condition_showS != null) { options.condition_show = DefineableCondition.Parse(options.condition_showS); } if (options.on_value != null) { options.on_value_actions = PropertyValueAction.ParseToArray(options.on_value); } return(options); } } return(new PropertyOptions()); }
public static TextureData GetTextureSettings(MaterialProperty prop) { TextureData defined_default = ThryEditor.currentlyDrawing.currentProperty.options.texture; if (ThryEditor.currentlyDrawing.currentProperty.options.force_texture_options && defined_default != null) { return(defined_default); } string json_texture_settings = FileHelper.LoadValueFromFile("gradient_texture_options_" + prop.name, PATH.PERSISTENT_DATA); if (json_texture_settings != null) { return(Parser.ParseToObject <TextureData>(json_texture_settings)); } else if (defined_default != null) { return(defined_default); } else { return(new TextureData()); } }
//finds all properties and headers and stores them in correct order private void CollectAllProperties() { //load display names from file if it exists MaterialProperty[] props = Properties; Dictionary <string, string> labels = LoadDisplayNamesFromFile(); LoadLocales(); PropertyDictionary = new Dictionary <string, ShaderProperty>(); ShaderParts = new List <ShaderPart>(); MainGroup = new ShaderGroup(this); //init top object that all Shader Objects are childs of Stack <ShaderGroup> headerStack = new Stack <ShaderGroup>(); //header stack. used to keep track if editorData header to parent new objects to headerStack.Push(MainGroup); //add top object as top object to stack headerStack.Push(MainGroup); //add top object a second time, because it get's popped with first actual header item _footers = new List <FooterButton>(); //init footer list int headerCount = 0; for (int i = 0; i < props.Length; i++) { string displayName = props[i].displayName; //Load from label file if (labels.ContainsKey(props[i].name)) { displayName = labels[props[i].name]; } //Check for locale if (Locale != null) { if (displayName.StartsWith("locale::", StringComparison.Ordinal)) { if (Locale.Constains(displayName)) { displayName = Locale.Get(displayName); } } } //extract json data from display name PropertyOptions options = ExtractExtraOptionsFromDisplayName(ref displayName); int offset = options.offset + headerCount; DrawingData.ResetLastDrawerData(); Editor.GetPropertyHeight(props[i]); ThryPropertyType type = GetPropertyType(props[i], options); switch (type) { case ThryPropertyType.header: headerStack.Pop(); break; case ThryPropertyType.legacy_header: headerStack.Pop(); break; case ThryPropertyType.headerWithEnd: case ThryPropertyType.legacy_header_start: offset = options.offset + ++headerCount; break; case ThryPropertyType.legacy_header_end: headerStack.Pop(); headerCount--; break; case ThryPropertyType.on_swap_to: _onSwapToActions = options.actions; break; } ShaderProperty NewProperty = null; ShaderPart newPart = null; switch (type) { case ThryPropertyType.master_label: _shaderHeader = new ShaderHeaderProperty(this, props[i], displayName, 0, options, false); break; case ThryPropertyType.footer: _footers.Add(new FooterButton(Parser.ParseToObject <ButtonData>(displayName))); break; case ThryPropertyType.header: case ThryPropertyType.headerWithEnd: case ThryPropertyType.legacy_header: case ThryPropertyType.legacy_header_start: ShaderHeader newHeader = new ShaderHeader(this, props[i], Editor, displayName, offset, options); headerStack.Peek().addPart(newHeader); headerStack.Push(newHeader); newPart = newHeader; break; case ThryPropertyType.group_start: ShaderGroup new_group = new ShaderGroup(this, options); headerStack.Peek().addPart(new_group); headerStack.Push(new_group); newPart = new_group; break; case ThryPropertyType.group_end: headerStack.Pop(); break; case ThryPropertyType.none: case ThryPropertyType.property: if (props[i].type == MaterialProperty.PropType.Texture) { NewProperty = new TextureProperty(this, props[i], displayName, offset, options, props[i].flags.HasFlag(MaterialProperty.PropFlags.NoScaleOffset) == false, !DrawingData.LastPropertyUsedCustomDrawer, i); } else { NewProperty = new ShaderProperty(this, props[i], displayName, offset, options, false, i); } break; case ThryPropertyType.lightmap_flags: NewProperty = new GIProperty(this, props[i], displayName, offset, options, false); break; case ThryPropertyType.dsgi: NewProperty = new DSGIProperty(this, props[i], displayName, offset, options, false); break; case ThryPropertyType.instancing: NewProperty = new InstancingProperty(this, props[i], displayName, offset, options, false); break; case ThryPropertyType.locale: NewProperty = new LocaleProperty(this, props[i], displayName, offset, options, false); break; case ThryPropertyType.shader_version: _shaderVersionRemote = new Version(WebHelper.GetCachedString(options.remote_version_url)); _shaderVersionLocal = new Version(displayName); _isShaderUpToDate = _shaderVersionLocal >= _shaderVersionRemote; _shaderUpdateUrl = options.generic_string; _hasShaderUpdateUrl = _shaderUpdateUrl != null; break; } if (NewProperty != null) { newPart = NewProperty; if (PropertyDictionary.ContainsKey(props[i].name)) { continue; } PropertyDictionary.Add(props[i].name, NewProperty); if (type != ThryPropertyType.none) { headerStack.Peek().addPart(NewProperty); } } //if new header is at end property if (headerStack.Peek() is ShaderHeader && (headerStack.Peek() as ShaderHeader).GetEndProperty() == props[i].name) { headerStack.Pop(); headerCount--; } if (newPart != null) { ShaderParts.Add(newPart); } } }
private void InitVariables() { is_changing_vrc_sdk = (FileHelper.LoadValueFromFile("delete_vrc_sdk", PATH.AFTER_COMPILE_DATA) == "true") || (FileHelper.LoadValueFromFile("update_vrc_sdk", PATH.AFTER_COMPILE_DATA) == "true"); List <Type> subclasses = typeof(ModuleSettings).Assembly.GetTypes().Where(type => type.IsSubclassOf(typeof(ModuleSettings))).ToList <Type>(); moduleSettings = new ModuleSettings[subclasses.Count]; int i = 0; foreach (Type classtype in subclasses) { moduleSettings[i++] = (ModuleSettings)Activator.CreateInstance(classtype); } is_init = true; if (thry_message == null) { WebHelper.DownloadStringASync(Thry.URL.SETTINGS_MESSAGE_URL, delegate(string s) { thry_message = Parser.ParseToObject <ButtonData>(s); }); } }
private void InitVariables() { List <Type> subclasses = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes()).Where(type => type.IsSubclassOf(typeof(ModuleSettings))).ToList(); moduleSettings = new ModuleSettings[subclasses.Count]; int i = 0; foreach (Type classtype in subclasses) { moduleSettings[i++] = (ModuleSettings)Activator.CreateInstance(classtype); } is_init = true; if (thry_message == null) { WebHelper.DownloadStringASync(Thry.URL.SETTINGS_MESSAGE_URL, delegate(string s) { thry_message = Parser.ParseToObject <ButtonData>(s); }); } }
//finds all properties and headers and stores them in correct order private void CollectAllProperties() { //load display names from file if it exists MaterialProperty[] props = editorData.properties; Dictionary <string, string> labels = LoadDisplayNamesFromFile(); LoadLocales(); editorData.propertyDictionary = new Dictionary <string, ShaderProperty>(); editorData.shaderParts = new List <ShaderPart>(); shaderparts = new ShaderHeader(); //init top object that all Shader Objects are childs of Stack <ShaderGroup> headerStack = new Stack <ShaderGroup>(); //header stack. used to keep track if editorData header to parent new objects to headerStack.Push(shaderparts); //add top object as top object to stack headerStack.Push(shaderparts); //add top object a second time, because it get's popped with first actual header item footer = new List <ButtonData>(); //init footer list int headerCount = 0; Type materialPropertyDrawerType = typeof(UnityEditor.Editor).Assembly.GetType("UnityEditor.MaterialPropertyHandler"); MethodInfo getPropertyHandlerMethod = materialPropertyDrawerType.GetMethod("GetShaderPropertyHandler", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); PropertyInfo drawerProperty = materialPropertyDrawerType.GetProperty("propertyDrawer"); Type materialToggleDrawerType = typeof(UnityEditor.Editor).Assembly.GetType("UnityEditor.MaterialToggleDrawer"); FieldInfo keyWordField = materialToggleDrawerType.GetField("keyword", BindingFlags.Instance | BindingFlags.NonPublic); for (int i = 0; i < props.Length; i++) { string displayName = props[i].displayName; if (locale != null) { foreach (string key in locale.GetAllKeys()) { if (displayName.Contains("locale::" + key)) { displayName = displayName.Replace("locale::" + key, locale.Get(key)); } } } displayName = Regex.Replace(displayName, @"''", "\""); if (labels.ContainsKey(props[i].name)) { displayName = labels[props[i].name]; } PropertyOptions options = ExtractExtraOptionsFromDisplayName(ref displayName); int offset = options.offset + headerCount; //Handle keywords object propertyHandler = getPropertyHandlerMethod.Invoke(null, new object[] { editorData.shader, props[i].name }); //if has custom drawer if (propertyHandler != null) { object propertyDrawer = drawerProperty.GetValue(propertyHandler, null); //if custom drawer exists if (propertyDrawer != null) { if (propertyDrawer.GetType().ToString() == "UnityEditor.MaterialToggleDrawer") { object keyword = keyWordField.GetValue(propertyDrawer); if (keyword != null) { foreach (Material m in editorData.materials) { if (m.GetFloat(props[i].name) == 1) { m.EnableKeyword((string)keyword); } else { m.DisableKeyword((string)keyword); } } } } } } ThryPropertyType type = GetPropertyType(props[i], options); switch (type) { case ThryPropertyType.header: headerStack.Pop(); break; case ThryPropertyType.header_start: offset = options.offset + ++headerCount; break; case ThryPropertyType.header_end: headerStack.Pop(); headerCount--; break; case ThryPropertyType.on_swap_to: on_swap_to_actions = options.actions; break; } ShaderProperty newPorperty = null; ShaderPart newPart = null; switch (type) { case ThryPropertyType.master_label: masterLabelText = displayName; break; case ThryPropertyType.footer: footer.Add(Parser.ParseToObject <ButtonData>(displayName)); break; case ThryPropertyType.header: case ThryPropertyType.header_start: if (options.is_hideable) { editorData.show_HeaderHider = true; } ShaderHeader newHeader = new ShaderHeader(props[i], editorData.editor, displayName, offset, options); headerStack.Peek().addPart(newHeader); headerStack.Push(newHeader); HeaderHider.InitHidden(newHeader); newPart = newHeader; break; case ThryPropertyType.group_start: ShaderGroup new_group = new ShaderGroup(options); headerStack.Peek().addPart(new_group); headerStack.Push(new_group); newPart = new_group; break; case ThryPropertyType.group_end: headerStack.Pop(); break; case ThryPropertyType.none: case ThryPropertyType.property: DrawingData.lastPropertyUsedCustomDrawer = false; editorData.editor.GetPropertyHeight(props[i]); bool forceOneLine = props[i].type == MaterialProperty.PropType.Vector && !DrawingData.lastPropertyUsedCustomDrawer; if (props[i].type == MaterialProperty.PropType.Texture) { newPorperty = new TextureProperty(props[i], displayName, offset, options, props[i].flags.HasFlag(MaterialProperty.PropFlags.NoScaleOffset) == false, !DrawingData.lastPropertyUsedCustomDrawer); } else { newPorperty = new ShaderProperty(props[i], displayName, offset, options, forceOneLine); } break; case ThryPropertyType.lightmap_flags: newPorperty = new GIProperty(props[i], displayName, offset, options, false); break; case ThryPropertyType.dsgi: newPorperty = new DSGIProperty(props[i], displayName, offset, options, false); break; case ThryPropertyType.instancing: newPorperty = new InstancingProperty(props[i], displayName, offset, options, false); break; case ThryPropertyType.locale: newPorperty = new LocaleProperty(props[i], displayName, offset, options, false); break; case ThryPropertyType.shader_optimizer: editorData.use_ShaderOptimizer = true; newPorperty = new ShaderProperty(props[i], displayName, offset, options, false); break; } if (newPorperty != null) { newPart = newPorperty; if (editorData.propertyDictionary.ContainsKey(props[i].name)) { continue; } editorData.propertyDictionary.Add(props[i].name, newPorperty); if (type != ThryPropertyType.none && type != ThryPropertyType.shader_optimizer) { headerStack.Peek().addPart(newPorperty); } } if (newPart != null) { editorData.shaderParts.Add(newPart); } } }
public static T Deserialize <T>(string s) { return(Parser.ParseToObject <T>(s)); }
//finds all properties and headers and stores them in correct order private void CollectAllProperties() { //load display names from file if it exists MaterialProperty[] props = properties; Dictionary <string, string> labels = LoadDisplayNamesFromFile(); LoadLocales(); propertyDictionary = new Dictionary <string, ShaderProperty>(); shaderParts = new List <ShaderPart>(); mainHeader = new ShaderHeader(this); //init top object that all Shader Objects are childs of Stack <ShaderGroup> headerStack = new Stack <ShaderGroup>(); //header stack. used to keep track if editorData header to parent new objects to headerStack.Push(mainHeader); //add top object as top object to stack headerStack.Push(mainHeader); //add top object a second time, because it get's popped with first actual header item footers = new List <FooterButton>(); //init footer list int headerCount = 0; for (int i = 0; i < props.Length; i++) { DrawingData.ResetLastDrawerData(); editor.GetPropertyHeight(props[i]); string displayName = props[i].displayName; //Load from label file if (labels.ContainsKey(props[i].name)) { displayName = labels[props[i].name]; } //Check for locale if (locale != null) { if (displayName.Contains("locale::")) { Match m = Regex.Match(displayName, @"locale::(\d\w)+d"); if (m.Success) { string key = m.Value.Substring(8, m.Value.Length - 8); if (locale.Constains(key)) { displayName = displayName.Replace("locale::" + locale.Get(key), ""); } } } } displayName = displayName.Replace("''", "\""); //extract json data from display name PropertyOptions options = ExtractExtraOptionsFromDisplayName(ref displayName); int offset = options.offset + headerCount; ThryPropertyType type = GetPropertyType(props[i], options); switch (type) { case ThryPropertyType.header: headerStack.Pop(); break; case ThryPropertyType.legacy_header: headerStack.Pop(); break; case ThryPropertyType.headerWithEnd: case ThryPropertyType.legacy_header_start: offset = options.offset + ++headerCount; break; case ThryPropertyType.legacy_header_end: headerStack.Pop(); headerCount--; break; case ThryPropertyType.on_swap_to: on_swap_to_actions = options.actions; break; } ShaderProperty newPorperty = null; ShaderPart newPart = null; switch (type) { case ThryPropertyType.master_label: shaderHeader = new ShaderHeaderProperty(this, props[i], displayName, 0, options, false); break; case ThryPropertyType.footer: footers.Add(new FooterButton(Parser.ParseToObject <ButtonData>(displayName))); break; case ThryPropertyType.header: case ThryPropertyType.headerWithEnd: case ThryPropertyType.legacy_header: case ThryPropertyType.legacy_header_start: if (options.is_hideable) { show_HeaderHider = true; } ShaderHeader newHeader = new ShaderHeader(this, props[i], editor, displayName, offset, options); headerStack.Peek().addPart(newHeader); headerStack.Push(newHeader); HeaderHider.InitHidden(newHeader); newPart = newHeader; break; case ThryPropertyType.group_start: ShaderGroup new_group = new ShaderGroup(this, options); headerStack.Peek().addPart(new_group); headerStack.Push(new_group); newPart = new_group; break; case ThryPropertyType.group_end: headerStack.Pop(); break; case ThryPropertyType.none: case ThryPropertyType.property: bool forceOneLine = props[i].type == MaterialProperty.PropType.Vector && !DrawingData.lastPropertyUsedCustomDrawer; if (props[i].type == MaterialProperty.PropType.Texture) { newPorperty = new TextureProperty(this, props[i], displayName, offset, options, props[i].flags.HasFlag(MaterialProperty.PropFlags.NoScaleOffset) == false, !DrawingData.lastPropertyUsedCustomDrawer); } else { newPorperty = new ShaderProperty(this, props[i], displayName, offset, options, forceOneLine); } break; case ThryPropertyType.lightmap_flags: newPorperty = new GIProperty(this, props[i], displayName, offset, options, false); break; case ThryPropertyType.dsgi: newPorperty = new DSGIProperty(this, props[i], displayName, offset, options, false); break; case ThryPropertyType.instancing: newPorperty = new InstancingProperty(this, props[i], displayName, offset, options, false); break; case ThryPropertyType.locale: newPorperty = new LocaleProperty(this, props[i], displayName, offset, options, false); break; case ThryPropertyType.shader_optimizer: use_ShaderOptimizer = true; newPorperty = new ShaderProperty(this, props[i], displayName, offset, options, false); break; } if (newPorperty != null) { newPart = newPorperty; if (propertyDictionary.ContainsKey(props[i].name)) { continue; } propertyDictionary.Add(props[i].name, newPorperty); //Debug.Log(newPorperty.materialProperty.name + ":" + headerStack.Count); if (type != ThryPropertyType.none && type != ThryPropertyType.shader_optimizer) { headerStack.Peek().addPart(newPorperty); } } //if new header is at end property if (headerStack.Peek() is ShaderHeader && (headerStack.Peek() as ShaderHeader).GetEndProperty() == props[i].name) { headerStack.Pop(); headerCount--; } if (newPart != null) { shaderParts.Add(newPart); DrawingData.lastInitiatedPart = newPart; editor.GetPropertyHeight(props[i]); DrawingData.lastInitiatedPart = null; } } }
private void InitVariables() { is_changing_vrc_sdk = (Helper.LoadValueFromFile("delete_vrc_sdk", ".thry_after_compile_data") == "true") || (Helper.LoadValueFromFile("update_vrc_sdk", ".thry_after_compile_data") == "true"); CheckAPICompatibility(); //check that Net_2.0 is ApiLevel CheckMCS(); //check that MCS is imported SetupStyle(); //setup styles CheckVRCSDK(); List <Type> subclasses = typeof(ModuleSettings).Assembly.GetTypes().Where(type => type.IsSubclassOf(typeof(ModuleSettings))).ToList <Type>(); moduleSettings = new ModuleSettings[subclasses.Count]; int i = 0; foreach (Type classtype in subclasses) { moduleSettings[i++] = (ModuleSettings)Activator.CreateInstance(classtype); } if (thry_message == null) { Helper.DownloadStringASync(THRY_MESSAGE_URL, delegate(string s) { thry_message = Parser.ParseToObject <ButtonData>(s); }); } }