Thomas ICHÉ
6 年前
当前提交
9a47eea4
共有 5 个文件被更改,包括 102 次插入 和 4 次删除
-
2Editor/GameViewLink/LinkGameView.cs
-
11Editor/MenuItems.cs
-
24Editor/SceneViewToolbar.cs
-
58Editor/PlayFromHere.cs
-
11Editor/PlayFromHere.cs.meta
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEditor; |
|||
|
|||
namespace GameplayIngredients.Editor |
|||
{ |
|||
public static class PlayFromHere |
|||
{ |
|||
public delegate void PlayFromHereDelegate(Vector3 position, Vector3 forward); |
|||
|
|||
public static event PlayFromHereDelegate OnPlayFromHere; |
|||
|
|||
[InitializeOnLoadMethod] |
|||
public static void Initialize() |
|||
{ |
|||
EditorApplication.playModeStateChanged += OnEnterPlayMode; |
|||
} |
|||
|
|||
|
|||
public static void Play() |
|||
{ |
|||
EditorPrefs.SetBool("playFromHereNext",true); |
|||
EditorApplication.isPlaying = true; |
|||
} |
|||
|
|||
static void OnEnterPlayMode(PlayModeStateChange state) |
|||
{ |
|||
if (state == PlayModeStateChange.EnteredPlayMode && EditorPrefs.GetBool("playFromHereNext")) |
|||
{ |
|||
if (OnPlayFromHere != null) |
|||
{ |
|||
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."); |
|||
|
|||
OnPlayFromHere.Invoke(position,forward); |
|||
|
|||
} |
|||
else |
|||
{ |
|||
Debug.LogWarning("Play From Here : No Actions to take. Please add events to PlayFromHere.OnPlayFromHere()"); |
|||
} |
|||
|
|||
EditorPrefs.SetBool("playFromHereNext", false); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0a474d3e13883394eae0cc77c0c8634e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue