Initial commit: AIGame Unity client with URP, HybridCLR, YooAsset and tooling.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
udx
2026-09-21 14:21:07 +08:00
co-authored by Cursor
commit f3f66ab063
931 changed files with 112366 additions and 0 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7a0ab883fda51549426c60701bd05576
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4f40406811f5efe4eb95440aebf17388
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,447 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 10
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 13
m_BakeOnSceneLoad: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 2
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 1
m_PVRFilteringGaussRadiusAO: 1
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &701989028
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 701989030}
- component: {fileID: 701989029}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &701989029
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 701989028}
m_Enabled: 1
serializedVersion: 13
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize2D: {x: 0.5, y: 0.5}
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ForceVisible: 0
m_ShapeRadius: 0.025
m_ShadowAngle: 0
m_LightUnit: 1
m_LuxAtDistance: 1
m_EnableSpotReflector: 1
--- !u!4 &701989030
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 701989028}
serializedVersion: 2
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &890368703
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 890368707}
- component: {fileID: 890368706}
- component: {fileID: 890368705}
- component: {fileID: 890368704}
- component: {fileID: 890368708}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!65 &890368704
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 890368703}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &890368705
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 890368703}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_MaskInteraction: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &890368706
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 890368703}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &890368707
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 890368703}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.5, y: 0.35, z: 0.5}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &890368708
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 890368703}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f2e2dbbd2e928074d83ba49a57cb9cfa, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Pipeline.Samples::Unity.Pipeline.Samples.CodeReload.InPlaceCodeReloadExample
rotationSpeed: 90
enableRotation: 1
rotationAxis: {x: 0, y: 1, z: 0}
moveSpeed: 2
enableMovement: 1
--- !u!1 &1185268903
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1185268906}
- component: {fileID: 1185268905}
- component: {fileID: 1185268904}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1185268904
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1185268903}
m_Enabled: 1
--- !u!20 &1185268905
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1185268903}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1185268906
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1185268903}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 1185268906}
- {fileID: 701989030}
- {fileID: 890368707}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1a4fb3f52f24e174d9e515c8b77ceb71
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,83 @@
using UnityEngine;
using Unity.Pipeline.CodeReload;
namespace Unity.Pipeline.Samples.CodeReload
{
/// <summary>
/// Example demonstrating in-place code reload editing workflow.
///
/// Usage:
/// 1. Add this component to a GameObject in the scene
/// 2. Play the scene - you'll see the object rotating
/// 3. Modify the Update() method below (try changing Vector3.up to Vector3.forward)
/// 4. Run: reload_file Assets/Samples/CodeReload_InPlace/InPlaceCodeReloadExample.cs
/// 5. See the changes take effect immediately without stopping play mode!
///
/// Requirements:
/// - Only use PUBLIC fields, properties, and methods
/// - Private/internal members will cause validation errors
/// </summary>
public class InPlaceCodeReloadExample : MonoBehaviour
{
[Header("Code Reload Configuration")]
public float rotationSpeed = 90f;
public bool enableRotation = true;
public Vector3 rotationAxis = Vector3.up;
[Header("Movement Configuration")]
public float moveSpeed = 2f;
public bool enableMovement = false;
[CodeReload]
void Update()
{
// Edit this body live, then run: reload_file <this file>
// Try changing rotationAxis (e.g. Vector3.up -> Vector3.forward) or the speed.
if (enableRotation)
{
transform.Rotate(rotationAxis, rotationSpeed * Time.deltaTime);
}
if (enableMovement)
{
var movement = Mathf.Sin(Time.time) * moveSpeed;
transform.position = new Vector3(movement, transform.position.y, transform.position.z);
}
}
[CodeReload]
public void ResetTransform()
{
// Another method you can code reload
transform.position = Vector3.zero;
transform.rotation = Quaternion.identity;
Debug.Log("Transform reset via code reload!");
}
// Note: value-returning methods are not yet supported by in-place reload (void methods only),
// so this one is a normal method.
public float CalculateDistance(Vector3 targetPosition)
{
return Vector3.Distance(transform.position, targetPosition);
}
void Awake()
{
// Run the sample in a 640x480 window instead of fullscreen.
Screen.SetResolution(640, 480, FullScreenMode.Windowed);
}
// Regular methods (not reloadable) - these work normally
void Start()
{
Debug.Log($"InPlaceCodeReloadExample started. Try code reloading the Update method!");
Debug.Log($"Command: reload_file {GetType().Name}.cs");
}
public void TriggerResetFromUI()
{
// This calls the reloadable method
ResetTransform();
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f2e2dbbd2e928074d83ba49a57cb9cfa
@@ -0,0 +1,437 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 10
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 13
m_BakeOnSceneLoad: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 2
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 2
m_PVRDenoiserTypeIndirect: 2
m_PVRDenoiserTypeAO: 2
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 1
m_PVRFilteringGaussRadiusAO: 1
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &201913770
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 201913773}
- component: {fileID: 201913772}
- component: {fileID: 201913771}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &201913771
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 201913770}
m_Enabled: 1
--- !u!20 &201913772
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 201913770}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &201913773
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 201913770}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &453203916
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 453203918}
- component: {fileID: 453203917}
m_Layer: 0
m_Name: Pong
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &453203917
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 453203916}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8ba7fa42014981348997afa11a492f9c, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::PongScript
leftPaddle: {fileID: 0}
rightPaddle: {fileID: 0}
ball: {fileID: 0}
leftScoreGO: {fileID: 0}
rightScoreGO: {fileID: 0}
arenaGO: {fileID: 0}
arena: {fileID: 0}
leftScoreText: {fileID: 0}
rightScoreText: {fileID: 0}
mat: {fileID: 0}
ballRenderer: {fileID: 0}
leftPaddleAngle: 180
rightPaddleAngle: 0
ballVelocity: {x: 0, y: 0, z: 0}
ballIsLeftPaddleColor: 0
leftLives: 3
rightLives: 3
gameOver: 0
ballSpeed: 5
circleRadius: 6
paddleAngularSpeed: 180
gravity: 3
updateTicks: 0
marker: none
--- !u!4 &453203918
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 453203916}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1639109660
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1639109662}
- component: {fileID: 1639109661}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1639109661
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1639109660}
m_Enabled: 1
serializedVersion: 12
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize2D: {x: 0.5, y: 0.5}
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ForceVisible: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
m_LightUnit: 1
m_LuxAtDistance: 1
m_EnableSpotReflector: 1
--- !u!4 &1639109662
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1639109660}
serializedVersion: 2
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1769366718
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1769366720}
- component: {fileID: 1769366719}
m_Layer: 0
m_Name: PipelineManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1769366719
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1769366718}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dd4ab1c9091e0194196b5f5d51cb932f, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Pipeline::Unity.Pipeline.RuntimePipelineManager
enableInBuilds: 0
port: 0
requestTimeoutMs: 30000
enableAuditLogging: 1
autoStart: 1
maxWorkItemsPerFrame: 10
m_AllowedReloadRoots: []
--- !u!4 &1769366720
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1769366718}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 201913773}
- {fileID: 1639109662}
- {fileID: 453203918}
- {fileID: 1769366720}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: aade730046d453349bd366dcebbce674
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,42 @@
# Code Reload - Minics
Demonstrates code reloading with the minics vm. This allows code reloading cs
scripts on all platforms (even on il2cpp players) with the constraint the the
script must only contain a subset of csharp.
## What's in this sample
| File | Purpose |
|------|---------|
| `pong.cs` | `PongScript`, a self-playing Pong game that can be reloaded. |
| `SampleScene.unity` | Scene with a GameObject carrying `PongScript`. |
`PongScript` is a self-playing arena Pong: two paddles orbit a circle and rally a
ball that switches colour on each hit.
## Try it
1. Import this sample and add `PongScene` to the built scene list.
2. Enable **developement build** and **autoconnect profiler** in the build settings (minics uses the profiler connection to reload the scripts.)
2. You may also want to enable run in background in the player settings if you are building for web.
3. Build and run the player. The paddles start rallying the ball automatically, and the profiler begins collecting data.
3. Make a change to pong.cs and push it with `unity command reload_file_player_interpreter "Assets/Samples/Unity Pipeline/0.2.0-exp.2/Code Reload Examples/CodeReload_Minics/pong.cs"` to see the reload live. (For automatic re-push on every save, use the Code Reload Interpreter Watch section of the Pipeline Settings inspector.)
## How the code reload works
- **`[CodeReload]` on the class** opts every eligible method (`Start`, `Update`,
`PlacePaddle`, `OnDisable`, …) into in-place reload. Editing any of them takes effect on the next `reload_file`.
- **`[OnCodeReload]` on `OnReloaded()`** runs once after each reload, on every
live instance. Here it tears down and rebuilds the scene (`OnDisable()` + `Start()`)
so edits to setup code apply immediately.
- **Verification markers** `updateTicks` and `marker` are public fields you can read
back over eval to confirm the freshly reloaded `Update` body is actually running.
Because in-place reloaded bodies may only touch **public** members of the target type,
every field and helper on `PongScript` is public.
## Minics
Minics is a subset of all C# features. This means that not all scripts will be able to
be reloaded. Consult the package documentation for more information on which
features are supported.
@@ -0,0 +1,248 @@
using UnityEngine;
using Unity.Pipeline.CodeReload;
// Pong sample for com.unity.pipeline in-place code reload:
// - Self-playing AI instead of the Input System (project has no com.unity.inputsystem).
// - Material created in code (project has no Resources/DefaultMaterial; built-in RP).
// - All members public: in-place [CodeReload] method bodies may only touch public members.
// - [CodeReload] on each editable method (Start/Update/PlacePaddle/OnDisable), so editing a helper
// like PlacePaddle takes effect too. `reload_file Assets/pong.cs`.
public class PongScript : MonoBehaviour
{
public GameObject leftPaddle, rightPaddle, ball;
public GameObject leftScoreGO, rightScoreGO, arenaGO;
public LineRenderer arena;
public TextMesh leftScoreText, rightScoreText;
public Material mat;
public Renderer ballRenderer;
public float leftPaddleAngle = 180f;
public float rightPaddleAngle = 0f;
public Vector3 ballVelocity;
public bool ballIsLeftPaddleColor = false;
public int leftLives = 3;
public int rightLives = 3;
public bool gameOver = false;
public float ballSpeed = 5f;
public float circleRadius = 2f;
public float paddleAngularSpeed = 180f;
public float gravity = 3f;
// Code-reload verification markers (read back via eval to confirm the live body ran).
public int updateTicks = 0;
public string marker = "none";
private Color leftColor ;
private Color rightColor;
[OnCodeReload]
public void OnReloaded()
{
Debug.Log($"Pong CodeReloaded");
OnDisable();
Start();
}
[CodeReload]
public void Start()
{
leftColor = new Color(0.678f, 1f, 0.184f); // green-yellow (Color.greenYellow needs 6000.2+)
rightColor = Color.magenta;
mat = new Material(Shader.Find("Sprites/Default"));
Camera cam = Camera.main;
cam.orthographic = true;
cam.orthographicSize = 12.5f;
cam.clearFlags = CameraClearFlags.SolidColor;
cam.backgroundColor = Color.grey;
cam.transform.position = new Vector3(0.0f, 0.0f, -10.0f);
leftScoreGO = new GameObject("LeftScore");
leftScoreGO.transform.position = new Vector3(-6f, 6f, 0f);
leftScoreText = leftScoreGO.AddComponent<TextMesh>();
leftScoreText.anchor = TextAnchor.MiddleCenter;
leftScoreText.alignment = TextAlignment.Center;
leftScoreText.text = "Cyan: " + leftLives.ToString();
leftScoreText.characterSize = 0.5f;
leftScoreText.color = leftColor;
rightScoreGO = new GameObject("RightScore");
rightScoreGO.transform.position = new Vector3(6f, 6f, 0f);
rightScoreText = rightScoreGO.AddComponent<TextMesh>();
rightScoreText.anchor = TextAnchor.MiddleCenter;
rightScoreText.alignment = TextAlignment.Center;
rightScoreText.text = "Magenta: " + rightLives.ToString();
rightScoreText.characterSize = 0.5f;
rightScoreText.color = rightColor;
arenaGO = new GameObject("CircleIndicator");
arenaGO.transform.position = new Vector3(0f, 0f, 0.5f);
arena = arenaGO.AddComponent<LineRenderer>();
arena.useWorldSpace = false;
arena.loop = true;
arena.startWidth = 0.1f;
arena.endWidth = 0.1f;
arena.material = mat;
arena.material.color = new Color(0.15f, 0.15f, 0.15f, 1f);
arena.positionCount = 64;
int i = 0;
while (i < 64)
{
float a = i * Mathf.PI * 2f / 64f;
arena.SetPosition(i, new Vector3(Mathf.Cos(a) * circleRadius, Mathf.Sin(a) * circleRadius, 0f));
i = i + 1;
}
leftPaddle = GameObject.CreatePrimitive(PrimitiveType.Quad);
leftPaddle.transform.localScale = new Vector3(0.3f, 1.5f, 1f);
Renderer lr = leftPaddle.GetComponent<Renderer>();
lr.material = mat;
lr.material.color = leftColor;
rightPaddle = GameObject.CreatePrimitive(PrimitiveType.Quad);
rightPaddle.transform.localScale = new Vector3(0.3f, 1.5f, 1f);
Renderer rr = rightPaddle.GetComponent<Renderer>();
rr.material = mat;
rr.material.color = rightColor;
PlacePaddle(leftPaddle, leftPaddleAngle);
PlacePaddle(rightPaddle, rightPaddleAngle);
ball = GameObject.CreatePrimitive(PrimitiveType.Sphere);
ball.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);
ballRenderer = ball.GetComponent<Renderer>();
ballRenderer.material = mat;
ballRenderer.material.color = rightColor;
ballVelocity = new Vector3(ballSpeed, ballSpeed * 0.5f, 0f);
}
[CodeReload]
public void PlacePaddle(GameObject paddle, float angleDeg)
{
float rad = angleDeg * Mathf.Deg2Rad;
paddle.transform.localScale = new Vector3(.5f,2,1);
paddle.transform.position = new Vector3(Mathf.Cos(rad) * circleRadius, Mathf.Sin(rad) * circleRadius, 0f);
paddle.transform.rotation = Quaternion.Euler(0f, 0f, angleDeg);
}
[CodeReload]
public void Update()
{
updateTicks++;
marker = "live";
if (gameOver)
{
this.OnDisable();
gameOver = false;
this.Start();
return;
}
float dt = Time.deltaTime;
// Self-playing AI: each paddle tracks the ball while the ball wears its colour.
float ballAng = Mathf.Atan2(ball.transform.position.y, ball.transform.position.x) * Mathf.Rad2Deg;
if (ballIsLeftPaddleColor)
{
float diff = Mathf.DeltaAngle(leftPaddleAngle, ballAng);
if (diff > 5f) leftPaddleAngle += paddleAngularSpeed * dt;
if (diff < -5f) leftPaddleAngle -= paddleAngularSpeed * dt;
}
else
{
float diff = Mathf.DeltaAngle(rightPaddleAngle, ballAng);
if (diff > 5f) rightPaddleAngle += paddleAngularSpeed * dt;
if (diff < -5f) rightPaddleAngle -= paddleAngularSpeed * dt;
}
PlacePaddle(leftPaddle, leftPaddleAngle);
PlacePaddle(rightPaddle, rightPaddleAngle);
ballVelocity = ballVelocity + Vector3.down * gravity * dt * 1.2f;
ball.transform.position = ball.transform.position + ballVelocity * dt ;
Vector3 bPos = ball.transform.position;
float bDist = bPos.magnitude;
float bAng = Mathf.Atan2(bPos.y, bPos.x) * Mathf.Rad2Deg;
if (bDist > circleRadius - 0.3f && bDist < circleRadius + 0.2f)
{
Vector3 normal = bPos.normalized;
if (Vector3.Dot(ballVelocity, normal) > 0f)
{
if (ballIsLeftPaddleColor)
{
float diff = Mathf.DeltaAngle(bAng, leftPaddleAngle);
if (diff > -12f && diff < 12f)
{
ballVelocity = Vector3.Reflect(ballVelocity, -normal);
ball.transform.position = ball.transform.position - normal * 0.1f;
ballIsLeftPaddleColor = false;
ballRenderer.material.color = rightColor;
}
}
else
{
float diff = Mathf.DeltaAngle(bAng, rightPaddleAngle);
if (diff > -12f && diff < 12f)
{
ballVelocity = Vector3.Reflect(ballVelocity, -normal);
ball.transform.position = ball.transform.position - normal * 0.1f;
ballIsLeftPaddleColor = true;
ballRenderer.material.color = leftColor;
}
}
}
}
if (bDist > 8f)
{
if (ballIsLeftPaddleColor)
{
leftLives -= 1;
leftScoreText.text = "Cyan: " + leftLives.ToString();
}
else
{
rightLives -= 1;
rightScoreText.text = "Magenta: " + rightLives.ToString();
}
if (leftLives <= 0 || rightLives <= 0)
{
gameOver = true;
}
else
{
ball.transform.position = new Vector3(0f, 0f, 0f);
ballVelocity = new Vector3(ballSpeed, ballSpeed * 0.5f, 0f);
ballIsLeftPaddleColor = rightLives < leftLives;
if (ballIsLeftPaddleColor)
{
ballRenderer.material.color = leftColor;
}
else
{
ballRenderer.material.color = rightColor;
}
}
}
}
[CodeReload]
public void OnDisable()
{
if (leftPaddle) GameObject.Destroy(leftPaddle);
if (rightPaddle) GameObject.Destroy(rightPaddle);
if (ball) GameObject.Destroy(ball);
if (leftScoreGO) GameObject.Destroy(leftScoreGO);
if (rightScoreGO) GameObject.Destroy(rightScoreGO);
if (arenaGO) GameObject.Destroy(arenaGO);
Camera.main.orthographicSize = 5.0f;
Camera.main.clearFlags = CameraClearFlags.Skybox;
Camera.main.orthographic = false;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8ba7fa42014981348997afa11a492f9c
@@ -0,0 +1,17 @@
{
"name": "Unity.Pipeline.Samples",
"rootNamespace": "Unity.Pipeline.Samples.CodeReload",
"references": [
"Unity.Pipeline",
"Unity.Pipeline.Attributes"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fadfe42d23f96db47a2c41e046892acb
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: