Exemple #1
0
	void NewAdvanced(){
		if (OpenShader!=null)
			OpenShader.CleanUp();
		OpenShader = ShaderBase.CreateInstance<ShaderBase>();
		OpenShader.DiffMode.On = true;
		ShaderSandwich.ShaderLayerTab = ShaderLayerTabs.Base;
		Goto(GUIType.Layers,ShaderTransition.TransDir.Forward);
		ChangeSaveTemp(null);
		CurrentFilePath = "";
	}
Exemple #2
0
	void NewSimple(){
		if (OpenShader!=null)
			OpenShader.CleanUp();
		OpenShader = ShaderBase.CreateInstance<ShaderBase>();
		ShaderSandwich.ShaderLayerTab = ShaderLayerTabs.Base;
		Goto(GUIType.Presets,ShaderTransition.TransDir.Forward);
		ChangeSaveTemp(null);
		CurrentFilePath = "";
	}
Exemple #3
0
	void GUILayers(Vector2 WinSize,Vector2 Position)
	{
		RunHotkeys();
		ShaderBase SSIO = OpenShader;
		if (SSIO==null)
		{
			GUIStage = GUIType.Start;
			GUITrans.Reset();
		}
		else
		{
			ShaderUtil.BeginGroup(new Rect(Position.x,Position.y,WinSize.x,WinSize.y));

			int ListCount = 1;
			if (ShaderLayerTab == ShaderLayerTabs.Base){
				ListCount+=1;
				ListCount+=1;
				if (SSIO.SpecularOn.On==true)
					ListCount+=1;	
				if (SSIO.EmissionOn.On==true)
					ListCount+=1;
				if (SSIO.ParallaxOn.On==true)
					ListCount+=1;
				if (SSIO.TransparencyOn.On==true)
					ListCount+=1;
			}
			if (ShaderLayerTab == ShaderLayerTabs.Shell){
				ListCount+=1;
				
				if (SSIO.SpecularOn.On==true)
					ListCount+=1;	
				if (SSIO.EmissionOn.On==true)
					ListCount+=1;
				if (SSIO.TransparencyOn.On==true)
					ListCount+=1;
			}
			if (ShaderLayerTab == ShaderLayerTabs.Lighting){
				ListCount+=3;
			}
			if (ShaderLayerTab == ShaderLayerTabs.Mask)
			{
				//foreach(ShaderLayerList SLL in SSIO.ShaderLayersMasks)
				//for (int i = 0;i++
				//{
					ListCount += SSIO.ShaderLayersMasks.Count;//+=1;
				//}
			}

			
			LayerListScroll = ShaderUtil.BeginScrollView(new Rect(264,0,WinSize.x-264,WinSize.y),LayerListScroll,new Rect(0,0,ListCount*150,WinSize.y-20),false,false);
			GUIStyle ButtonStyle;
			if(Flatter){
			ButtonStyle = new GUIStyle(GUI.skin.box);
			ButtonStyle.alignment = TextAnchor.MiddleCenter;
			}
			else
			ButtonStyle = new GUIStyle(GUI.skin.button);
			
			ButtonStyle.fontSize = 20;	
			
			List<List<ShaderLayer>> SLList = new List<List<ShaderLayer>>();
			GUI.color = BackgroundColor;
			GUI.DrawTexture( new Rect(264,30,300,25), EditorGUIUtility.whiteTexture );
			GUI.color = new Color(1f,1f,1f,1f);
			
			int Pos = 0;
			bool Hit = false;
			
			if (ShaderLayerTab == ShaderLayerTabs.Lighting)
			{
				if(GUILayersBox(SSIO.ShaderLayersLightingAll,Pos,WinSize,ButtonStyle))Hit = true;
				SLList.Add(SSIO.ShaderLayersLightingAll.SLs);
				Pos+=1;
				if(GUILayersBox(SSIO.ShaderLayersLightingDiffuse,Pos,WinSize,ButtonStyle))Hit = true;
				SLList.Add(SSIO.ShaderLayersLightingDiffuse.SLs);
				Pos+=1;
				if(GUILayersBox(SSIO.ShaderLayersLightingSpecular,Pos,WinSize,ButtonStyle))Hit = true;
				SLList.Add(SSIO.ShaderLayersLightingSpecular.SLs);
				Pos+=1;
				if(GUILayersBox(SSIO.ShaderLayersLightingAmbient,Pos,WinSize,ButtonStyle))Hit = true;
				SLList.Add(SSIO.ShaderLayersLightingAmbient.SLs);
			}
			if (ShaderLayerTab == ShaderLayerTabs.Base)
			{
				if(GUILayersBox(SSIO.ShaderLayersDiffuse,Pos,WinSize,ButtonStyle))Hit = true;
				SLList.Add(SSIO.ShaderLayersDiffuse.SLs);
				
				Pos+=1;
				if(GUILayersBox(SSIO.ShaderLayersNormal,Pos,WinSize,ButtonStyle))Hit = true;
				SLList.Add(SSIO.ShaderLayersNormal.SLs);
				
				Pos+=1;
				if(GUILayersBox(SSIO.ShaderLayersVertex,Pos,WinSize,ButtonStyle))Hit = true;
				SLList.Add(SSIO.ShaderLayersVertex.SLs);
				
				if (SSIO.SpecularOn.On==true){
					Pos+=1;
					if(GUILayersBox(SSIO.ShaderLayersSpecular,Pos,WinSize,ButtonStyle))Hit = true;
					SLList.Add(SSIO.ShaderLayersSpecular.SLs);
				}		
				if (SSIO.EmissionOn.On==true){
					Pos+=1;
					if(GUILayersBox(SSIO.ShaderLayersEmission,Pos,WinSize,ButtonStyle))Hit = true;
					SLList.Add(SSIO.ShaderLayersEmission.SLs);
				}
				if (SSIO.ParallaxOn.On==true){
					Pos+=1;
					if(GUILayersBox(SSIO.ShaderLayersHeight,Pos,WinSize,ButtonStyle))Hit = true;
					SLList.Add(SSIO.ShaderLayersHeight.SLs);
				}
				if (SSIO.TransparencyOn.On==true){
					Pos+=1;
					if(GUILayersBox(SSIO.ShaderLayersAlpha,Pos,WinSize,ButtonStyle))Hit = true;
					SLList.Add(SSIO.ShaderLayersAlpha.SLs);
				}
			}			
			if (ShaderLayerTab == ShaderLayerTabs.Shell)
			{
				if(GUILayersBox(SSIO.ShaderLayersShellDiffuse,Pos,WinSize,ButtonStyle))Hit = true;
				SLList.Add(SSIO.ShaderLayersShellDiffuse.SLs);
				
				Pos+=1;
				if(GUILayersBox(SSIO.ShaderLayersShellNormal,Pos,WinSize,ButtonStyle))Hit = true;
				SLList.Add(SSIO.ShaderLayersShellNormal.SLs);
				
				if (SSIO.SpecularOn.On==true){
					Pos+=1;
					if(GUILayersBox(SSIO.ShaderLayersShellSpecular,Pos,WinSize,ButtonStyle))Hit = true;
					SLList.Add(SSIO.ShaderLayersShellSpecular.SLs);
				}		
				if (SSIO.EmissionOn.On==true){
					Pos+=1;
					if(GUILayersBox(SSIO.ShaderLayersShellEmission,Pos,WinSize,ButtonStyle))Hit = true;
					SLList.Add(SSIO.ShaderLayersShellEmission.SLs);
				}
				if (SSIO.TransparencyOn.On==true){
					Pos+=1;
					if(GUILayersBox(SSIO.ShaderLayersShellAlpha,Pos,WinSize,ButtonStyle))Hit = true;
					SLList.Add(SSIO.ShaderLayersShellAlpha.SLs);
				}
			}
			if (ShaderLayerTab == ShaderLayerTabs.Mask)
			{
				if ((Event.current.type == EventType.MouseDown&&new Rect(150*(Pos+SSIO.ShaderLayersMasks.Count),30,150,WinSize.y).Contains(Event.current.mousePosition)))
				OpenShader.AddMask();
				foreach(ShaderLayerList SLL in SSIO.ShaderLayersMasks)
				{
					if(GUILayersBox(SLL,Pos,WinSize,ButtonStyle))Hit = true;
					SLList.Add(SLL.SLs);
					
					Pos+=1;
				}
				if (!(Event.current.type == EventType.Repaint&&new Rect(150*Pos,30,150,WinSize.y).Contains(Event.current.mousePosition)))GUI.enabled = false;
				GUILayersBox(SSIO.ShaderLayersMaskTemp,Pos,WinSize,ButtonStyle);

				GUI.Label(new Rect(150*Pos+18,120,150,WinSize.y),"Click to Add Mask");
				
				GUI.enabled = true;
				Pos+=1;
				//if (GUI.Button(new Rect(Pos*150,(WinSize.y-64),64,64),Plus))
				//OpenShader.AddMask();
			}
			ShaderUtil.EndScrollView();
			GUI.skin.GetStyle("ButtonLeft").alignment = TextAnchor.MiddleLeft;
			GUI.skin.GetStyle("ButtonRight").alignment = TextAnchor.MiddleLeft;
			GUI.skin.GetStyle("ButtonMid").alignment = TextAnchor.MiddleLeft;
			
			//SeeShells = !GUI.Toggle(new Rect(251,10,100,25),!SeeShells,new GUIContent("Base",IconBase),GUI.skin.GetStyle("ButtonLeft"));
			if (ShaderLayerTab != ShaderLayerTabs.Base){
				if (GUI.Button(new Rect(264,6,100,25),new GUIContent("Base",IconBase),GUI.skin.GetStyle("ButtonLeft")))ShaderLayerTab = ShaderLayerTabs.Base;
			}
			else{
				GUI.Toggle(new Rect(264,6,100,25),true,new GUIContent("Base",IconBase),GUI.skin.GetStyle("ButtonLeft"));
			}
			
			if (!OpenShader.ShellsOn.On)GUI.enabled = false;

			if (ShaderLayerTab != ShaderLayerTabs.Shell){
				if (GUI.Button(new Rect(364,6,100,25),new GUIContent("Shell",IconShell),GUI.skin.GetStyle("ButtonMid")))ShaderLayerTab = ShaderLayerTabs.Shell;
			}
			else{
				GUI.Toggle(new Rect(364,6,100,25),true,new GUIContent("Shell",IconShell),GUI.skin.GetStyle("ButtonMid"));
			}			
			
			GUI.enabled = true;
			
			if (ShaderLayerTab != ShaderLayerTabs.Mask){
				if (GUI.Button(new Rect(464,6,100,25),new GUIContent("Mask",IconMask),GUI.skin.GetStyle("ButtonMid")))ShaderLayerTab = ShaderLayerTabs.Mask;
			}
			else{
				GUI.Toggle(new Rect(464,6,100,25),true,new GUIContent("Mask",IconMask),GUI.skin.GetStyle("ButtonMid"));
			}
			
			GUI.enabled = true;
			if (ShaderLayerTab != ShaderLayerTabs.Lighting){
				if (GUI.Button(new Rect(564,6,100,25),new GUIContent("Lighting",IconMask),GUI.skin.GetStyle("ButtonRight")))ShaderLayerTab = ShaderLayerTabs.Lighting;
			}
			else{
				GUI.Toggle(new Rect(564,6,100,25),true,new GUIContent("Lighting",IconMask),GUI.skin.GetStyle("ButtonRight"));
			}
			GUI.enabled = true;
			
			GUI.Box(new Rect(0,0,264,WinSize.y),"",ButtonStyle);
			
			
			if (Hit==false&&Event.current.type == EventType.MouseDown&&!(new Rect(0,0,264,WinSize.y).Contains(Event.current.mousePosition)))
			LayerSelection = new Vector2(20,20);
			
			ShaderLayer DrawLayer = null;
			//if (LayerSelection.x==0)
			//{
				if (LayerSelection.x<SLList.Count)
				if (LayerSelection.y<SLList[(int)LayerSelection.x].Count)
				if (SLList[(int)LayerSelection.x][(int)LayerSelection.y]!=null)
				DrawLayer = SLList[(int)LayerSelection.x][(int)LayerSelection.y];
			//}
			
			
			GUI.Box(new Rect(0,0,264,48),"Layer Settings",ButtonStyle);
			int ScrollHeight = 660;
			
			ShaderUtil.BeginGroup(new Rect(0,48,264,WinSize.y-48));
			if (!((WinSize.y-48-30)>ScrollHeight))
			LayerScroll = ShaderUtil.BeginScrollView(new Rect(0,0,264,WinSize.y-48-30),LayerScroll,new Rect(0,0,230,ScrollHeight),false,true);
			else{
			ShaderUtil.BeginScrollView(new Rect(0,0,264,WinSize.y-48-30),new Vector2(0,0),new Rect(0,0,230,ScrollHeight),false,true);
			ShaderUtil.EndScrollView();
			}
			
			
			if (AnimateInputs&&Event.current.type==EventType.Repaint&&DrawLayer!=null){
				foreach(ShaderLayer SL in DrawLayer.Parent.SLs){
					SL.UpdateShaderVars(true);
					foreach(ShaderVar SV in SL.ShaderVars)
					SV.UpdateToInput(true);
				}
			}
			
			if (DrawLayer!=null)
				DrawLayer.DrawGUI();
			else
				ShaderLayer.DrawGUIGen(true);
			//if ((WinSize.y-48)<=ScrollHeight)
			if (!((WinSize.y-48-30)>ScrollHeight))
			ShaderUtil.EndScrollView();
			ShaderUtil.EndGroup();
			ChangeSaveTemp(DrawLayer);
			
			if (GUI.Button( ShaderUtil.Rect2(RectDir.Bottom,0,WinSize.y,64,30),"Back",ButtonStyle))
				Goto(GUIType.Start,ShaderTransition.TransDir.Backward);
			if (GUI.Button( ShaderUtil.Rect2(RectDir.Bottom,64,WinSize.y,110,30),"Settings",ButtonStyle))
				Goto(GUIType.Configure,ShaderTransition.TransDir.Backward);	
			if (GUI.Button( ShaderUtil.Rect2(RectDir.Bottom,174,WinSize.y,100-24,30),"Inputs",ButtonStyle))
				Goto(GUIType.Inputs,ShaderTransition.TransDir.Backward);
			
			ShaderUtil.EndGroup();
		}
		
	}