Exemplo n.º 1
0
    void OnGUI() {
		//if(Event.current.type==EventType.Repaint)
		ValueChanged = false;
		RunHotkeys();
		ShaderUtil.Rects.Clear();
		//ShaderSandwich windowG = this;//(ShaderSandwich)EditorWindow.GetWindow (typeof (ShaderSandwich),false,"",false);
		Instance = this;
		int MenuPad = 15;
		
		Vector2 WinSize = new Vector2(position.width,position.height);
		Vector2 WinSize2 = new Vector2(position.width,position.height-MenuPad);
		
		GUIMouseDown = false;
		GUIMouseUp = false;
		
		if ((Event.current.type == EventType.MouseDown))
		GUIMouseDown = true;
		if ((Event.current.type == EventType.MouseUp))
		GUIMouseUp = true;
		
		if (GUIMouseDown)
		GUIMouseHold = true;		
		if (GUIMouseUp)
		GUIMouseHold = false;
		
		LoadAssets();
		SSSettings.CurPath = CurrentFilePath;
		GUISkin oldskin = GUI.skin;
		if(Event.current.type==EventType.Repaint)
		ShaderUtil.AddProSkin(WinSize);

		if (ShaderVarEditing!=null)
		ShaderVarEditing.UseEditingMouse(false);
		
		bool SVMD = false;
		if (ShaderVarEditing!=null&&(Event.current.type!=EventType.Repaint))//.type== EventType.MouseDown))
		SVMD = true;
		
		if (SVMD)
		ShaderUtil.BeginGroup(new Rect(0,0,0,0));
		if (OpenShader!=null&&AnimateInputs&&Event.current.type==EventType.Repaint){
			foreach(ShaderInput SI in OpenShader.ShaderInputs)
			SI.Update();
		}		
			//if (EditorWindow.focusedWindow==this)
			Repaint();
			//TransitionTime = Mathf.Min(TransitionTime,1);
			if (GUITrans.DoneHit())
			{
				GUIStage = GUITransition;
			}
	
			float Movement = 0f;
			if (GUITrans.Transitioning==ShaderTransition.TransDir.Backward)
			Movement = WinSize.x;
			
			if (GUIStage==GUIType.Start)
				GUIStart(WinSize2,new Vector2(-GUITrans.Get()*WinSize.x+Movement,MenuPad));
			else if (GUIStage==GUIType.Presets)
				GUIPresets(WinSize2,new Vector2(-GUITrans.Get()*WinSize.x+Movement,MenuPad));
			else if (GUIStage==GUIType.Configure)
				GUIConfigure(WinSize2,new Vector2(-GUITrans.Get()*WinSize.x+Movement,MenuPad));
			else if (GUIStage==GUIType.Layers)
				GUILayers(WinSize2,new Vector2(-GUITrans.Get()*WinSize.x+Movement,MenuPad));
			else if (GUIStage==GUIType.Inputs)
				GUIInputs(WinSize2,new Vector2(-GUITrans.Get()*WinSize.x+Movement,MenuPad));
			
			if (GUITrans.Done()!=true)
			{
				Movement = WinSize2.x;
				if (GUITrans.Transitioning==ShaderTransition.TransDir.Backward)
				Movement = 0*WinSize2.x;
				
				if (GUITransition==GUIType.Start)
					GUIStart(WinSize2,new Vector2(-GUITrans.Get()*WinSize.x+Movement,MenuPad));
				else if (GUITransition==GUIType.Presets)
					GUIPresets(WinSize2,new Vector2(-GUITrans.Get()*WinSize.x+Movement,MenuPad));
				else if (GUITransition==GUIType.Configure)
					GUIConfigure(WinSize2,new Vector2(-GUITrans.Get()*WinSize.x+Movement,MenuPad));
				else if (GUITransition==GUIType.Layers)
					GUILayers(WinSize2,new Vector2(-GUITrans.Get()*WinSize.x+Movement,MenuPad));
				else if (GUITransition==GUIType.Inputs)
					GUIInputs(WinSize2,new Vector2(-GUITrans.Get()*WinSize.x+Movement,MenuPad));
			}
			DrawMenu();
		
		if (SVMD)
		ShaderUtil.EndGroup();
		
		if (ShaderVarEditing!=null)
		ShaderVarEditing.UseEditingMouse(true);
		
		

		//Debug.Log(GUI.tooltip=="");
		//Debug.Log(TooltipAlpha);
		//GUI.color = new Color(GUI.color.r,GUI.color.g,GUI.color.b,TooltipAlpha);

		GUI.skin = oldskin;
		ShaderUtil.DrawTooltip(0,WinSize);
		if (GUI.changed==true){
			changedTimer = 100;
		}
		changedTimer -=1;
		/*if (changedTimer>-100&&changedTimer<=0)
		{
			if (OpenShader!=null)
			OpenShader.RecalculateAutoInputs();
			changedTimer = -200;
		}*/
		if (PleaseReimport!=""&&Event.current.type==EventType.Repaint){
			GiveMeAFrame+=1;
			if (GiveMeAFrame==4){
			AssetDatabase.ImportAsset(PleaseReimport,ImportAssetOptions.ForceSynchronousImport);
			SetStatus("Updating Preview Window","Preview Updated.",1f);
			PleaseReimport = "";
			GiveMeAFrame = 0;
			}
		}
		
    }
Exemplo n.º 2
0
	public static void Init () {
		
		ShaderSandwich windowG = (ShaderSandwich)EditorWindow.GetWindow (typeof (ShaderSandwich));
		Instance = windowG;
		LoadPlugins();
		windowG.wantsMouseMove = true;
		//windowG.minSize = new Vector2(950,460);//460
		windowG.minSize = new Vector2(800,450);//460
		//Rect tempPos = windowG.position;
		//Debug.Log(tempPos);
		//tempPos.width = 950;
		//tempPos.height = 460;
		windowG.position = new Rect(200,200,950,460);
		windowG.title = "Shader Sandwich"; 
		
		//LoadAssets();
		windowG.MOTD = getAnswerFromOutside("http://electronic-mind.org/ShaderSandwich/MOTD.txt");
		string tempStr = "";
		bool commentedOut = false;
		foreach (char c in windowG.MOTD)
		{
			if (c.ToString()=="~")
			commentedOut=true;
			
			if (commentedOut==false)
			tempStr+=c;
			
			if (c.ToString()=="~")
			commentedOut=false;			
		}
		windowG.MOTD = tempStr;
		

		//if (windowS.QuestionMarkOff==null)
		//windowG.OnEnable();
		
		//ShaderSandwich.Instance.OpenShader = new ShaderBase();
	}