浏览代码

Various Fixes

Fixed Link Game View in PlayFromHere
Fixed Play From Here
Added Play From Here to EditorOnlyLogic
Fixed EditorSceneSetup double click issues
Fixed Toolbar that broke gizmos
/main
Thomas ICHÉ 6 年前
当前提交
0e8f71a0
共有 6 个文件被更改,包括 62 次插入27 次删除
  1. 3
      Editor/EditorSceneSetup/EditorSceneSetup.cs
  2. 4
      Editor/GameViewLink/LinkGameView.cs
  3. 62
      Editor/PlayFromHere.cs
  4. 3
      Editor/SceneViewPOV/SceneViewPOV.cs
  5. 9
      Editor/SceneViewToolbar.cs
  6. 8
      Runtime/Logic/EditorOnlyLogic.cs

3
Editor/EditorSceneSetup/EditorSceneSetup.cs


{
EditorUtility.ClearProgressBar();
}
return true;
return true;
return false;
}

4
Editor/GameViewLink/LinkGameView.cs


m_Active = value;
s_GameObject.SetActive(value);
if(s_GameObject != null)
s_GameObject.SetActive(value);
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
}
}

62
Editor/PlayFromHere.cs


public static event PlayFromHereDelegate OnPlayFromHere;
[InitializeOnLoadMethod]
public static void Initialize()
static void Initialize()
EditorApplication.playModeStateChanged -= OnEnterPlayMode;
EditorApplication.playModeStateChanged += OnEnterPlayMode;
}

return OnPlayFromHere != null && OnPlayFromHere.GetInvocationList().Length > 0;
}
}
public static void Play()
public static void Play(SceneView sceneView)
EditorPrefs.SetBool("playFromHereNext",true);
var forward = sceneView.camera.transform.forward;
var position = sceneView.camera.transform.position;
EditorPrefs.SetInt("PlayFromHere", 1);
EditorPrefs.SetFloat("PlayFromHere.position.x", position.x);
EditorPrefs.SetFloat("PlayFromHere.position.y", position.y);
EditorPrefs.SetFloat("PlayFromHere.position.z", position.z);
EditorPrefs.SetFloat("PlayFromHere.forward.x", forward.x);
EditorPrefs.SetFloat("PlayFromHere.forward.y", forward.y);
EditorPrefs.SetFloat("PlayFromHere.forward.z", forward.z);
if (state == PlayModeStateChange.EnteredPlayMode && EditorPrefs.GetBool("playFromHereNext"))
if(state == PlayModeStateChange.ExitingPlayMode)
{
PlayerPrefs.SetInt("PlayFromHere", 0);
}
if(state == PlayModeStateChange.ExitingEditMode)
if (OnPlayFromHere != null)
if(EditorPrefs.GetInt("PlayFromHere") == 1)
Vector3 position = Vector3.zero;
Vector3 forward = Vector3.forward;
if (SceneView.lastActiveSceneView != null)
{
// Let's choose a point 1m in front of the point of view
var camera = SceneView.lastActiveSceneView.camera;
position = camera.transform.position;
forward = camera.transform.forward;
}
else
Debug.LogWarning("Play From Here : Could not find the position of the last sceneview camera, playing at world's origin.");
PlayerPrefs.SetInt("PlayFromHere", 1);
}
else
{
PlayerPrefs.SetInt("PlayFromHere", 0);
}
}
OnPlayFromHere.Invoke(position,forward);
if (state == PlayModeStateChange.EnteredPlayMode && (PlayerPrefs.GetInt("PlayFromHere") == 1))
{
if (OnPlayFromHere != null)
{
Vector3 position = new Vector3(
EditorPrefs.GetFloat("PlayFromHere.position.x"),
EditorPrefs.GetFloat("PlayFromHere.position.y"),
EditorPrefs.GetFloat("PlayFromHere.position.z"));
Vector3 forward = new Vector3(
EditorPrefs.GetFloat("PlayFromHere.forward.x"),
EditorPrefs.GetFloat("PlayFromHere.forward.y"),
EditorPrefs.GetFloat("PlayFromHere.forward.z"));
OnPlayFromHere.Invoke(position, forward);
}
else
{

EditorPrefs.SetBool("playFromHereNext", false);
EditorPrefs.SetInt("PlayFromHere", 0);
}
}

3
Editor/SceneViewPOV/SceneViewPOV.cs


private static void CheckPOVGameObjects()
{
if (Application.isPlaying)
return;
var activeScene = SceneManager.GetActiveScene();
ScenePOVRoot[] allRoots = GameObject.FindObjectsOfType<ScenePOVRoot>();

9
Editor/SceneViewToolbar.cs


[InitializeOnLoadMethod]
static void Initialize()
{
SceneView.onSceneGUIDelegate += OnSceneGUI;
SceneView.onSceneGUIDelegate += OnSceneGUI;
Handles.BeginGUI();
if(PlayFromHere.IsReady)
{
bool play = GUILayout.Toggle(EditorApplication.isPlaying, Contents.playFromHere, EditorStyles.toolbarButton);

if (play)
PlayFromHere.Play();
PlayFromHere.Play(sceneView);
else
EditorApplication.isPlaying = false;
}

}
}
Handles.EndGUI();
}
static class Contents

8
Runtime/Logic/EditorOnlyLogic.cs


PlayerOnly
}
[Tooltip("Executes in editor whe using Play From Here or not")]
public bool EditorOnPlayHere = false;
public Mode ExecutionPath;
[ReorderableList]

{
switch(ExecutionPath)
{
if (Application.isEditor) Callable.Call(OnExecute);
if (Application.isEditor && EditorOnPlayHere == (PlayerPrefs.GetInt("PlayFromHere") == 1))
Callable.Call(OnExecute);
case Mode.PlayerOnly:
if (!Application.isEditor) Callable.Call(OnExecute);
break;

正在加载...
取消
保存