|
|
|
|
@@ -17,43 +17,92 @@ namespace Demo.Game
|
|
|
|
|
{
|
|
|
|
|
public class CameraObjectConfig : ScriptLoadableConfig
|
|
|
|
|
{
|
|
|
|
|
public bool IsSetupOrthographic = false;
|
|
|
|
|
public bool orthographic;
|
|
|
|
|
public bool IsSetupFieldOfView = false;
|
|
|
|
|
public float fieldOfView;
|
|
|
|
|
public bool IsSetupOrthographicSize = false;
|
|
|
|
|
public float orthographicSize;
|
|
|
|
|
public bool IsSetupNearClipPlane = false;
|
|
|
|
|
public float nearClipPlane;
|
|
|
|
|
public bool IsSetupFarClipPlane = false;
|
|
|
|
|
public float farClipPlane;
|
|
|
|
|
public bool IsSetupDepth = false;
|
|
|
|
|
public float depth;
|
|
|
|
|
public bool IsSetupVirtualCameraFollow = false;
|
|
|
|
|
public int VirtualCameraFollow;
|
|
|
|
|
public bool IsSetupVirtualCameraLookAt = false;
|
|
|
|
|
public int VirtualCameraLookAt;
|
|
|
|
|
public bool IsSetupVirtualCameraFollowOffset = false;
|
|
|
|
|
public Vector3 VirtualCameraFollowOffset;
|
|
|
|
|
public bool IsSetupVirtualCameraLookAtDamping = false;
|
|
|
|
|
public Vector3 VirtualCameraLookAtDamping;
|
|
|
|
|
|
|
|
|
|
public override void Deserialize(BinaryReader reader)
|
|
|
|
|
{
|
|
|
|
|
IsSetupOrthographic =BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
orthographic = BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
|
|
|
|
|
IsSetupFieldOfView = BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
fieldOfView = BinarySerializeUtility.ReadFloat(reader);
|
|
|
|
|
|
|
|
|
|
IsSetupOrthographicSize = BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
orthographicSize = BinarySerializeUtility.ReadFloat(reader);
|
|
|
|
|
|
|
|
|
|
IsSetupNearClipPlane = BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
nearClipPlane = BinarySerializeUtility.ReadFloat(reader);
|
|
|
|
|
|
|
|
|
|
IsSetupFarClipPlane = BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
farClipPlane = BinarySerializeUtility.ReadFloat(reader);
|
|
|
|
|
|
|
|
|
|
IsSetupDepth = BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
depth = BinarySerializeUtility.ReadFloat(reader);
|
|
|
|
|
|
|
|
|
|
IsSetupVirtualCameraFollow = BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
VirtualCameraFollow = BinarySerializeUtility.ReadInt(reader);
|
|
|
|
|
|
|
|
|
|
IsSetupVirtualCameraLookAt = BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
VirtualCameraLookAt = BinarySerializeUtility.ReadInt(reader);
|
|
|
|
|
|
|
|
|
|
IsSetupVirtualCameraFollowOffset = BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
VirtualCameraFollowOffset = BinarySerializeUtility.ReadVec3(reader);
|
|
|
|
|
|
|
|
|
|
IsSetupVirtualCameraLookAtDamping = BinarySerializeUtility.ReadBool(reader);
|
|
|
|
|
VirtualCameraLookAtDamping = BinarySerializeUtility.ReadVec3(reader);
|
|
|
|
|
|
|
|
|
|
base.Deserialize(reader);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Serialize(BinaryWriter writer)
|
|
|
|
|
{
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, IsSetupOrthographic);
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, orthographic);
|
|
|
|
|
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, IsSetupFieldOfView);
|
|
|
|
|
BinarySerializeUtility.WriteFloat(writer, fieldOfView);
|
|
|
|
|
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, IsSetupOrthographicSize);
|
|
|
|
|
BinarySerializeUtility.WriteFloat(writer, orthographicSize);
|
|
|
|
|
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, IsSetupNearClipPlane);
|
|
|
|
|
BinarySerializeUtility.WriteFloat(writer, nearClipPlane);
|
|
|
|
|
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, IsSetupFarClipPlane);
|
|
|
|
|
BinarySerializeUtility.WriteFloat(writer, farClipPlane);
|
|
|
|
|
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, IsSetupDepth);
|
|
|
|
|
BinarySerializeUtility.WriteFloat(writer, depth);
|
|
|
|
|
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, IsSetupVirtualCameraFollow);
|
|
|
|
|
BinarySerializeUtility.WriteInt(writer, VirtualCameraFollow);
|
|
|
|
|
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, IsSetupVirtualCameraLookAt);
|
|
|
|
|
BinarySerializeUtility.WriteInt(writer,VirtualCameraLookAt);
|
|
|
|
|
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, IsSetupVirtualCameraFollowOffset);
|
|
|
|
|
BinarySerializeUtility.WriteVec3(writer, VirtualCameraFollowOffset);
|
|
|
|
|
|
|
|
|
|
BinarySerializeUtility.WriteBool(writer, IsSetupVirtualCameraLookAtDamping);
|
|
|
|
|
BinarySerializeUtility.WriteVec3(writer, VirtualCameraLookAtDamping);
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
}
|
|
|
|
|
@@ -67,7 +116,7 @@ namespace Demo.Game
|
|
|
|
|
{
|
|
|
|
|
return new CameraObjectConfig();
|
|
|
|
|
}
|
|
|
|
|
private Camera MainCamera => Camera.main;
|
|
|
|
|
internal Camera MainCamera => Camera.main;
|
|
|
|
|
private CinemachineCamera m_VirtualCamera;
|
|
|
|
|
private CinemachineCamera VirtualCamera
|
|
|
|
|
{
|
|
|
|
|
@@ -105,6 +154,7 @@ namespace Demo.Game
|
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
|
|
|
public void SetOrthographic(bool orthographic)
|
|
|
|
|
{
|
|
|
|
|
GetConfig<CameraObjectConfig>().IsSetupOrthographic = true;
|
|
|
|
|
GetConfig<CameraObjectConfig>().orthographic = MainCamera.orthographic = orthographic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -114,6 +164,7 @@ namespace Demo.Game
|
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
|
|
|
public void SetFieldOfView(float fieldOfView)
|
|
|
|
|
{
|
|
|
|
|
GetConfig<CameraObjectConfig>().IsSetupFieldOfView = true;
|
|
|
|
|
GetConfig<CameraObjectConfig>().fieldOfView = MainCamera.fieldOfView = fieldOfView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -123,6 +174,7 @@ namespace Demo.Game
|
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
|
|
|
public void SetOrthographicSize(float orthographicSize)
|
|
|
|
|
{
|
|
|
|
|
GetConfig<CameraObjectConfig>().IsSetupOrthographicSize = true;
|
|
|
|
|
GetConfig<CameraObjectConfig>().orthographicSize = MainCamera.orthographicSize = orthographicSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -132,6 +184,7 @@ namespace Demo.Game
|
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
|
|
|
public void SetNearClipPlane(float nearClipPlane)
|
|
|
|
|
{
|
|
|
|
|
GetConfig<CameraObjectConfig>().IsSetupNearClipPlane = true;
|
|
|
|
|
GetConfig<CameraObjectConfig>().nearClipPlane = MainCamera.nearClipPlane = nearClipPlane;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -141,6 +194,7 @@ namespace Demo.Game
|
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
|
|
|
public void SetFarClipPlane(float farClipPlane)
|
|
|
|
|
{
|
|
|
|
|
GetConfig<CameraObjectConfig>().IsSetupFarClipPlane = true;
|
|
|
|
|
GetConfig<CameraObjectConfig>().farClipPlane = MainCamera.farClipPlane = farClipPlane;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -150,6 +204,7 @@ namespace Demo.Game
|
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
|
|
|
public void SetDepth(float depth)
|
|
|
|
|
{
|
|
|
|
|
GetConfig<CameraObjectConfig>().IsSetupDepth = true;
|
|
|
|
|
GetConfig<CameraObjectConfig>().depth = MainCamera.depth = depth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -159,6 +214,7 @@ namespace Demo.Game
|
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
|
|
|
public void SetVirtualCameraFollow(ScriptableObject target)
|
|
|
|
|
{
|
|
|
|
|
GetConfig<CameraObjectConfig>().IsSetupVirtualCameraFollow = true;
|
|
|
|
|
GetConfig<CameraObjectConfig>().VirtualCameraFollow = GetRoot().FindIndex(target);
|
|
|
|
|
VirtualCamera.Follow = target.transform;
|
|
|
|
|
}
|
|
|
|
|
@@ -169,6 +225,7 @@ namespace Demo.Game
|
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
|
|
|
public void SetVirtualCameraLookAt(ScriptableObject target)
|
|
|
|
|
{
|
|
|
|
|
GetConfig<CameraObjectConfig>().IsSetupVirtualCameraLookAt = true;
|
|
|
|
|
GetConfig<CameraObjectConfig>().VirtualCameraLookAt = GetRoot().FindIndex(target);
|
|
|
|
|
VirtualCamera.LookAt = target.transform;
|
|
|
|
|
}
|
|
|
|
|
@@ -185,6 +242,7 @@ namespace Demo.Game
|
|
|
|
|
var body = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineFollow;
|
|
|
|
|
if (body != null)
|
|
|
|
|
{
|
|
|
|
|
GetConfig<CameraObjectConfig>().IsSetupVirtualCameraFollowOffset = true;
|
|
|
|
|
GetConfig<CameraObjectConfig>().VirtualCameraFollowOffset = new Vector3(x, y, z);
|
|
|
|
|
body.FollowOffset = new Vector3(x, y, z);
|
|
|
|
|
}
|
|
|
|
|
@@ -202,6 +260,7 @@ namespace Demo.Game
|
|
|
|
|
var aim = VirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body) as CinemachineRotationComposer;
|
|
|
|
|
if (aim != null)
|
|
|
|
|
{
|
|
|
|
|
GetConfig<CameraObjectConfig>().IsSetupVirtualCameraLookAtDamping = true;
|
|
|
|
|
GetConfig<CameraObjectConfig>().VirtualCameraLookAtDamping = new Vector3(x, y, z);
|
|
|
|
|
aim.Damping = new(x, y);
|
|
|
|
|
}
|
|
|
|
|
|