public void OnOpen() { Config config = Config.Get(); //get material targets Object[] targets = current.editor.targets; current.materials = new Material[targets.Length]; for (int i = 0; i < targets.Length; i++) { current.materials[i] = targets[i] as Material; } //collect shader properties CollectAllProperties(); //init settings texture if (settingsTexture == null) { byte[] fileData = File.ReadAllBytes(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("thry_settings_icon")[0])); settingsTexture = new Texture2D(2, 2); settingsTexture.LoadImage(fileData); } //init master label MaterialProperty shader_master_label = FindProperty(current.properties, PROPERTY_NAME_MASTER_LABEL); if (shader_master_label != null) { masterLabelText = shader_master_label.displayName; } current.shader = current.materials[0].shader; string defaultShaderName = current.materials[0].shader.name.Split(new string[] { "-queue" }, System.StringSplitOptions.None)[0].Replace(".differentQueues/", ""); current.defaultShader = Shader.Find(defaultShaderName); //update render queue if render queue selection is deactivated if (!config.renderQueueShaders && !config.showRenderQueue) { current.materials[0].renderQueue = current.defaultShader.renderQueue; UpdateRenderQueueInstance(); } foreach (MaterialProperty p in current.properties) { if (p.name == PROPERTY_NAME_USING_THRY_EDITOR) { p.floatValue = MATERIAL_NOT_RESET; } } if (current.materials != null) { foreach (Material m in current.materials) { ShaderImportFixer.backupSingleMaterial(m); } } firstOnGUICall = false; }
public override void OnClosed(Material material) { base.OnClosed(material); if (current.materials != null) { foreach (Material m in current.materials) { ShaderImportFixer.backupSingleMaterial(m); } } firstOnGUICall = true; }