浏览代码

Better handling of for Play From Here / Link Game View when switching play mode + enter play from here

/fix-enterplaymode
Thomas ICHÉ 3 年前
当前提交
37660865
共有 2 个文件被更改,包括 39 次插入23 次删除
  1. 12
      Editor/GameViewLink/LinkGameView.cs
  2. 50
      Editor/PlayFromHere.cs

12
Editor/GameViewLink/LinkGameView.cs


if (!Application.isPlaying)
EditorPrefs.SetBool(kCinemachinePreferenceName, value);
UpdateCinemachinePreview(value);
try
{
UpdateCinemachinePreview(value);
}
catch(System.Exception e)
{
Debug.LogException(e);
}
m_CinemachineActive = value;
}

}
brain.enabled = value;
brain.ManualUpdate();
}
}

50
Editor/PlayFromHere.cs


[InitializeOnLoadMethod]
static void Initialize()
{
EditorPrefs.SetInt("PlayFromHere", 0);
EditorApplication.playModeStateChanged -= OnEnterPlayMode;
EditorApplication.playModeStateChanged += OnEnterPlayMode;
}

{
if(state == PlayModeStateChange.ExitingPlayMode)
{
PlayerPrefs.SetInt("PlayFromHere", 0);
EditorPrefs.SetInt("PlayFromHere", 0);
}
if(state == PlayModeStateChange.ExitingEditMode)
{

PlayerPrefs.SetInt("PlayFromHere", 0);
}
}
if (state == PlayModeStateChange.EnteredPlayMode && (PlayerPrefs.GetInt("PlayFromHere") == 1))
try
EditorUtility.ClearProgressBar();
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
if (state == PlayModeStateChange.EnteredPlayMode && (PlayerPrefs.GetInt("PlayFromHere") == 1))
Debug.LogWarning("Play From Here : No Actions to take. Please add events to PlayFromHere.OnPlayFromHere()");
}
EditorUtility.ClearProgressBar();
EditorPrefs.SetInt("PlayFromHere", 0);
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
{
Debug.LogWarning("Play From Here : No Actions to take. Please add events to PlayFromHere.OnPlayFromHere()");
}
EditorPrefs.SetInt("PlayFromHere", 0);
}
catch
{
EditorUtility.ClearProgressBar();
}
}
}
正在加载...
取消
保存