【编辑器】编辑时应用显示初始位置
parent
dc723bdb24
commit
27f8d9e2cf
|
|
@ -91,6 +91,7 @@ public class MapManagerInspector : OdinEditor
|
|||
}
|
||||
|
||||
DeActiveScene();
|
||||
ApplyInitialCameraPosition();
|
||||
}
|
||||
|
||||
private void DeActiveScene()
|
||||
|
|
@ -112,6 +113,29 @@ public class MapManagerInspector : OdinEditor
|
|||
Target.SaveMapData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载地图后应用存储的相机初始位置与FOV
|
||||
/// </summary>
|
||||
private void ApplyInitialCameraPosition()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
return;
|
||||
|
||||
if (Target == null || Target.CameraController == null || Map == null || TGS == null)
|
||||
return;
|
||||
|
||||
var camera = Target.CameraController;
|
||||
camera.CameraBounds = TGS.bounds;
|
||||
var initPos = Map.BlockPosition2WorldPosition(MapData.initialCameraPosition);
|
||||
camera.InitializeCameraPosition(
|
||||
initPos,
|
||||
MapData.cameraMarginInfo,
|
||||
camera.rightMargin,
|
||||
camera.leftMargin,
|
||||
camera.topMargin,
|
||||
camera.bottomMargin);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
|
|
@ -145,8 +169,15 @@ public class MapManagerInspector : OdinEditor
|
|||
|
||||
private void DrawMapData()
|
||||
{
|
||||
Target.MapDataJson =
|
||||
EditorGUILayout.ObjectField("地图配置", Target.MapDataJson, typeof(TextAsset), false) as TextAsset;
|
||||
var mapAsset = Target.MapDataJson;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
mapAsset = EditorGUILayout.ObjectField("地图配置", mapAsset, typeof(TextAsset), false) as TextAsset;
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Target.MapDataJson = mapAsset;
|
||||
ApplyInitialCameraPosition();
|
||||
}
|
||||
|
||||
if (Target.MapDataJson != null)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
|
|
|||
Loading…
Reference in New Issue