static void Init() { // Get existing open window or if none, make a new one: PoiSettings window = (PoiSettings)EditorWindow.GetWindow(typeof(PoiSettings)); window.Show(); }
//-------------Main Function-------------- public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props) { PoiHelper.updateQueueShadersIfNessecary(); Object[] targets = materialEditor.targets; Material[] materials = new Material[targets.Length]; for (int i = 0; i < targets.Length; i++) { materials[i] = targets[i] as Material; } config = PoiHelper.GetConfig(); if (presetHandler == null) { presetHandler = new PoiPresetHandler(props); } else { presetHandler.testPresetsChanged(props); } SetupStyle(); CollectAllProperties(props, materialEditor); // load default toggle values LoadDefaults(materials[0]); //shader name + presets EditorGUILayout.BeginHorizontal(); byte[] fileData = File.ReadAllBytes(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("poiSettigsIcon")[0])); Texture2D tex = new Texture2D(2, 2); tex.LoadImage(fileData); if (GUILayout.Button(tex, new GUILayoutOption[] { GUILayout.MaxWidth(24), GUILayout.MaxHeight(18) })) { sendActiveShader = true; PoiSettings window = PoiSettings.getInstance(); window.Show(); window.Focus(); } MaterialProperty shader_master_label = FindProperty(props, "shader_master_label"); if (shader_master_label != null) { DrawMasterLabel(shader_master_label.displayName); } presetHandler.drawPresets(props, materials); EditorGUILayout.EndHorizontal(); //shader properties foreach (ShaderPart part in shaderparts.parts) { drawShaderPart(part, materialEditor); } Shader shader = materials[0].shader; string defaultShaderName = materials[0].shader.name.Split(new string[] { "-queue" }, System.StringSplitOptions.None)[0].Replace(".differentQueues/", ""); Shader defaultShader = Shader.Find(defaultShaderName); //Render Queue if (config.useRenderQueueSelection) { drawRenderQueueSelector(materials[0], defaultShader); EditorGUILayout.LabelField("Default: " + defaultShaderName); EditorGUILayout.LabelField("Shader: " + shader.name); } ToggleDefines(materials[0]); //big/small texture toggle /*if (textureFieldsCount > 0) { * if(EditorGUILayout.Toggle("Big Texture Fields", config.bigTextures) != config.bigTextures) * { * config.bigTextures = !config.bigTextures; * config.save(); * } * }*/ //footer EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Space(2); foreach (string footNote in footer) { string[] splitNote = footNote.TrimEnd(')').Split("(".ToCharArray(), 2); string value = splitNote[1]; string type = splitNote[0]; if (type == "linkButton") { string[] values = value.Split(",".ToCharArray()); drawLinkButton(70, 20, values[0], values[1]); } GUILayout.Space(2); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (!config.useRenderQueueSelection) { materials[0].renderQueue = defaultShader.renderQueue; } UpdateRenderQueue(materials[0], defaultShader); if (sendActiveShader) { PoiSettings.activeShader = defaultShader; PoiSettings.presetHandler = presetHandler; EditorWindow win = PoiHelper.FindEditorWindow(typeof(PoiSettings)); if (win != null) { win.Repaint(); } sendActiveShader = false; } }