Example #1
0
        void Follow()
        {
            sceneViews = UnityEditor.SceneView.sceneViews;
            if (sceneViewFollowers == null || !on || sceneViews.Count == 0)
            {
                return;
            }

            foreach (SceneViewFollower svf in sceneViewFollowers)
            {
                if (!svf.enable)
                {
                    continue;
                }
                UnityEditor.SceneView sceneView = (UnityEditor.SceneView)sceneViews[svf.sceneViewIndex];
                if (sceneView != null)
                {
                    if ((Application.isPlaying && onlyInPlayMode) || !onlyInPlayMode)
                    {
                        sceneView.orthographic = svf.orthographic;
                        sceneView.LookAtDirect(svf.targetTransform.position + svf.positionOffset, (svf.enableFixedRotation) ? Quaternion.Euler(svf.fixedRotation) : svf.targetTransform.rotation, svf.size);
                    }
                }
            }
        }
Example #2
0
		/// <summary>
		/// <para>Seguimiento de la vista al objetivo</para>
		/// </summary>
		private void Follow()// Seguimiento de la vista al objetivo
		{
			// Selecciona la sceneview actual
			sceneViews = UnityEditor.SceneView.sceneViews;

			// Si no se cumplen las condiciones optimas, return
			if (svSeguidor == null || !on || sceneViews.Count == 0) return;

			// Recorremos todas
			foreach (SceneViewSeguidor svs in svSeguidor)
			{
				// Si no esta activado continuamos
				if (svs.activado == false) continue;

				// Fijamos la sceneview
				UnityEditor.SceneView sceneView = (UnityEditor.SceneView)sceneViews[svs.sceneViewIndex];

				if (sceneView != null)
				{
					if ((Application.isPlaying && soloEnPlayMode) || !soloEnPlayMode)
					{
						// Seguimos
						sceneView.orthographic = svs.ortographic;
						sceneView.LookAtDirect(svs.objetivo.position + svs.posicionOffset, (svs.activarFixedRotacion) ? Quaternion.Euler(svs.fixedRotacion) : svs.objetivo.rotation, svs.distancia);
					}
				}
			}
		}
    public void OnSceneGUI()
    {
 
        current = Event.current;
 
        if (!current.isKey || current.type != EventType.keyDown)
            return;
 
        sceneView = UnityEditor.SceneView.lastActiveSceneView;
        eulerAngles = sceneView.camera.transform.rotation.eulerAngles;
        rotHelper = sceneView.camera.transform.rotation;
 
        switch (current.keyCode)
        {
            case KeyCode.Keypad1:
                if (current.control == false)
                    sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(0f, 360f, 0f)));
                else
                    sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(0f, 180f, 0f)));
                break;
            case KeyCode.Keypad2:
                sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, rotHelper * Quaternion.Euler(new Vector3(-15f, 0f, 0f)));
                break;
            case KeyCode.Keypad3:
                if (current.control == false)
                    sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(0f, 270f, 0f)));
                else
                    sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(0f, 90f, 0f)));
                break;
            case KeyCode.Keypad4:
                sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(eulerAngles.x, eulerAngles.y + 15f, eulerAngles.z)));
                break;
            case KeyCode.Keypad5:
                sceneView.orthographic = !sceneView.orthographic;
                break;
            case KeyCode.Keypad6:
                sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(eulerAngles.x, eulerAngles.y - 15f, eulerAngles.z)));
                break;
            case KeyCode.Keypad7:
                if (current.control == false)
                    sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(90f, 0f, 0f)));
                else
                    sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(270f, 0f, 0f)));
                break;
            case KeyCode.Keypad8:
                sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, rotHelper * Quaternion.Euler(new Vector3(15f, 0f, 0f)));
                break;
            case KeyCode.KeypadPeriod:
                if (Selection.transforms.Length == 1)
                    sceneView.LookAtDirect(Selection.activeTransform.position, sceneView.camera.transform.rotation);
                else if (Selection.transforms.Length > 1)
                {
                    Vector3 tempVec = new Vector3();
                    for (int i = 0; i < Selection.transforms.Length; i++)
                    {
                        tempVec += Selection.transforms[i].position;
                    }
                    sceneView.LookAtDirect((tempVec / Selection.transforms.Length), sceneView.camera.transform.rotation);
                }
                break;
            case KeyCode.KeypadMinus:
                SceneView.RepaintAll();
                sceneView.size *= 1.1f;
                break;
            case KeyCode.KeypadPlus:
                SceneView.RepaintAll();
                sceneView.size /= 1.1f;
                break;
        }
    }