topical media & game development

talk show tell print

lib-unity-demo-shader-Assets-Depth-of-Field-DOFGui.js / js



  
  
  function OnGUI() {
          var dof : DepthOfFieldEffect = GetComponent(DepthOfFieldEffect);
          GUILayout.BeginArea(Rect(5,5,250,80), GUI.skin.window);
          GUILayout.Label("Focal distance (1/2 to change): " + dof.focalDistance.ToString("f1"));
          GUILayout.Label("Focal range (3/4 to change): " + dof.focalRange.ToString("f1"));
          GUILayout.EndArea();
  }
  
  function Update() {
          var dof : DepthOfFieldEffect = GetComponent(DepthOfFieldEffect);
          var dt = Time.deltaTime;
          if (Input.GetKey("1"))
                  dof.focalDistance -= 5*dt;
          if (Input.GetKey("2"))
                  dof.focalDistance += 5*dt;
          if (Input.GetKey("3"))
                  dof.focalRange -= 5*dt;
          if (Input.GetKey("4"))
                  dof.focalRange += 5*dt;
          dof.focalDistance = Mathf.Clamp(dof.focalDistance, 1.0, 15.0);
          dof.focalRange = Mathf.Clamp(dof.focalRange, 1.0, 30.0);
  }


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.