//========================================================================= public void PostFxScanLinesGUI(EchoPFXOption iepo, PossibleOpts ipo) { if (ipo.scanlines == ECHOPFXSCANLINES.HORIZONTAL || ipo.scanlines == ECHOPFXSCANLINES.BOTH) { EditorGUILayout.LabelField("HORIZONTAL:"); EditorGUILayout.BeginHorizontal(); iepo.linesAmountDivideH = GUILayout.Toggle(iepo.linesAmountDivideH, ""); EditorGUILayout.LabelField("Divide Screen Height By Count"); EditorGUILayout.EndHorizontal(); iepo.linesAmountH = EditorGUILayout.IntField("Count", iepo.linesAmountH); iepo.linesScrollH = EditorGUILayout.FloatField("Scroll", iepo.linesScrollH); } if (ipo.scanlines == ECHOPFXSCANLINES.BOTH) { EditorGUILayout.Space(); } if (ipo.scanlines == ECHOPFXSCANLINES.VERTICAL || ipo.scanlines == ECHOPFXSCANLINES.BOTH) { EditorGUILayout.LabelField("VERTICAL:"); EditorGUILayout.BeginHorizontal(); iepo.linesAmountDivideV = GUILayout.Toggle(iepo.linesAmountDivideV, ""); EditorGUILayout.LabelField("Divide Screen Width By Count"); EditorGUILayout.EndHorizontal(); iepo.linesAmountV = EditorGUILayout.IntField("Count", iepo.linesAmountV); iepo.linesScrollV = EditorGUILayout.FloatField("Scroll", iepo.linesScrollV); } }
//========================================================================= public static void WriteTCDefine(PossibleOpts ipo) { if (!ipo.useUniqueTC) { return; } switch (ipo.type) { case ECHOPFXOPTION.OVERLAY_NORMAL: _final += "#define OVERLAY_NORMAL_TC"; break; case ECHOPFXOPTION.OVERLAY_SCREEN: _final += "#define OVERLAY_SCR_TC"; break; case ECHOPFXOPTION.OVERLAY_ADD: _final += "#define OVERLAY_ADD_TC"; break; case ECHOPFXOPTION.OVERLAY_SUBTRACT: _final += "#define OVERLAY_SUB_TC"; break; case ECHOPFXOPTION.OVERLAY_MULTIPLY: _final += "#define OVERLAY_MUL_TC"; break; case ECHOPFXOPTION.OVERLAY_OVERLAY: _final += "#define OVERLAY_OVR_TC"; break; case ECHOPFXOPTION.CUSTOM_FRAG_1: _final += "#define CUSTOM_FRAG_1_TC"; break; case ECHOPFXOPTION.CUSTOM_FRAG_2: _final += "#define CUSTOM_FRAG_2_TC"; break; case ECHOPFXOPTION.CUSTOM_FRAG_3: _final += "#define CUSTOM_FRAG_3_TC"; break; case ECHOPFXOPTION.CUSTOM_FRAG_4: _final += "#define CUSTOM_FRAG_4_TC"; break; default: break; } _final += "\n"; }
//========================================================================= private void SetNewRenderGroup(EchoPFXRenderGroup ierg, bool iadd) { if (_erg != ierg) { _customOpt = null; } else { return; } _erg = ierg; if (iadd) { float highnum = -2; epfxm.ergList.Add(_erg); for (int loop = 0; loop < epfxm.ergList.Count; loop++) { if (epfxm.ergList[loop] != ierg) { if (epfxm.ergList[loop].cameraDepthEnd > highnum) { highnum = epfxm.ergList[loop].cameraDepthEnd; } } } highnum++; _erg.cameraDepthStart = highnum; _erg.cameraDepthEnd = highnum + 1; } _ergIndex = epfxm.ergList.IndexOf(_erg); _epeIndex = 0; }
//========================================================================= void OnEnable() { EchoPFXEffect epe; LoadPrefs(); _customOpt = null; epfxm = (EchoPFXManager)target; serializedObject.Update(); // postFX.Update(); if (epfxm.ergList.Count < 1) { SetNewRenderGroup(new EchoPFXRenderGroup(GetGroupID()), true); } if (_ergIndex < 0 || _ergIndex >= epfxm.ergList.Count) { _ergIndex = 0; } _erg = epfxm.ergList[_ergIndex]; if (_epeIndex < 0 || _epeIndex >= _erg.epeList.Count) { if (_erg.epeList.Count < 1) { epe = new EchoPFXEffect(); epe.name = "New Effect"; _erg.epeList.Add(epe); _epeIndex = _erg.epeList.IndexOf(epe); } } EditorApplication.playmodeStateChanged = AutoCompileShaders; //epfxm.UpdateAllRenderGroups(); }
//========================================================================= void OnDisable() { //EditorPrefs.DeleteAll(); SavePrefs(); _customOpt = null; }
//========================================================================= public void MyEffectsGUI() { int loop; int delIndex = -1; EchoPFXEffect epfx; Color old_color = GUI.color; EchoPFXEffect epe; EditorGUILayout.Space(); if (GUILayout.Button("Add New Effect")) { epe = new EchoPFXEffect(); epe.name = "New Effect"; _erg.epeList.Add(epe); _epeIndex = _erg.epeList.IndexOf(epe); } EditorGUILayout.Space(); if (_erg == null || _erg.epeList.Count < 1) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Effect List Empty: Add a New Effect"); EditorGUILayout.Space(); return; } if (_erg == null) { return; } if (_epeIndex >= _erg.epeList.Count) { _epeIndex = 0; return; } epe = _erg.epeList[_epeIndex]; for (loop = 0; loop < _erg.epeList.Count; loop++) { epfx = _erg.epeList[loop]; GUILayout.BeginHorizontal(); epfx.active = GUILayout.Toggle(epfx.active, "", GUILayout.Width(32)); if (loop == _epeIndex) { GUI.color = new Color(0.5f, 0.7f, 2.0f, 1.0f); } if (GUILayout.Button(epfx.name)) { EditorGUIUtility.systemCopyBuffer = epfx.name; epe = epfx; _epeIndex = loop; _curMode = 2; } GUI.color = old_color; if (GUILayout.Button("-", GUILayout.Width(32))) { _customOpt = null; delIndex = loop; } GUILayout.EndHorizontal(); } if (delIndex >= 0 && _erg.epeList.Count > 0) { _erg.epeList.RemoveAt(delIndex); if (_epeIndex >= _erg.epeList.Count) { _epeIndex = _erg.epeList.Count - 1; } } }
//========================================================================= public override void OnInspectorGUI() { string[] names = { "Group", "Build", "Make" }; int loop; Color oldColor = GUI.color; string cname; bool oldToggle; serializedObject.Update(); // postFX.Update(); if (epfxm.ergList.Count > 0) { SetNewRenderGroup(epfxm.ergList[_ergIndex], false); } EditorGUILayout.Space(); epfxm.managerCameraDepth = EditorGUILayout.FloatField("Manager Depth", epfxm.managerCameraDepth); epfxm.frameRate = EditorGUILayout.IntField("Frame Rate", epfxm.frameRate); oldToggle = _playMaker; _playMaker = EditorGUILayout.Toggle("PlayMaker Actions", _playMaker); if (oldToggle != _playMaker) { _playMaker = TogglePlayMakerActions(); } GUILayout.BeginHorizontal(); if (GUILayout.Button("Export")) { _customOpt = null; EchoPFXLoadSave.Save(epfxm); } if (GUILayout.Button("Import")) { _customOpt = null; _needCompile = true; SetNewRenderGroup(EchoPFXLoadSave.Load(epfxm), false); EditorUtility.SetDirty(target); } GUILayout.EndHorizontal(); EditorGUILayout.Space(); GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(8) }); EditorGUILayout.Space(); _myrgFold = EditorGUILayout.Foldout(_myrgFold, new GUIContent("Render Groups")); if (_myrgFold) { MyRenderGroupsGUI(); } EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(8) }); EditorGUILayout.Space(); _myfxFold = EditorGUILayout.Foldout(_myfxFold, new GUIContent("Post Effects")); if (_myfxFold) { MyEffectsGUI(); } EditorGUILayout.Space(); GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(8) }); EditorGUILayout.Space(); EditorGUILayout.Space(); if (_needCompile) { cname = ">> Compile Post FX Shaders <<"; GUI.color = new Color(2.0f, 0.5f, 0.0f, 1.0f); } else { cname = "Compile Post FX Shaders"; } if (GUILayout.Button(cname, GUILayout.Height(24))) { EchoPFXShaderBuild.BuildShaders(epfxm.ergList); _needCompile = false; } GUI.color = oldColor; EditorGUILayout.Space(); GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(8) }); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); for (loop = 0; loop < 3; loop++) { if (loop == _curMode) { GUI.color = new Color(0.5f, 0.7f, 2.0f, 1.0f); } if (GUILayout.Button(names[loop])) { _customOpt = null; _curMode = loop; epfxm.UpdateAllRenderGroups(); } GUI.color = oldColor; } GUILayout.EndHorizontal(); EditorGUILayout.Space(); switch (_curMode) { case 1: EffectBuildOptionsGUI(); break; case 2: EffectEditorGUI(); break; default: RenderGroupGUI(); break; } if (GUI.changed) { EditorUtility.SetDirty(target); } serializedObject.ApplyModifiedProperties(); }
//========================================================================= public void MyRenderGroupsGUI() { int loop; int delIndex = -1; EchoPFXRenderGroup erg; Color old_color = GUI.color; EditorGUILayout.Space(); if (GUILayout.Button("Add Render Group")) { SetNewRenderGroup(new EchoPFXRenderGroup(GetGroupID()), true); epfxm.SortRenderGroups(); } EditorGUILayout.Space(); if (epfxm.ergList.Count < 1) { EditorGUILayout.Space(); EditorGUILayout.LabelField("No Render Groups !"); EditorGUILayout.Space(); return; } for (loop = 0; loop < epfxm.ergList.Count; loop++) { erg = epfxm.ergList[loop]; if (erg == null) { continue; } GUILayout.BeginHorizontal(); if (loop == _ergIndex) { GUI.color = new Color(0.5f, 0.7f, 2.0f, 1.0f); } if (GUILayout.Button(erg.name)) { EditorGUIUtility.systemCopyBuffer = erg.name; SetNewRenderGroup(erg, false); _curMode = 0; } GUI.color = old_color; if (GUILayout.Button("-", GUILayout.Width(32))) { _customOpt = null; delIndex = loop; } GUILayout.EndHorizontal(); } if (delIndex >= 0) { if (epfxm.ergList.Count > 0) { epfxm.ergList.RemoveAt(delIndex); _ergIndex--; if (_ergIndex < 0) { _ergIndex = 0; if (epfxm.ergList.Count < 1) { _erg = null; } } } else { _erg = null; _ergIndex = 0; } } }
//========================================================================= public void EffectBuildOptionsGUI() { int index1; int loop; PossibleOpts opt; string[] popupNames1; string[] popupNames2; string[][] popupNames; int[] lookup1; int[] lookup2; int[][] lookup; int count; PossibleOpts po; List <PossibleOpts>[] possibleOpts; if (_erg == null) { return; } EditorGUI.BeginChangeCheck(); lookup1 = new int [(int)ECHOPFXOPTION.COUNT]; lookup2 = new int [(int)ECHOPFXOPTION.COUNT]; _erg.possibleOpts1.Sort(delegate(PossibleOpts e1, PossibleOpts e2) { return(e1.order.CompareTo(e2.order)); }); _erg.possibleOpts2.Sort(delegate(PossibleOpts e1, PossibleOpts e2) { return(e1.order.CompareTo(e2.order)); }); // setup pass one stuff for (loop = 0; loop < _erg.possibleOpts1.Count; loop++) { _erg.possibleOpts1[loop].order = loop; } popupNames1 = MakePopupNames(_erg.possibleOpts1, lookup1); // setup pass two stuff for (loop = 0; loop < _erg.possibleOpts2.Count; loop++) { _erg.possibleOpts2[loop].order = loop; } popupNames2 = MakePopupNames(_erg.possibleOpts2, lookup2); popupNames = new string[2][]; lookup = new int[2][]; possibleOpts = new List <PossibleOpts> [2]; popupNames[0] = popupNames1; popupNames[1] = popupNames2; lookup[0] = lookup1; lookup[1] = lookup2; possibleOpts[0] = _erg.possibleOpts1; possibleOpts[1] = _erg.possibleOpts2; EditorGUILayout.BeginHorizontal(); for (int pass = 0; pass < 2; pass++) { EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Pass:"******"Options: ", GUILayout.MinWidth(64)); index1 = -1; } if (index1 >= 0) { po = new PossibleOpts((ECHOPFXOPTION)lookup[pass][index1]); po.order = possibleOpts[pass].Count; possibleOpts[pass].Add(po); _erg.ValidateOptions(); } // draw selected options count = 0; for (loop = possibleOpts[pass].Count - 1; loop >= 0; loop--) { opt = possibleOpts[pass][possibleOpts[pass].Count - 1 - loop]; count++; EditorGUILayout.BeginHorizontal(); if (HasCustomOptions(opt.type) == 0) { GUILayout.Label(optNames[(int)opt.type]); } else { if (GUILayout.Button(optNames[(int)opt.type], GUILayout.MinWidth(48))) { _customOpt = opt; } } if (loop != possibleOpts[pass].Count - 1) { if (GUILayout.Button("UP", GUILayout.Width(32))) { _customOpt = null; opt.order -= 1.5f; } } else { GUILayout.Label(" ", GUILayout.Width(32)); } if (loop > 0) { if (GUILayout.Button("DN", GUILayout.Width(32))) { _customOpt = null; opt.order += 1.5f; } } else { GUILayout.Label(" ", GUILayout.Width(32)); } if (GUILayout.Button("-", GUILayout.Width(24))) { _customOpt = null; _erg.RemoveOptionOfType(opt.type, pass); possibleOpts[pass].Remove(opt); } GUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(GUILayout.Width(16)); EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); epfxm.UpdateAllRenderGroups(); // sampler2D _echoCustomF1Tex; // fixed _echoCustomF1Fade; //fixed4 _echoCustomF1Args; if (_customOpt != null) { GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(2) }); EditorGUILayout.LabelField("Options:"); EditorGUILayout.Space(); switch (HasCustomOptions(_customOpt.type)) { case 1: _customOpt.useUniqueTC = GUILayout.Toggle(_customOpt.useUniqueTC, " Use Unique TexCoord ( Scroll UV Effects )"); EditorGUILayout.Space(); if (GUILayout.Button("Done Editing", GUILayout.Width(128))) { _customOpt = null; } break; case 2: _customOpt.useUniqueTC = GUILayout.Toggle(_customOpt.useUniqueTC, " Use Unique TexCoord ( Scroll UV Effects )"); EditorGUILayout.Space(); EditorGUILayout.LabelField("Fragment Shader Code:"); _customOpt.customCode = EditorGUILayout.TextArea(_customOpt.customCode, GUILayout.Height(128)); if (GUILayout.Button("Done Editing", GUILayout.Width(128))) { _customOpt = null; } //SCOTTFIND EditorGUILayout.Space(); LayoutHelp("fixed3", "_RGB.", "Screen RGB Colors"); LayoutHelp("sampler2D", "_Tex", "Texture"); LayoutHelp("float4", "_Tex_ST", "Tiling(xy) Offset(zw)"); LayoutHelp("texcoord", "_TC", "Texture Coords"); LayoutHelp("fixed", "_Fade", "Percent 0.0-1.0"); LayoutHelp("fixed4", "_Args", "User Values"); LayoutHelp("fixed4", "_Color", "RGBA"); break; case 3: _customOpt.scanlines = (ECHOPFXSCANLINES)EditorGUILayout.EnumPopup("Scanline Types", _customOpt.scanlines); if (GUILayout.Button("Done Editing", GUILayout.Width(128))) { _customOpt = null; } break; default: break; } } EditorGUILayout.Space(); if (EditorGUI.EndChangeCheck()) { _needCompile = true; } }
//============================================================ private static EchoPFXRenderGroup LoadRenderGroup(XmlNode inode) { EchoPFXRenderGroup erg = new EchoPFXRenderGroup(_curID++); XmlNode node; XmlNode childNode; int loop; ECHOPFXOPTION fxo; PossibleOpts po; node = inode.FirstChild; erg.name = inode["name"].InnerText; erg.id = NodeParseInt(inode, "id"); erg.passCount = NodeParseInt(inode, "passCount"); erg.active = NodeParseBool(inode, "active"); erg.cameraDepthStart = NodeParseFloat(inode, "cameraDepthStart"); erg.cameraDepthEnd = NodeParseFloat(inode, "cameraDepthEnd"); erg.meshCellWidth = NodeParseInt(inode, "meshCellWidth"); erg.meshCellHeight = NodeParseInt(inode, "meshCellHeight"); erg.rtAdjustSize = (ECHORTADJUST)NodeParseEnum(inode, "rtAdjustSize", typeof(ECHORTADJUST), (int)ECHORTADJUST.DEVICE_SIZE); erg.rtAdjustWidth = NodeParseInt(inode, "rtAdjustWidth"); erg.rtAdjustHeight = NodeParseInt(inode, "rtAdjustHeight"); erg.rtFilterMode = new FilterMode[2]; erg.rtFilterMode[0] = ( FilterMode )NodeParseEnum(inode, "rtFilterMode1", typeof(FilterMode), (int)FilterMode.Point); erg.rtFilterMode[1] = ( FilterMode )NodeParseEnum(inode, "rtFilterMode2", typeof(FilterMode), (int)FilterMode.Point); erg.rtBlendMode = new ECHOPFXBLEND[2]; erg.rtBlendMode[0] = ( ECHOPFXBLEND )NodeParseEnum(inode, "rtBlendMode1", typeof(ECHOPFXBLEND), (int)ECHOPFXBLEND.NORMAL); erg.rtBlendMode[1] = ( ECHOPFXBLEND )NodeParseEnum(inode, "rtBlendMode2", typeof(ECHOPFXBLEND), (int)ECHOPFXBLEND.NORMAL); node = inode["PossibleOpts1"]; erg.possibleOpts1.Clear(); for (loop = 0; loop < node.ChildNodes.Count; loop++) { childNode = node.ChildNodes[loop]; fxo = ( ECHOPFXOPTION )NodeParseEnum(childNode["type"], typeof(ECHOPFXOPTION), (int)ECHOPFXOPTION.COUNT); if (fxo != ECHOPFXOPTION.COUNT) { po = new PossibleOpts(fxo, loop); po.customCode = NodeParseString(childNode["code"]); erg.possibleOpts1.Add(po); } } node = inode["PossibleOpts2"]; erg.possibleOpts2.Clear(); for (loop = 0; loop < node.ChildNodes.Count; loop++) { childNode = node.ChildNodes[loop]; fxo = ( ECHOPFXOPTION )NodeParseEnum(childNode["type"], typeof(ECHOPFXOPTION), (int)ECHOPFXOPTION.COUNT); if (fxo != ECHOPFXOPTION.COUNT) { po = new PossibleOpts(fxo, loop); po.customCode = NodeParseString(node.ChildNodes[loop]["code"]); erg.possibleOpts2.Add(po); } } node = inode["Effects"]; erg.epeList.Clear(); for (loop = 0; loop < node.ChildNodes.Count; loop++) { erg.epeList.Add(LoadEffect(node.ChildNodes[loop])); } return(erg); }
//========================================================================= public static void WriteFragOption(PossibleOpts ipo, EchoPFXRenderGroup ierg, int ipass) { switch (ipo.type) { case ECHOPFXOPTION.GREYSCALE: _final += _greyscale; break; case ECHOPFXOPTION.INVERSE: _final += _inverse; break; case ECHOPFXOPTION.COLOR: _final += _color; break; case ECHOPFXOPTION.ADD: _final += _add; break; case ECHOPFXOPTION.MULTIPLY: _final += _multiply; break; case ECHOPFXOPTION.NOISE: _final += _noise; break; case ECHOPFXOPTION.DISTORTION: break; case ECHOPFXOPTION.SHOCKWAVE: break; case ECHOPFXOPTION.SCANLINES: if (ipo.scanlines == ECHOPFXSCANLINES.HORIZONTAL || ipo.scanlines == ECHOPFXSCANLINES.BOTH) { _final += _scanlineh; } _final += "\n"; if (ipo.scanlines == ECHOPFXSCANLINES.VERTICAL || ipo.scanlines == ECHOPFXSCANLINES.BOTH) { _final += _scanlinev; } break; case ECHOPFXOPTION.LUMRAMP: _final += _ramp; break; case ECHOPFXOPTION.COLOR_CORRECT: _final += _color_correct; break; case ECHOPFXOPTION.OVERLAY_NORMAL: _final += _overlay_lerp; break; case ECHOPFXOPTION.OVERLAY_SCREEN: _final += _overlay_screen; break; case ECHOPFXOPTION.OVERLAY_ADD: _final += _overlay_add; break; case ECHOPFXOPTION.OVERLAY_SUBTRACT: _final += _overlay_subtract; break; case ECHOPFXOPTION.OVERLAY_MULTIPLY: _final += _overlay_multiply; break; case ECHOPFXOPTION.OVERLAY_OVERLAY: _final += _overlay_overlay; break; case ECHOPFXOPTION.CUSTOM_FRAG_1: _final += "#ifdef ECHO_PFX_CUSTOM_FRAG_1_ON\n"; _final += ParseCustomCode(ipo.type, ipo.customCode) + "\n"; _final += "#endif\n"; break; case ECHOPFXOPTION.CUSTOM_FRAG_2: _final += "#ifdef ECHO_PFX_CUSTOM_FRAG_2_ON\n"; _final += ipo.customCode + "\n"; _final += "#endif\n"; break; case ECHOPFXOPTION.CUSTOM_FRAG_3: _final += "#ifdef ECHO_PFX_CUSTOM_FRAG_3_ON\n"; _final += ipo.customCode + "\n"; _final += "#endif\n"; break; case ECHOPFXOPTION.CUSTOM_FRAG_4: _final += "#ifdef ECHO_PFX_CUSTOM_FRAG_4_ON\n"; _final += ipo.customCode + "\n"; _final += "#endif\n"; break; } _final += "\n"; }