bool GUILayersBox(ShaderLayerList list, int X,Vector2 WinSize,GUIStyle ButtonStyle){ list.FixParents(); WinSize.y-=30; ShaderUtil.BeginGroup(new Rect(150*X,30,150,WinSize.y)); GUI.Box(new Rect(0,0,150,WinSize.y),"",ButtonStyle); list.Scroll = ShaderUtil.BeginScrollView(new Rect(0,48,150,WinSize.y-48-100-32),list.Scroll,new Rect(0,0,130,list.Count*110-10),false,false); int Pos = -1; bool Hit = false; list.LayerCatagory = list.Name.Text; foreach(ShaderLayer SL in list) { //if (Event.current.type==EventType.Repaint) //ShaderUtil.BeginGroup(new Rect(-9000,0,0,0)); //SL.DrawGUI(); //ShaderUtil.EndGroup(); if (SL.Name.Text=="") SL.Name.Text = SL.GetLayerCatagory(); if (SL.BugCheck()) ChangeSaveTemp(SL); Pos+=1; bool OldGUIChanged = GUI.changed; if ((Pos*110+80-list.Scroll.y)>0&&(Pos*110-list.Scroll.y<(WinSize.y-150))){ if ((X)==LayerSelection.x&&(Pos)==LayerSelection.y) { SL.DrawIcon(new Rect(30-(15),Pos*110,90,90),true); } else { if (SL.DrawIcon(new Rect(30-(15),Pos*110,90,90),false)){ LayerSelection = new Vector2(X,Pos); ShaderUtil.Defocus(); } } } GUI.skin.label.alignment = TextAnchor.LowerCenter; if (ViewLayerNames) ShaderUtil.Label(new Rect(30-(15),Pos*110,90,90),SL.Name.Text,11); GUI.skin.label.alignment = TextAnchor.UpperLeft; GUI.changed = OldGUIChanged; if (Event.current.type == EventType.MouseDown && new Rect(30-(15),Pos*110,90,90).Contains(Event.current.mousePosition)) Hit = true; if (Pos==0) GUI.enabled = false; ShaderUtil.MakeTooltip(0,new Rect(120-(15),Pos*110,30,30),"Move Layer Up"); if (GUI.Button(new Rect(120-(15),Pos*110,30,30),new GUIContent(UPArrow))) { list.MoveItem(Pos,Pos-1);//MoveLayerUp = Pos; list.UpdateIcon(new Vector2(70,70)); ChangeSaveTemp(null); //RegenShaderPreview(); EditorGUIUtility.ExitGUI(); } GUI.enabled = true; ShaderUtil.MakeTooltip(0,new Rect(120-(15),Pos*110+30,30,30),"Delete Layer"); if (GUI.Button(new Rect(120-(15),Pos*110+30,30,30),new GUIContent(CrossRed))) { list.RemoveAt(Pos); UEObject.DestroyImmediate(SL,false); list.UpdateIcon(new Vector2(70,70)); ChangeSaveTemp(null); //RegenShaderPreview(); EditorGUIUtility.ExitGUI(); } if (Pos>=list.Count-1) GUI.enabled = false; ShaderUtil.MakeTooltip(0,new Rect(120-(15),Pos*110+60,30,30),"Move Layer Down"); if (GUI.Button(new Rect(120-(15),Pos*110+60,30,30),new GUIContent(DOWNArrow,"Move Layer Down"))) { //Pos2+=1; list.MoveItem(Pos,Pos+1);//MoveLayerDown = Pos; list.UpdateIcon(new Vector2(70,70)); ChangeSaveTemp(null); //RegenShaderPreview(); EditorGUIUtility.ExitGUI(); } GUI.enabled = true; //GUI.Label(new Rect(30,48+Pos*110+75,60,30),"Editor: "); //GUI.color = new Color(1f,1f,1f,1f); //GUI.backgroundColor = new Color(1f,1f,1f,1f); //SL.LayerType.UseInput = GUI.Toggle(new Rect(80,48+Pos*110+75,30,30),SL.LayerType.UseInput,""); //GUI.color = oldCol; //GUI.backgroundColor = oldColB; } ShaderUtil.EndScrollView(); GUI.Box(new Rect(0,0,150,48),"",ButtonStyle); if (OpenShader.ShaderLayersMasks.Contains(list)) list.Name.Text = GUI.TextField(new Rect(10,10,150-20,48-20),list.Name.Text,ButtonStyle); else GUI.Label(new Rect(0,0,150,48),list.Name.Text,ButtonStyle); if (list.Count==0) ShaderUtil.Label(new Rect(5,48,140,48),list.Description,12); GUI.Box(ShaderUtil.Rect2(RectDir.Diag,150,WinSize.y-100,150,32),""); ShaderUtil.MakeTooltip(0,ShaderUtil.Rect2(RectDir.Diag,150,WinSize.y-100,32,32),"Add Layer"); if (GUI.Button(ShaderUtil.Rect2(RectDir.Diag,150,WinSize.y-100,32,32),new GUIContent(Plus,"Add Layer"))){ list.Add(ShaderLayer.CreateInstance<ShaderLayer>()); LayerSelection = new Vector2(X,list.Count-1); } if (OpenShader.ShaderLayersMasks.Contains(list)||list==OpenShader.ShaderLayersMaskTemp){ int ColorSelection = 0; if (list.EndTag.Text=="r") ColorSelection = 0; if (list.EndTag.Text=="g") ColorSelection = 1; if (list.EndTag.Text=="b") ColorSelection = 2; if (list.EndTag.Text=="a") ColorSelection = 3; if (list.EndTag.Text=="rgba") ColorSelection = 4; string[] ColorTag = new string[]{"Red","Green","Blue", "Alpha","RGBA"}; string[] ColorTag2 = new string[]{"r","g","b", "a","rgba"}; /*if (GUI.Button(ShaderUtil.Rect2(RectDir.Bottom,1,WinSize.y-100,(150-33)/2,32),ColorTag[ColorSelection],"button")){ GenericMenu toolsMenu = new GenericMenu(); toolsMenu.AddItem(new GUIContent("Red"), false, MashMakeRed,list); toolsMenu.AddItem(new GUIContent("Green"), false, MashMakeGreen,list); toolsMenu.AddItem(new GUIContent("Blue"), false, MashMakeBlue,list); toolsMenu.AddItem(new GUIContent("Alpha"), false, MashMakeAlpha,list); toolsMenu.AddItem(new GUIContent("RGBA"), false, MashMakeRGBA,list); toolsMenu.DropDown(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0)); list.UpdateIcon(new Vector2(70,70)); ChangeSaveTemp(null); EditorGUIUtility.ExitGUI(); }*/ //VertexMask.Float = (float)(int)(VertexMasks)EditorGUI.EnumPopup(new Rect(0,YOffset,250,20)," ",(VertexMasks)(int)VertexMask.Float,ShaderUtil.EditorPopup); EditorGUI.BeginChangeCheck(); ShaderUtil.MakeTooltip(0,ShaderUtil.Rect2(RectDir.Bottom,32,WinSize.y-100-16,(150-32-32),16),"The channel the mask uses."); ColorSelection = EditorGUI.IntPopup(ShaderUtil.Rect2(RectDir.Bottom,32,WinSize.y-100-16,(150-32-32),16),ColorSelection,ColorTag,new int[]{0,1,2,3,4},ShaderUtil.EditorPopup); if (EditorGUI.EndChangeCheck()){ list.UpdateIcon(new Vector2(70,70)); ChangeSaveTemp(null); list.EndTag.Text = ColorTag2[ColorSelection]; } ShaderUtil.MakeTooltip(0,new Rect(0,WinSize.y-132,32,32),"Set the mask to be a lighting mask."); EditorGUI.BeginChangeCheck(); GUI.Toggle(new Rect(0,WinSize.y-132,32,32),list.IsLighting.On,list.IsLighting.On?LightBulbOn:LightBulbOff,ButtonStyle); if (EditorGUI.EndChangeCheck()) { if (EditorUtility.DisplayDialog(list.IsLighting.On?"Switch back to normal mask?":"Switch to lighting mask?", "Switching between normal and lighting masks will remove all layers within the mask. Are you sure you want to do this?", "Yes", "No")){ list.SLs.Clear(); list.IsLighting.On = !list.IsLighting.On; //OpenShader.ShaderLayersMasks.Remove(list); CorrectAllLayers(); list.UpdateIcon(new Vector2(70,70)); ChangeSaveTemp(null); EditorGUIUtility.ExitGUI(); } } ShaderUtil.MakeTooltip(0,new Rect(31,WinSize.y-117,29,17),"Delete the Mask (You can't undo this!)."); if (GUI.Button(new Rect(31,WinSize.y-117,29,17),CrossRed,ButtonStyle)) { if (EditorUtility.DisplayDialog("Delete Mask?", "Are you sure you want to delete this mask? It can't be undone!", "Yes", "No")){ OpenShader.ShaderLayersMasks.Remove(list); CorrectAllLayers(); ChangeSaveTemp(null); EditorGUIUtility.ExitGUI(); } } ShaderUtil.MakeTooltip(0,new Rect(31+29,WinSize.y-117,29,17),"Move the mask to the left."); if (GUI.Button(new Rect(31+29,WinSize.y-117,29,17),LeftArrow,ButtonStyle)) { ShaderUtil.MoveItem(ref OpenShader.ShaderLayersMasks,OpenShader.ShaderLayersMasks.IndexOf(list),OpenShader.ShaderLayersMasks.IndexOf(list)-1); CorrectAllLayers(); ChangeSaveTemp(null); EditorGUIUtility.ExitGUI(); } ShaderUtil.MakeTooltip(0,new Rect(31+29+29,WinSize.y-117,29,17),"Move the mask to the right."); if (GUI.Button(new Rect(31+29+29,WinSize.y-117,29,17),RightArrow,ButtonStyle)) { ShaderUtil.MoveItem(ref OpenShader.ShaderLayersMasks,OpenShader.ShaderLayersMasks.IndexOf(list),OpenShader.ShaderLayersMasks.IndexOf(list)+1); CorrectAllLayers(); ChangeSaveTemp(null); EditorGUIUtility.ExitGUI(); } } else if (list.EndTag.Text.Length==1){//||OpenShader.ShaderLayersMasks.Contains(list)){ int ColorSelection = 0; if (list.EndTag.Text=="r") ColorSelection = 0; if (list.EndTag.Text=="g") ColorSelection = 1; if (list.EndTag.Text=="b") ColorSelection = 2; if (list.EndTag.Text=="a") ColorSelection = 3; string[] ColorTag = new string[]{"r","g","b", "a"}; string OldEndTag = list.EndTag.Text; list.EndTag.Text = ColorTag[GUI.SelectionGrid(ShaderUtil.Rect2(RectDir.Bottom,1,WinSize.y-100,150-33,32),ColorSelection,new string[]{"R","G","B", "A"},4)]; if (list.EndTag.Text!=OldEndTag) list.UpdateIcon(new Vector2(70,70)); } if (Flatter) GUI.Box(ShaderUtil.Rect2(RectDir.Bottom,0,WinSize.y,150,100),"");//,ButtonStyle); else GUI.Box(ShaderUtil.Rect2(RectDir.Bottom,0,WinSize.y,150,100),"",ButtonStyle); ShaderUtil.MakeTooltip(0,new Rect(150-16,WinSize.y-100,16,16),"Reload layer preview (In case it hasn't updated)."); GUIStyle ButtonStyle2 = new GUIStyle(ButtonStyle); ButtonStyle2.padding = new RectOffset(2,2,2,2); ButtonStyle2.margin = new RectOffset(2,2,2,2); if (GUI.Button(new Rect(150-16,WinSize.y-100,16,16),ReloadIcon,ButtonStyle2)) GUI.changed = true; list.DrawIcon(ShaderUtil.Rect2(RectDir.Bottom,25+15,WinSize.y-15,100-30,100-30),GUI.changed); if (Event.current.button == 1&&ShaderUtil.MouseDownIn(new Rect(0,0,ShaderUtil.GetGroupRect().width,ShaderUtil.GetGroupRect().height-100-30)) ){ GenericMenu toolsMenu = new GenericMenu(); toolsMenu.AddItem(new GUIContent("Paste"), false, LayerPaste,list); toolsMenu.DropDown(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0)); EditorGUIUtility.ExitGUI(); } ShaderUtil.EndGroup(); return Hit; }