feat(scripting): add mono csharp runtime foundation
This commit is contained in:
60
managed/GameScripts/BuiltinComponentProbe.cs
Normal file
60
managed/GameScripts/BuiltinComponentProbe.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using XCEngine;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
public sealed class BuiltinComponentProbe : MonoBehaviour
|
||||
{
|
||||
public bool HasCamera;
|
||||
public bool HasLight;
|
||||
public bool CameraLookupSucceeded;
|
||||
public bool LightLookupSucceeded;
|
||||
|
||||
public float ObservedFieldOfView;
|
||||
public float ObservedNearClipPlane;
|
||||
public float ObservedFarClipPlane;
|
||||
public float ObservedDepth;
|
||||
public bool ObservedPrimary;
|
||||
|
||||
public float ObservedIntensity;
|
||||
public float ObservedRange;
|
||||
public float ObservedSpotAngle;
|
||||
public bool ObservedCastsShadows;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
HasCamera = HasComponent<Camera>();
|
||||
HasLight = HasComponent<Light>();
|
||||
|
||||
CameraLookupSucceeded = TryGetComponent(out Camera camera);
|
||||
LightLookupSucceeded = TryGetComponent(out Light light);
|
||||
|
||||
if (camera != null)
|
||||
{
|
||||
ObservedFieldOfView = camera.fieldOfView;
|
||||
ObservedNearClipPlane = camera.nearClipPlane;
|
||||
ObservedFarClipPlane = camera.farClipPlane;
|
||||
ObservedDepth = camera.depth;
|
||||
ObservedPrimary = camera.primary;
|
||||
|
||||
camera.fieldOfView = 75.0f;
|
||||
camera.nearClipPlane = 0.3f;
|
||||
camera.farClipPlane = 500.0f;
|
||||
camera.depth = 3.0f;
|
||||
camera.primary = false;
|
||||
}
|
||||
|
||||
if (light != null)
|
||||
{
|
||||
ObservedIntensity = light.intensity;
|
||||
ObservedRange = light.range;
|
||||
ObservedSpotAngle = light.spotAngle;
|
||||
ObservedCastsShadows = light.castsShadows;
|
||||
|
||||
light.intensity = 2.5f;
|
||||
light.range = 42.0f;
|
||||
light.spotAngle = 55.0f;
|
||||
light.castsShadows = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user