合并代码
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ViewCameraBaking : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 802326651d2bc7442aa201a7859a30e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ViewCameraDesign : ModuleViewCamera {
|
||||
public Camera viewCamera;
|
||||
public Transform viewSpace;
|
||||
private RenderTexture renderTexture;
|
||||
private readonly Vector3 CameraOffset = new Vector3(0, 0, -2);
|
||||
|
||||
protected override void Awake() => ModuleCore.ViewCameraDesign = this;
|
||||
|
||||
public override Vector3 position {
|
||||
get => viewCamera.transform.localPosition - CameraOffset;
|
||||
set => viewCamera.transform.localPosition = value + CameraOffset;
|
||||
}
|
||||
public override Vector3 eulerAngles {
|
||||
get => viewCamera.transform.eulerAngles;
|
||||
set => viewCamera.transform.eulerAngles = value;
|
||||
}
|
||||
public override float scale {
|
||||
get => viewCamera.orthographicSize;
|
||||
set => viewCamera.orthographicSize = value;
|
||||
}
|
||||
public override RenderTexture RenderTexture {
|
||||
get => renderTexture;
|
||||
}
|
||||
|
||||
public override void UpdateRenderTexture(int x, int y) {
|
||||
renderTexture = new RenderTexture(x, y, 0);
|
||||
viewCamera.targetTexture = renderTexture;
|
||||
}
|
||||
public override Vector3 ScreenToViewPosition(Vector3 screenPosition) {
|
||||
float x = screenPosition.x / viewCamera.pixelWidth;
|
||||
float y = 1 - screenPosition.y / viewCamera.pixelHeight;
|
||||
Vector3 mouseRatio = new Vector3(x - 0.5f, y - 0.5f);
|
||||
float aspectRatio = (float)viewCamera.pixelWidth / viewCamera.pixelHeight;
|
||||
return new Vector3(mouseRatio.x * aspectRatio, mouseRatio.y) * 2;
|
||||
}
|
||||
public override Vector3 ScreenToWorldPosition(Vector3 screenPosition) {
|
||||
return ScreenToViewPosition(screenPosition) * scale + position;
|
||||
}
|
||||
public override Vector3 ViewToScreenPosition(Vector3 screenPosition) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public override Vector3 ViewToWorldPosition(Vector3 screenPosition) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public override Vector3 WorldToScreenPosition(Vector3 screenPosition) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public override Vector3 WorldToViewPosition(Vector3 screenPosition) {
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c639043240fd73545af704b1a6b52895
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user