├── unityrust_native ├── src │ ├── bindings │ │ ├── mod.rs │ │ ├── delegates.rs │ │ ├── debug.rs │ │ ├── gameobject.rs │ │ └── nativearray.rs │ ├── lib.rs │ ├── unity_mesh_updater.rs │ └── rust_object.rs └── Cargo.toml ├── UnityRust ├── Assets │ ├── libunity_rust.dylib │ ├── BindingTest.unity.meta │ ├── RustNative.meta │ ├── RustNative │ │ ├── RustNative.asmdef.meta │ │ ├── RustObject.cs.meta │ │ ├── UnityBindings.cs.meta │ │ ├── RustNative.asmdef │ │ ├── RustObject.cs │ │ └── UnityBindings.cs │ ├── BindingTest.cs.meta │ ├── RustMeshModifier.cs.meta │ ├── libunity_rust.dylib.meta │ ├── BindingTest.cs │ ├── RustMeshModifier.cs │ └── BindingTest.unity ├── ProjectSettings │ ├── ProjectVersion.txt │ ├── ClusterInputManager.asset │ ├── PresetManager.asset │ ├── EditorBuildSettings.asset │ ├── XRSettings.asset │ ├── VersionControlSettings.asset │ ├── TimeManager.asset │ ├── VFXManager.asset │ ├── AutoStreamingSettings.asset │ ├── AudioManager.asset │ ├── TagManager.asset │ ├── UnityConnectSettings.asset │ ├── PackageManagerSettings.asset │ ├── EditorSettings.asset │ ├── DynamicsManager.asset │ ├── NavMeshAreas.asset │ ├── Physics2DSettings.asset │ ├── GraphicsSettings.asset │ ├── SceneTemplateSettings.json │ ├── InputManager.asset │ ├── QualitySettings.asset │ └── ProjectSettings.asset ├── UserSettings │ └── EditorUserSettings.asset └── Packages │ ├── manifest.json │ └── packages-lock.json ├── .gitignore └── README.md /unityrust_native/src/bindings/mod.rs: -------------------------------------------------------------------------------- 1 | 2 | mod delegates; 3 | pub mod debug; 4 | pub mod gameobject; 5 | pub mod nativearray; -------------------------------------------------------------------------------- /UnityRust/Assets/libunity_rust.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wlgys8/UnityRustInteractTest/HEAD/UnityRust/Assets/libunity_rust.dylib -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2020.3.17f1c1 2 | m_EditorVersionWithRevision: 2020.3.17f1c1 (1f35b2393d76) 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.csproj 3 | Temp 4 | Library 5 | .vscode 6 | Logs 7 | obj 8 | *.sln 9 | /unityrust_native/target 10 | Cargo.lock 11 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /UnityRust/Assets/BindingTest.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a4c0b3f9141a4ed7aefa24d99cec2da 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /UnityRust/Assets/RustNative.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa2fee3f7f2f34cc883e153a398ad266 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /UnityRust/Assets/RustNative/RustNative.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61a655854c8b3441fb55c3c5aa1e965f 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /unityrust_native/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unityrust" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | [lib] 7 | name = "unity_rust" 8 | crate-type = ["cdylib"] 9 | 10 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 11 | 12 | [dependencies] 13 | -------------------------------------------------------------------------------- /UnityRust/Assets/BindingTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2312498f95f494ef28e327ed8fddf32d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UnityRust/Assets/RustMeshModifier.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d94d630b9fff04cc29eba0d97c012015 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /unityrust_native/src/bindings/delegates.rs: -------------------------------------------------------------------------------- 1 | use std::os::raw::c_char; 2 | pub type UnityDVoidString = unsafe extern "C" fn(data: *const c_char); 3 | pub type UnityDU32= unsafe extern "C" fn()->u32; 4 | pub type UnityDVoidU32 = unsafe extern "C" fn(data:u32); 5 | pub type UnityDVoidU32Bool = unsafe extern "C" fn(id:u32,value:bool); 6 | 7 | -------------------------------------------------------------------------------- /UnityRust/Assets/RustNative/RustObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c412710977a97461094d7c5f7225378c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UnityRust/Assets/RustNative/UnityBindings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cdd19e06127a447b4942c10b28d203f5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /unityrust_native/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod bindings; 2 | mod rust_object; 3 | mod unity_mesh_updater; 4 | use bindings::{gameobject::GameObject}; 5 | 6 | #[no_mangle] 7 | pub extern fn test_run_method(val:i32)->i32{ 8 | crate::bindings::debug::log("hello, i am from rust"); 9 | let mut go = GameObject::new(); 10 | go.set_active(false); 11 | return val + 1; 12 | } 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /UnityRust/Assets/RustNative/RustNative.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RustNative", 3 | "rootNamespace": "", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": true, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [], 13 | "noEngineReferences": false 14 | } -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/AutoStreamingSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1200 &1 4 | AutoStreamingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | mSearchMode: 7 8 | mCustomSearchFile: 9 | mTextures: [] 10 | mAudios: [] 11 | mMeshes: [] 12 | mScenes: [] 13 | mConfigCCD: 14 | useCCD: 0 15 | cosKey: 16 | projectGuid: 17 | bucketUuid: 18 | bucketName: 19 | badgeName: 20 | -------------------------------------------------------------------------------- /unityrust_native/src/bindings/debug.rs: -------------------------------------------------------------------------------- 1 | 2 | use std::ffi::CString; 3 | use super::delegates::*; 4 | 5 | static mut _LOG: Option = None; 6 | 7 | pub fn log(data:&str){ 8 | let c_str = CString::new(data).unwrap(); 9 | unsafe{ 10 | _LOG.expect("have not binded")(c_str.as_ptr()); 11 | } 12 | } 13 | 14 | ///在外部语言调用进行绑定 15 | #[no_mangle] 16 | extern fn bind_unityengine_debug_log(func:UnityDVoidString){ 17 | unsafe{ 18 | _LOG = Some(func); 19 | } 20 | } -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /unityrust_native/src/unity_mesh_updater.rs: -------------------------------------------------------------------------------- 1 | use std::ffi::c_void; 2 | use crate::bindings::nativearray::NativeArray; 3 | 4 | 5 | #[repr(C)] 6 | struct Vertex{ 7 | position:[f32;3], 8 | normal:[f32;3] 9 | } 10 | 11 | const PI:f32 = 3.1415926; 12 | 13 | #[no_mangle] 14 | extern fn rust_dynamic_update_mesh(vertex_buffer_ptr: *mut c_void,vertex_count:u32,time:f32){ 15 | let mut vertex_buffer = NativeArray::new(vertex_buffer_ptr as * mut Vertex, vertex_count as isize); 16 | for i in 0..vertex_count{ 17 | let pos = &mut vertex_buffer[i as isize].position; 18 | pos[0] = (time + PI * 0.5 * i as f32) .cos(); 19 | pos[1] = (time + PI * 0.5 * i as f32) .sin(); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /UnityRust/Assets/libunity_rust.dylib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43a72c21db64846d78629ca6b34b5f12 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 0 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 1 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | Standalone: OSXUniversal 27 | second: 28 | enabled: 1 29 | settings: 30 | CPU: AnyCPU 31 | userData: 32 | assetBundleName: 33 | assetBundleVariant: 34 | -------------------------------------------------------------------------------- /UnityRust/UserSettings/EditorUserSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!162 &1 4 | EditorUserSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_ConfigSettings: 8 | RecentlyUsedScenePath-0: 9 | value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d 10 | flags: 0 11 | RecentlyUsedScenePath-1: 12 | value: 22424703114646790400082b1e246b150503563f22213229 13 | flags: 0 14 | vcSharedLogLevel: 15 | value: 0d5e400f0650 16 | flags: 0 17 | m_VCAutomaticAdd: 1 18 | m_VCDebugCom: 0 19 | m_VCDebugCmd: 0 20 | m_VCDebugOut: 0 21 | m_SemanticMergeMode: 2 22 | m_VCShowFailedCheckout: 1 23 | m_VCOverwriteFailedCheckoutAssets: 1 24 | m_VCProjectOverlayIcons: 1 25 | m_VCHierarchyOverlayIcons: 1 26 | m_VCOtherOverlayIcons: 1 27 | m_VCAllowAsyncUpdate: 0 28 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity.cn 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /unityrust_native/src/rust_object.rs: -------------------------------------------------------------------------------- 1 | use crate::bindings; 2 | 3 | 4 | #[derive(Debug)] 5 | #[repr(C)] 6 | pub struct RustObject{ 7 | pub val:f32 8 | } 9 | 10 | impl Drop for RustObject { 11 | fn drop(&mut self) { 12 | bindings::debug::log("rust object dropped!"); 13 | } 14 | } 15 | 16 | #[no_mangle] 17 | pub extern fn rust_object_new()-> * const RustObject{ 18 | let a = RustObject{ 19 | val :0. 20 | }; 21 | let b = Box::new(a); 22 | return Box::into_raw(b); 23 | } 24 | 25 | #[no_mangle] 26 | pub extern fn rust_object_dispose(ptr: * mut RustObject){ 27 | unsafe{ 28 | Box::from_raw(ptr); 29 | } 30 | } 31 | 32 | #[no_mangle] 33 | pub extern fn rust_object_set_value(ptr: * mut RustObject,val:f32){ 34 | let obj = unsafe{ 35 | ptr.as_mut().expect("invalid ptr") 36 | }; 37 | obj.val = val; 38 | } 39 | 40 | #[no_mangle] 41 | extern fn rust_object_get_value(ptr: * const RustObject)->f32{ 42 | let obj = unsafe { 43 | ptr.as_ref().expect("invalid ptr") 44 | }; 45 | return obj.val; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreviewPackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | oneTimeWarningShown: 0 20 | m_Registries: 21 | - m_Id: main 22 | m_Name: 23 | m_Url: https://packages.unity.cn 24 | m_Scopes: [] 25 | m_IsDefault: 1 26 | m_Capabilities: 7 27 | m_UserSelectedRegistryName: 28 | m_UserAddingNewScopedRegistry: 0 29 | m_RegistryInfoDraft: 30 | m_ErrorMessage: 31 | m_Original: 32 | m_Id: 33 | m_Name: 34 | m_Url: 35 | m_Scopes: [] 36 | m_IsDefault: 0 37 | m_Capabilities: 0 38 | m_Modified: 0 39 | m_Name: 40 | m_Url: 41 | m_Scopes: 42 | - 43 | m_SelectedScopeIndex: 0 44 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 9 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 0 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 0 30 | m_AssetPipelineMode: 1 31 | m_CacheServerMode: 0 32 | m_CacheServerEndpoint: 33 | m_CacheServerNamespacePrefix: default 34 | m_CacheServerEnableDownload: 1 35 | m_CacheServerEnableUpload: 1 36 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /UnityRust/Assets/BindingTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System.Runtime.InteropServices; 5 | using UnityEngine.Assertions; 6 | public class BindingTest : MonoBehaviour 7 | { 8 | void Start() 9 | { 10 | UnityRustBindings.RegisterUnityToRust(); 11 | var rustObj = new RustObject(); 12 | Debug.Log(rustObj.val); 13 | rustObj.val = 200; 14 | Debug.Log(rustObj.val); 15 | 16 | var rustObjUnsafe = new RustObjectUnsafe(); 17 | Debug.Log(rustObjUnsafe.val); 18 | rustObjUnsafe.val = 3.1415926f; 19 | Debug.Log(rustObjUnsafe.val); 20 | 21 | var result = test_run_method(100); 22 | Assert.AreEqual(result,101); // 23 | 24 | this.CreatePlane(); 25 | } 26 | 27 | private RustMeshModifier _meshModifier; 28 | 29 | private void CreatePlane(){ 30 | _meshModifier = new RustMeshModifier(); 31 | var meshFilter = new GameObject("Plane").AddComponent(); 32 | var meshRender = meshFilter.gameObject.AddComponent(); 33 | meshFilter.sharedMesh = _meshModifier.mesh; 34 | meshRender.sharedMaterial = new Material(Shader.Find("Standard")); 35 | } 36 | 37 | void Update(){ 38 | if(Input.GetKeyDown(KeyCode.Space)){ 39 | System.GC.Collect(); 40 | } 41 | _meshModifier.Update(); 42 | } 43 | 44 | void OnDestroy(){ 45 | _meshModifier.Dispose(); 46 | } 47 | 48 | [DllImport("unity_rust")] 49 | private extern static int test_run_method(int val); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /unityrust_native/src/bindings/gameobject.rs: -------------------------------------------------------------------------------- 1 | 2 | use super::delegates::*; 3 | use std::marker::PhantomData; 4 | 5 | static mut _CONSTRUCTOR: Option = None; 6 | static mut _DESTRUCTOR:Option = None; 7 | static mut _SET_ACTIVE:Option = None; 8 | 9 | #[no_mangle] 10 | extern fn bind_unityengine_gameobject_constructor(func:UnityDU32){ 11 | unsafe{ 12 | _CONSTRUCTOR = Some(func); 13 | } 14 | } 15 | #[no_mangle] 16 | extern fn bind_unityengine_gameobject_destructor(func:UnityDVoidU32){ 17 | unsafe{ 18 | _DESTRUCTOR = Some(func); 19 | } 20 | } 21 | #[no_mangle] 22 | extern fn bind_unityengine_gameobject_set_active(func:UnityDVoidU32Bool){ 23 | unsafe{ 24 | _SET_ACTIVE = Some(func); 25 | } 26 | } 27 | 28 | pub struct GameObject{ 29 | _unity_object_id:u32, 30 | _not_send_sync:PhantomData<*const ()> 31 | } 32 | 33 | //negative trait bounds are not yet fully implemented; use marker types for now 34 | // impl !Send for GameObject { 35 | // } 36 | // impl !Sync for GameObject { 37 | // } 38 | 39 | impl Drop for GameObject{ 40 | fn drop(&mut self) { 41 | unsafe{ 42 | _DESTRUCTOR.expect("GameObject have not binded")(self._unity_object_id); 43 | } 44 | } 45 | } 46 | 47 | impl GameObject { 48 | pub fn new()->GameObject{ 49 | unsafe{ 50 | let handle = _CONSTRUCTOR.expect("GameObject have not binded")(); 51 | return GameObject{ 52 | _unity_object_id:handle, 53 | _not_send_sync:PhantomData{} 54 | } 55 | } 56 | } 57 | 58 | pub fn set_active(&mut self,value:bool){ 59 | unsafe{ 60 | _SET_ACTIVE.expect("GameObject have not binded")(self._unity_object_id,value); 61 | } 62 | } 63 | } 64 | 65 | 66 | -------------------------------------------------------------------------------- /unityrust_native/src/bindings/nativearray.rs: -------------------------------------------------------------------------------- 1 | use std::{marker::PhantomData, ops::{Index, IndexMut}}; 2 | 3 | 4 | pub struct NativeArray{ 5 | _ptr:* mut T, 6 | _size:isize, 7 | _type:PhantomData 8 | } 9 | 10 | 11 | impl NativeArray{ 12 | 13 | pub fn new(ptr:* mut T,size:isize)->NativeArray{ 14 | return NativeArray{ 15 | _ptr:ptr, 16 | _size:size, 17 | _type:PhantomData{} 18 | }; 19 | } 20 | 21 | pub fn get(&self,index:isize)->Option<&T>{ 22 | if index >= self._size || index < 0 { 23 | return None; 24 | } 25 | let v = unsafe { 26 | self._ptr.offset(index).as_ref().unwrap() 27 | }; 28 | return Some(v); 29 | } 30 | 31 | pub fn get_mut(&self,index:isize)->Option<& mut T>{ 32 | if index >= self._size || index < 0 { 33 | return None; 34 | } 35 | let mut v = unsafe { 36 | self._ptr.offset(index).as_mut().unwrap() 37 | }; 38 | return Some(v); 39 | } 40 | 41 | 42 | pub fn set(&mut self,index:isize,val:T)->bool{ 43 | if index >= self._size || index < 0 { 44 | return false; 45 | } 46 | unsafe{ 47 | * (self._ptr.offset(index)) = val; 48 | return true; 49 | } 50 | } 51 | 52 | pub fn size(&self)->isize{ 53 | self._size 54 | } 55 | } 56 | 57 | impl Index for NativeArray{ 58 | type Output = T; 59 | fn index(&self, index: isize) -> &Self::Output { 60 | return self.get(index).expect("out of bounds"); 61 | } 62 | } 63 | 64 | impl IndexMut for NativeArray { 65 | fn index_mut(&mut self, index: isize) -> &mut Self::Output { 66 | return self.get_mut(index).expect("out of bounds"); 67 | } 68 | } 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /UnityRust/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.burst": "1.4.11", 4 | "com.unity.collab-proxy": "1.7.1", 5 | "com.unity.ide.rider": "2.0.7", 6 | "com.unity.ide.visualstudio": "2.0.11", 7 | "com.unity.ide.vscode": "1.2.3", 8 | "com.unity.test-framework": "1.1.27", 9 | "com.unity.textmeshpro": "3.0.6", 10 | "com.unity.timeline": "1.4.8", 11 | "com.unity.ugui": "1.0.0", 12 | "com.unity.modules.ai": "1.0.0", 13 | "com.unity.modules.androidjni": "1.0.0", 14 | "com.unity.modules.animation": "1.0.0", 15 | "com.unity.modules.assetbundle": "1.0.0", 16 | "com.unity.modules.audio": "1.0.0", 17 | "com.unity.modules.cloth": "1.0.0", 18 | "com.unity.modules.director": "1.0.0", 19 | "com.unity.modules.imageconversion": "1.0.0", 20 | "com.unity.modules.imgui": "1.0.0", 21 | "com.unity.modules.jsonserialize": "1.0.0", 22 | "com.unity.modules.particlesystem": "1.0.0", 23 | "com.unity.modules.physics": "1.0.0", 24 | "com.unity.modules.physics2d": "1.0.0", 25 | "com.unity.modules.screencapture": "1.0.0", 26 | "com.unity.modules.terrain": "1.0.0", 27 | "com.unity.modules.terrainphysics": "1.0.0", 28 | "com.unity.modules.tilemap": "1.0.0", 29 | "com.unity.modules.ui": "1.0.0", 30 | "com.unity.modules.uielements": "1.0.0", 31 | "com.unity.modules.umbra": "1.0.0", 32 | "com.unity.modules.unityanalytics": "1.0.0", 33 | "com.unity.modules.unitywebrequest": "1.0.0", 34 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 35 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 36 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 37 | "com.unity.modules.unitywebrequestwww": "1.0.0", 38 | "com.unity.modules.vehicles": "1.0.0", 39 | "com.unity.modules.video": "1.0.0", 40 | "com.unity.modules.vr": "1.0.0", 41 | "com.unity.modules.wind": "1.0.0", 42 | "com.unity.modules.xr": "1.0.0" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /UnityRust/Assets/RustNative/RustObject.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | public class RustObject{ 7 | 8 | private System.IntPtr _rawPtr; 9 | 10 | public RustObject(){ 11 | _rawPtr = rust_object_new(); 12 | } 13 | 14 | public float val{ 15 | get{ 16 | return rust_object_get_value(_rawPtr); 17 | }set{ 18 | rust_object_set_value(_rawPtr,value); 19 | } 20 | } 21 | 22 | 23 | 24 | private void Dispose() 25 | { 26 | if(_rawPtr != System.IntPtr.Zero){ 27 | rust_object_dispose(_rawPtr); 28 | _rawPtr = System.IntPtr.Zero; 29 | } 30 | } 31 | 32 | ~RustObject(){ 33 | Dispose(); 34 | } 35 | 36 | [DllImport("unity_rust")] 37 | internal static extern System.IntPtr rust_object_new(); 38 | 39 | [DllImport("unity_rust")] 40 | internal static extern void rust_object_dispose(System.IntPtr rawPtr); 41 | 42 | [DllImport("unity_rust")] 43 | private static extern void rust_object_set_value(System.IntPtr ptr,float val); 44 | 45 | [DllImport("unity_rust")] 46 | private static extern float rust_object_get_value(System.IntPtr ptr); 47 | 48 | } 49 | 50 | public class RustObjectUnsafe{ 51 | 52 | [StructLayout(LayoutKind.Sequential)] 53 | public struct RustObjectNative{ 54 | public float val; 55 | } 56 | 57 | private System.IntPtr _rawPtr; 58 | 59 | public RustObjectUnsafe(){ 60 | _rawPtr = RustObject.rust_object_new(); 61 | } 62 | 63 | private unsafe RustObjectNative* pointer{ 64 | get{ 65 | return (RustObjectNative*)_rawPtr; 66 | } 67 | } 68 | 69 | public float val{ 70 | get{ 71 | unsafe{ 72 | return pointer->val; 73 | } 74 | }set{ 75 | unsafe{ 76 | pointer->val = value; 77 | } 78 | } 79 | } 80 | 81 | private void Dispose() 82 | { 83 | if(_rawPtr != System.IntPtr.Zero){ 84 | RustObject.rust_object_dispose(_rawPtr); 85 | _rawPtr = System.IntPtr.Zero; 86 | } 87 | } 88 | 89 | ~RustObjectUnsafe(){ 90 | Dispose(); 91 | } 92 | } 93 | 94 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | m_LogWhenShaderIsCompiled: 0 63 | m_AllowEnlightenSupportForUpgradedProject: 0 64 | -------------------------------------------------------------------------------- /UnityRust/Assets/RustNative/UnityBindings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | 7 | public static class ObjectCache{ 8 | private static Dictionary _objectCache = new Dictionary(); 9 | private static uint _globalId = 0; 10 | 11 | public static uint Add(object obj){ 12 | var id = _globalId ++; 13 | _objectCache.Add(id,obj); 14 | return id; 15 | } 16 | 17 | public static bool Remove(uint id){ 18 | return _objectCache.Remove(id); 19 | } 20 | public static T Get(uint id){ 21 | return (T)_objectCache[id]; 22 | } 23 | } 24 | 25 | public class GameObjectBinding{ 26 | 27 | 28 | [DllImport("unity_rust")] 29 | private static unsafe extern void bind_unityengine_gameobject_constructor(System.Func func); 30 | [DllImport("unity_rust")] 31 | private static unsafe extern void bind_unityengine_gameobject_destructor(System.Action func); 32 | [DllImport("unity_rust")] 33 | private static unsafe extern void bind_unityengine_gameobject_set_active(System.Action func); 34 | 35 | private static uint Constructor(){ 36 | var go = new GameObject(); 37 | var id = ObjectCache.Add(go); 38 | return id; 39 | } 40 | 41 | private static void Destructor(uint objectId){ 42 | ObjectCache.Remove(objectId); 43 | } 44 | 45 | private static void SetActive(uint objectId,bool val){ 46 | ObjectCache.Get(objectId).SetActive(val); 47 | } 48 | 49 | public static void Register(){ 50 | bind_unityengine_gameobject_constructor(Constructor); 51 | bind_unityengine_gameobject_destructor(Destructor); 52 | bind_unityengine_gameobject_set_active(SetActive); 53 | } 54 | } 55 | 56 | public class DebugBinding{ 57 | 58 | /// 59 | /// 调用Register,注册相关函数到rust中 60 | /// 61 | public static void Register(){ 62 | bind_unityengine_debug_log(unity_log); 63 | } 64 | private static void unity_log(string msg){ 65 | UnityEngine.Debug.Log(msg); 66 | } 67 | [DllImport("unity_rust")] 68 | private static unsafe extern void bind_unityengine_debug_log(System.Action func); 69 | } 70 | 71 | public static class UnityRustBindings{ 72 | public static void RegisterUnityToRust(){ 73 | DebugBinding.Register(); 74 | GameObjectBinding.Register(); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /UnityRust/Assets/RustMeshModifier.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Unity.Collections; 5 | using System.Runtime.InteropServices; 6 | using Unity.Mathematics; 7 | using UnityEngine.Rendering; 8 | using Unity.Collections.LowLevel.Unsafe; 9 | 10 | public class RustMeshModifier 11 | { 12 | [StructLayout(LayoutKind.Sequential)] 13 | public struct Vertex{ 14 | public float3 position; 15 | public float3 normal; 16 | } 17 | 18 | private Mesh _mesh; 19 | private NativeArray _vertexBuffer; 20 | 21 | public RustMeshModifier(){ 22 | _mesh = new Mesh(); 23 | var layout = new[] 24 | { 25 | new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.Float32, 3), 26 | new VertexAttributeDescriptor(VertexAttribute.Normal, VertexAttributeFormat.Float32, 3), 27 | }; 28 | var vertexCount = 4; 29 | _mesh.SetVertexBufferParams(vertexCount, layout); 30 | _vertexBuffer = new NativeArray(vertexCount,Allocator.Persistent,NativeArrayOptions.UninitializedMemory); 31 | _vertexBuffer[0] = new Vertex(){ 32 | position = new float3(0,0,0), 33 | normal = new float3(0,0,-1), 34 | }; 35 | _vertexBuffer[1] = new Vertex(){ 36 | position = new float3(1,0,0), 37 | normal = new float3(0,0,-1), 38 | }; 39 | _vertexBuffer[3] = new Vertex(){ 40 | position = new float3(1,1,0), 41 | normal = new float3(0,0,-1), 42 | }; 43 | _vertexBuffer[2] = new Vertex(){ 44 | position = new float3(0,1,0), 45 | normal = new float3(0,0,-1), 46 | }; 47 | _mesh.SetVertexBufferData(_vertexBuffer,0,0,vertexCount); 48 | _mesh.SetIndices(new int[]{ 49 | 0,3,1,1,3,2 50 | },MeshTopology.Triangles, 0); 51 | _mesh.MarkDynamic(); 52 | } 53 | 54 | 55 | public Mesh mesh{ 56 | get{ 57 | return _mesh; 58 | } 59 | } 60 | 61 | public void Dispose(){ 62 | _vertexBuffer.Dispose(); 63 | } 64 | 65 | public void Update(){ 66 | unsafe{ 67 | var ptr = (System.IntPtr)NativeArrayUnsafeUtility.GetUnsafePtr(_vertexBuffer); 68 | var vertexCount = _vertexBuffer.Length; 69 | //在rust中更新vertexbuffer 70 | rust_dynamic_update_mesh(ptr,(uint)vertexCount,Time.time); 71 | _mesh.SetVertexBufferData(_vertexBuffer,0,0,vertexCount); 72 | } 73 | } 74 | 75 | [DllImport("unity_rust")] 76 | private extern static void rust_dynamic_update_mesh(System.IntPtr nativeArrayPtr,uint arraySize,float time); 77 | 78 | } 79 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "ignore": false, 8 | "defaultInstantiationMode": 0, 9 | "supportsModification": true 10 | }, 11 | { 12 | "userAdded": false, 13 | "type": "UnityEditor.Animations.AnimatorController", 14 | "ignore": false, 15 | "defaultInstantiationMode": 0, 16 | "supportsModification": true 17 | }, 18 | { 19 | "userAdded": false, 20 | "type": "UnityEngine.AnimatorOverrideController", 21 | "ignore": false, 22 | "defaultInstantiationMode": 0, 23 | "supportsModification": true 24 | }, 25 | { 26 | "userAdded": false, 27 | "type": "UnityEditor.Audio.AudioMixerController", 28 | "ignore": false, 29 | "defaultInstantiationMode": 0, 30 | "supportsModification": true 31 | }, 32 | { 33 | "userAdded": false, 34 | "type": "UnityEngine.ComputeShader", 35 | "ignore": true, 36 | "defaultInstantiationMode": 1, 37 | "supportsModification": true 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEngine.Cubemap", 42 | "ignore": false, 43 | "defaultInstantiationMode": 0, 44 | "supportsModification": true 45 | }, 46 | { 47 | "userAdded": false, 48 | "type": "UnityEngine.GameObject", 49 | "ignore": false, 50 | "defaultInstantiationMode": 0, 51 | "supportsModification": true 52 | }, 53 | { 54 | "userAdded": false, 55 | "type": "UnityEditor.LightingDataAsset", 56 | "ignore": false, 57 | "defaultInstantiationMode": 0, 58 | "supportsModification": false 59 | }, 60 | { 61 | "userAdded": false, 62 | "type": "UnityEngine.LightingSettings", 63 | "ignore": false, 64 | "defaultInstantiationMode": 0, 65 | "supportsModification": true 66 | }, 67 | { 68 | "userAdded": false, 69 | "type": "UnityEngine.Material", 70 | "ignore": false, 71 | "defaultInstantiationMode": 0, 72 | "supportsModification": true 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEditor.MonoScript", 77 | "ignore": true, 78 | "defaultInstantiationMode": 1, 79 | "supportsModification": true 80 | }, 81 | { 82 | "userAdded": false, 83 | "type": "UnityEngine.PhysicMaterial", 84 | "ignore": false, 85 | "defaultInstantiationMode": 0, 86 | "supportsModification": true 87 | }, 88 | { 89 | "userAdded": false, 90 | "type": "UnityEngine.PhysicsMaterial2D", 91 | "ignore": false, 92 | "defaultInstantiationMode": 0, 93 | "supportsModification": true 94 | }, 95 | { 96 | "userAdded": false, 97 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 98 | "ignore": false, 99 | "defaultInstantiationMode": 0, 100 | "supportsModification": true 101 | }, 102 | { 103 | "userAdded": false, 104 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 105 | "ignore": false, 106 | "defaultInstantiationMode": 0, 107 | "supportsModification": true 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Rendering.VolumeProfile", 112 | "ignore": false, 113 | "defaultInstantiationMode": 0, 114 | "supportsModification": true 115 | }, 116 | { 117 | "userAdded": false, 118 | "type": "UnityEditor.SceneAsset", 119 | "ignore": false, 120 | "defaultInstantiationMode": 0, 121 | "supportsModification": false 122 | }, 123 | { 124 | "userAdded": false, 125 | "type": "UnityEngine.Shader", 126 | "ignore": true, 127 | "defaultInstantiationMode": 1, 128 | "supportsModification": true 129 | }, 130 | { 131 | "userAdded": false, 132 | "type": "UnityEngine.ShaderVariantCollection", 133 | "ignore": true, 134 | "defaultInstantiationMode": 1, 135 | "supportsModification": true 136 | }, 137 | { 138 | "userAdded": false, 139 | "type": "UnityEngine.Texture", 140 | "ignore": false, 141 | "defaultInstantiationMode": 0, 142 | "supportsModification": true 143 | }, 144 | { 145 | "userAdded": false, 146 | "type": "UnityEngine.Texture2D", 147 | "ignore": false, 148 | "defaultInstantiationMode": 0, 149 | "supportsModification": true 150 | }, 151 | { 152 | "userAdded": false, 153 | "type": "UnityEngine.Timeline.TimelineAsset", 154 | "ignore": false, 155 | "defaultInstantiationMode": 0, 156 | "supportsModification": true 157 | } 158 | ], 159 | "defaultDependencyTypeInfo": { 160 | "userAdded": false, 161 | "type": "", 162 | "ignore": false, 163 | "defaultInstantiationMode": 1, 164 | "supportsModification": true 165 | }, 166 | "newSceneOverride": 0 167 | } -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | excludedTargetPlatforms: [] 44 | - serializedVersion: 2 45 | name: Low 46 | pixelLightCount: 0 47 | shadows: 0 48 | shadowResolution: 0 49 | shadowProjection: 1 50 | shadowCascades: 1 51 | shadowDistance: 20 52 | shadowNearPlaneOffset: 3 53 | shadowCascade2Split: 0.33333334 54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 55 | shadowmaskMode: 0 56 | blendWeights: 2 57 | textureQuality: 0 58 | anisotropicTextures: 0 59 | antiAliasing: 0 60 | softParticles: 0 61 | softVegetation: 0 62 | realtimeReflectionProbes: 0 63 | billboardsFaceCameraPosition: 0 64 | vSyncCount: 0 65 | lodBias: 0.4 66 | maximumLODLevel: 0 67 | streamingMipmapsActive: 0 68 | streamingMipmapsAddAllCameras: 1 69 | streamingMipmapsMemoryBudget: 512 70 | streamingMipmapsRenderersPerFrame: 512 71 | streamingMipmapsMaxLevelReduction: 2 72 | streamingMipmapsMaxFileIORequests: 1024 73 | particleRaycastBudget: 16 74 | asyncUploadTimeSlice: 2 75 | asyncUploadBufferSize: 16 76 | asyncUploadPersistentBuffer: 1 77 | resolutionScalingFixedDPIFactor: 1 78 | excludedTargetPlatforms: [] 79 | - serializedVersion: 2 80 | name: Medium 81 | pixelLightCount: 1 82 | shadows: 1 83 | shadowResolution: 0 84 | shadowProjection: 1 85 | shadowCascades: 1 86 | shadowDistance: 20 87 | shadowNearPlaneOffset: 3 88 | shadowCascade2Split: 0.33333334 89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 90 | shadowmaskMode: 0 91 | blendWeights: 2 92 | textureQuality: 0 93 | anisotropicTextures: 1 94 | antiAliasing: 0 95 | softParticles: 0 96 | softVegetation: 0 97 | realtimeReflectionProbes: 0 98 | billboardsFaceCameraPosition: 0 99 | vSyncCount: 1 100 | lodBias: 0.7 101 | maximumLODLevel: 0 102 | streamingMipmapsActive: 0 103 | streamingMipmapsAddAllCameras: 1 104 | streamingMipmapsMemoryBudget: 512 105 | streamingMipmapsRenderersPerFrame: 512 106 | streamingMipmapsMaxLevelReduction: 2 107 | streamingMipmapsMaxFileIORequests: 1024 108 | particleRaycastBudget: 64 109 | asyncUploadTimeSlice: 2 110 | asyncUploadBufferSize: 16 111 | asyncUploadPersistentBuffer: 1 112 | resolutionScalingFixedDPIFactor: 1 113 | excludedTargetPlatforms: [] 114 | - serializedVersion: 2 115 | name: High 116 | pixelLightCount: 2 117 | shadows: 2 118 | shadowResolution: 1 119 | shadowProjection: 1 120 | shadowCascades: 2 121 | shadowDistance: 40 122 | shadowNearPlaneOffset: 3 123 | shadowCascade2Split: 0.33333334 124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 125 | shadowmaskMode: 1 126 | blendWeights: 2 127 | textureQuality: 0 128 | anisotropicTextures: 1 129 | antiAliasing: 0 130 | softParticles: 0 131 | softVegetation: 1 132 | realtimeReflectionProbes: 1 133 | billboardsFaceCameraPosition: 1 134 | vSyncCount: 1 135 | lodBias: 1 136 | maximumLODLevel: 0 137 | streamingMipmapsActive: 0 138 | streamingMipmapsAddAllCameras: 1 139 | streamingMipmapsMemoryBudget: 512 140 | streamingMipmapsRenderersPerFrame: 512 141 | streamingMipmapsMaxLevelReduction: 2 142 | streamingMipmapsMaxFileIORequests: 1024 143 | particleRaycastBudget: 256 144 | asyncUploadTimeSlice: 2 145 | asyncUploadBufferSize: 16 146 | asyncUploadPersistentBuffer: 1 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Very High 151 | pixelLightCount: 3 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 2 156 | shadowDistance: 70 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 1.5 171 | maximumLODLevel: 0 172 | streamingMipmapsActive: 0 173 | streamingMipmapsAddAllCameras: 1 174 | streamingMipmapsMemoryBudget: 512 175 | streamingMipmapsRenderersPerFrame: 512 176 | streamingMipmapsMaxLevelReduction: 2 177 | streamingMipmapsMaxFileIORequests: 1024 178 | particleRaycastBudget: 1024 179 | asyncUploadTimeSlice: 2 180 | asyncUploadBufferSize: 16 181 | asyncUploadPersistentBuffer: 1 182 | resolutionScalingFixedDPIFactor: 1 183 | excludedTargetPlatforms: [] 184 | - serializedVersion: 2 185 | name: Ultra 186 | pixelLightCount: 4 187 | shadows: 2 188 | shadowResolution: 2 189 | shadowProjection: 1 190 | shadowCascades: 4 191 | shadowDistance: 150 192 | shadowNearPlaneOffset: 3 193 | shadowCascade2Split: 0.33333334 194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 195 | shadowmaskMode: 1 196 | blendWeights: 4 197 | textureQuality: 0 198 | anisotropicTextures: 2 199 | antiAliasing: 2 200 | softParticles: 1 201 | softVegetation: 1 202 | realtimeReflectionProbes: 1 203 | billboardsFaceCameraPosition: 1 204 | vSyncCount: 1 205 | lodBias: 2 206 | maximumLODLevel: 0 207 | streamingMipmapsActive: 0 208 | streamingMipmapsAddAllCameras: 1 209 | streamingMipmapsMemoryBudget: 512 210 | streamingMipmapsRenderersPerFrame: 512 211 | streamingMipmapsMaxLevelReduction: 2 212 | streamingMipmapsMaxFileIORequests: 1024 213 | particleRaycastBudget: 4096 214 | asyncUploadTimeSlice: 2 215 | asyncUploadBufferSize: 16 216 | asyncUploadPersistentBuffer: 1 217 | resolutionScalingFixedDPIFactor: 1 218 | excludedTargetPlatforms: [] 219 | m_PerPlatformDefaultQuality: 220 | Android: 2 221 | Lumin: 5 222 | Nintendo 3DS: 5 223 | Nintendo Switch: 5 224 | PS4: 5 225 | PSP2: 2 226 | Stadia: 5 227 | Standalone: 5 228 | WebGL: 3 229 | Windows Store Apps: 5 230 | XboxOne: 5 231 | iPhone: 2 232 | tvOS: 2 233 | -------------------------------------------------------------------------------- /UnityRust/Assets/BindingTest.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0.3731193, g: 0.38073996, b: 0.35872698, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 12 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 512 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 256 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 1 83 | m_PVRDenoiserTypeDirect: 1 84 | m_PVRDenoiserTypeIndirect: 1 85 | m_PVRDenoiserTypeAO: 1 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 1 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_LightingSettings: {fileID: 0} 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | maxJobWorkers: 0 122 | preserveTilesOutsideBounds: 0 123 | debug: 124 | m_Flags: 0 125 | m_NavMeshData: {fileID: 0} 126 | --- !u!1 &759939 127 | GameObject: 128 | m_ObjectHideFlags: 0 129 | m_CorrespondingSourceObject: {fileID: 0} 130 | m_PrefabInstance: {fileID: 0} 131 | m_PrefabAsset: {fileID: 0} 132 | serializedVersion: 6 133 | m_Component: 134 | - component: {fileID: 759940} 135 | - component: {fileID: 759941} 136 | m_Layer: 0 137 | m_Name: GameObject 138 | m_TagString: Untagged 139 | m_Icon: {fileID: 0} 140 | m_NavMeshLayer: 0 141 | m_StaticEditorFlags: 0 142 | m_IsActive: 1 143 | --- !u!4 &759940 144 | Transform: 145 | m_ObjectHideFlags: 0 146 | m_CorrespondingSourceObject: {fileID: 0} 147 | m_PrefabInstance: {fileID: 0} 148 | m_PrefabAsset: {fileID: 0} 149 | m_GameObject: {fileID: 759939} 150 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 151 | m_LocalPosition: {x: 0, y: 0, z: 0} 152 | m_LocalScale: {x: 1, y: 1, z: 1} 153 | m_Children: [] 154 | m_Father: {fileID: 0} 155 | m_RootOrder: 0 156 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 157 | --- !u!114 &759941 158 | MonoBehaviour: 159 | m_ObjectHideFlags: 0 160 | m_CorrespondingSourceObject: {fileID: 0} 161 | m_PrefabInstance: {fileID: 0} 162 | m_PrefabAsset: {fileID: 0} 163 | m_GameObject: {fileID: 759939} 164 | m_Enabled: 1 165 | m_EditorHideFlags: 0 166 | m_Script: {fileID: 11500000, guid: 2312498f95f494ef28e327ed8fddf32d, type: 3} 167 | m_Name: 168 | m_EditorClassIdentifier: 169 | --- !u!1 &1884904930 170 | GameObject: 171 | m_ObjectHideFlags: 0 172 | m_CorrespondingSourceObject: {fileID: 0} 173 | m_PrefabInstance: {fileID: 0} 174 | m_PrefabAsset: {fileID: 0} 175 | serializedVersion: 6 176 | m_Component: 177 | - component: {fileID: 1884904933} 178 | - component: {fileID: 1884904932} 179 | - component: {fileID: 1884904931} 180 | m_Layer: 0 181 | m_Name: Camera 182 | m_TagString: Untagged 183 | m_Icon: {fileID: 0} 184 | m_NavMeshLayer: 0 185 | m_StaticEditorFlags: 0 186 | m_IsActive: 1 187 | --- !u!81 &1884904931 188 | AudioListener: 189 | m_ObjectHideFlags: 0 190 | m_CorrespondingSourceObject: {fileID: 0} 191 | m_PrefabInstance: {fileID: 0} 192 | m_PrefabAsset: {fileID: 0} 193 | m_GameObject: {fileID: 1884904930} 194 | m_Enabled: 1 195 | --- !u!20 &1884904932 196 | Camera: 197 | m_ObjectHideFlags: 0 198 | m_CorrespondingSourceObject: {fileID: 0} 199 | m_PrefabInstance: {fileID: 0} 200 | m_PrefabAsset: {fileID: 0} 201 | m_GameObject: {fileID: 1884904930} 202 | m_Enabled: 1 203 | serializedVersion: 2 204 | m_ClearFlags: 1 205 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 206 | m_projectionMatrixMode: 1 207 | m_GateFitMode: 2 208 | m_FOVAxisMode: 0 209 | m_SensorSize: {x: 36, y: 24} 210 | m_LensShift: {x: 0, y: 0} 211 | m_FocalLength: 50 212 | m_NormalizedViewPortRect: 213 | serializedVersion: 2 214 | x: 0 215 | y: 0 216 | width: 1 217 | height: 1 218 | near clip plane: 0.3 219 | far clip plane: 1000 220 | field of view: 60 221 | orthographic: 0 222 | orthographic size: 5 223 | m_Depth: 0 224 | m_CullingMask: 225 | serializedVersion: 2 226 | m_Bits: 4294967295 227 | m_RenderingPath: -1 228 | m_TargetTexture: {fileID: 0} 229 | m_TargetDisplay: 0 230 | m_TargetEye: 3 231 | m_HDR: 1 232 | m_AllowMSAA: 1 233 | m_AllowDynamicResolution: 0 234 | m_ForceIntoRT: 0 235 | m_OcclusionCulling: 1 236 | m_StereoConvergence: 10 237 | m_StereoSeparation: 0.022 238 | --- !u!4 &1884904933 239 | Transform: 240 | m_ObjectHideFlags: 0 241 | m_CorrespondingSourceObject: {fileID: 0} 242 | m_PrefabInstance: {fileID: 0} 243 | m_PrefabAsset: {fileID: 0} 244 | m_GameObject: {fileID: 1884904930} 245 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 246 | m_LocalPosition: {x: 0, y: 0, z: -10} 247 | m_LocalScale: {x: 1, y: 1, z: 1} 248 | m_Children: [] 249 | m_Father: {fileID: 0} 250 | m_RootOrder: 1 251 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 252 | -------------------------------------------------------------------------------- /UnityRust/Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.burst": { 4 | "version": "1.4.11", 5 | "depth": 0, 6 | "source": "registry", 7 | "dependencies": { 8 | "com.unity.mathematics": "1.2.1" 9 | }, 10 | "url": "https://packages.unity.cn" 11 | }, 12 | "com.unity.collab-proxy": { 13 | "version": "1.7.1", 14 | "depth": 0, 15 | "source": "registry", 16 | "dependencies": { 17 | "com.unity.nuget.newtonsoft-json": "2.0.0" 18 | }, 19 | "url": "https://packages.unity.cn" 20 | }, 21 | "com.unity.ext.nunit": { 22 | "version": "1.0.6", 23 | "depth": 1, 24 | "source": "registry", 25 | "dependencies": {}, 26 | "url": "https://packages.unity.cn" 27 | }, 28 | "com.unity.ide.rider": { 29 | "version": "2.0.7", 30 | "depth": 0, 31 | "source": "registry", 32 | "dependencies": { 33 | "com.unity.test-framework": "1.1.1" 34 | }, 35 | "url": "https://packages.unity.cn" 36 | }, 37 | "com.unity.ide.visualstudio": { 38 | "version": "2.0.11", 39 | "depth": 0, 40 | "source": "registry", 41 | "dependencies": { 42 | "com.unity.test-framework": "1.1.9" 43 | }, 44 | "url": "https://packages.unity.cn" 45 | }, 46 | "com.unity.ide.vscode": { 47 | "version": "1.2.3", 48 | "depth": 0, 49 | "source": "registry", 50 | "dependencies": {}, 51 | "url": "https://packages.unity.cn" 52 | }, 53 | "com.unity.mathematics": { 54 | "version": "1.2.1", 55 | "depth": 1, 56 | "source": "registry", 57 | "dependencies": {}, 58 | "url": "https://packages.unity.cn" 59 | }, 60 | "com.unity.nuget.newtonsoft-json": { 61 | "version": "2.0.0", 62 | "depth": 1, 63 | "source": "registry", 64 | "dependencies": {}, 65 | "url": "https://packages.unity.cn" 66 | }, 67 | "com.unity.test-framework": { 68 | "version": "1.1.27", 69 | "depth": 0, 70 | "source": "registry", 71 | "dependencies": { 72 | "com.unity.ext.nunit": "1.0.6", 73 | "com.unity.modules.imgui": "1.0.0", 74 | "com.unity.modules.jsonserialize": "1.0.0" 75 | }, 76 | "url": "https://packages.unity.cn" 77 | }, 78 | "com.unity.textmeshpro": { 79 | "version": "3.0.6", 80 | "depth": 0, 81 | "source": "registry", 82 | "dependencies": { 83 | "com.unity.ugui": "1.0.0" 84 | }, 85 | "url": "https://packages.unity.cn" 86 | }, 87 | "com.unity.timeline": { 88 | "version": "1.4.8", 89 | "depth": 0, 90 | "source": "registry", 91 | "dependencies": { 92 | "com.unity.modules.director": "1.0.0", 93 | "com.unity.modules.animation": "1.0.0", 94 | "com.unity.modules.audio": "1.0.0", 95 | "com.unity.modules.particlesystem": "1.0.0" 96 | }, 97 | "url": "https://packages.unity.cn" 98 | }, 99 | "com.unity.ugui": { 100 | "version": "1.0.0", 101 | "depth": 0, 102 | "source": "builtin", 103 | "dependencies": { 104 | "com.unity.modules.ui": "1.0.0", 105 | "com.unity.modules.imgui": "1.0.0" 106 | } 107 | }, 108 | "com.unity.modules.ai": { 109 | "version": "1.0.0", 110 | "depth": 0, 111 | "source": "builtin", 112 | "dependencies": {} 113 | }, 114 | "com.unity.modules.androidjni": { 115 | "version": "1.0.0", 116 | "depth": 0, 117 | "source": "builtin", 118 | "dependencies": {} 119 | }, 120 | "com.unity.modules.animation": { 121 | "version": "1.0.0", 122 | "depth": 0, 123 | "source": "builtin", 124 | "dependencies": {} 125 | }, 126 | "com.unity.modules.assetbundle": { 127 | "version": "1.0.0", 128 | "depth": 0, 129 | "source": "builtin", 130 | "dependencies": {} 131 | }, 132 | "com.unity.modules.audio": { 133 | "version": "1.0.0", 134 | "depth": 0, 135 | "source": "builtin", 136 | "dependencies": {} 137 | }, 138 | "com.unity.modules.cloth": { 139 | "version": "1.0.0", 140 | "depth": 0, 141 | "source": "builtin", 142 | "dependencies": { 143 | "com.unity.modules.physics": "1.0.0" 144 | } 145 | }, 146 | "com.unity.modules.director": { 147 | "version": "1.0.0", 148 | "depth": 0, 149 | "source": "builtin", 150 | "dependencies": { 151 | "com.unity.modules.audio": "1.0.0", 152 | "com.unity.modules.animation": "1.0.0" 153 | } 154 | }, 155 | "com.unity.modules.imageconversion": { 156 | "version": "1.0.0", 157 | "depth": 0, 158 | "source": "builtin", 159 | "dependencies": {} 160 | }, 161 | "com.unity.modules.imgui": { 162 | "version": "1.0.0", 163 | "depth": 0, 164 | "source": "builtin", 165 | "dependencies": {} 166 | }, 167 | "com.unity.modules.jsonserialize": { 168 | "version": "1.0.0", 169 | "depth": 0, 170 | "source": "builtin", 171 | "dependencies": {} 172 | }, 173 | "com.unity.modules.particlesystem": { 174 | "version": "1.0.0", 175 | "depth": 0, 176 | "source": "builtin", 177 | "dependencies": {} 178 | }, 179 | "com.unity.modules.physics": { 180 | "version": "1.0.0", 181 | "depth": 0, 182 | "source": "builtin", 183 | "dependencies": {} 184 | }, 185 | "com.unity.modules.physics2d": { 186 | "version": "1.0.0", 187 | "depth": 0, 188 | "source": "builtin", 189 | "dependencies": {} 190 | }, 191 | "com.unity.modules.screencapture": { 192 | "version": "1.0.0", 193 | "depth": 0, 194 | "source": "builtin", 195 | "dependencies": { 196 | "com.unity.modules.imageconversion": "1.0.0" 197 | } 198 | }, 199 | "com.unity.modules.subsystems": { 200 | "version": "1.0.0", 201 | "depth": 1, 202 | "source": "builtin", 203 | "dependencies": { 204 | "com.unity.modules.jsonserialize": "1.0.0" 205 | } 206 | }, 207 | "com.unity.modules.terrain": { 208 | "version": "1.0.0", 209 | "depth": 0, 210 | "source": "builtin", 211 | "dependencies": {} 212 | }, 213 | "com.unity.modules.terrainphysics": { 214 | "version": "1.0.0", 215 | "depth": 0, 216 | "source": "builtin", 217 | "dependencies": { 218 | "com.unity.modules.physics": "1.0.0", 219 | "com.unity.modules.terrain": "1.0.0" 220 | } 221 | }, 222 | "com.unity.modules.tilemap": { 223 | "version": "1.0.0", 224 | "depth": 0, 225 | "source": "builtin", 226 | "dependencies": { 227 | "com.unity.modules.physics2d": "1.0.0" 228 | } 229 | }, 230 | "com.unity.modules.ui": { 231 | "version": "1.0.0", 232 | "depth": 0, 233 | "source": "builtin", 234 | "dependencies": {} 235 | }, 236 | "com.unity.modules.uielements": { 237 | "version": "1.0.0", 238 | "depth": 0, 239 | "source": "builtin", 240 | "dependencies": { 241 | "com.unity.modules.ui": "1.0.0", 242 | "com.unity.modules.imgui": "1.0.0", 243 | "com.unity.modules.jsonserialize": "1.0.0", 244 | "com.unity.modules.uielementsnative": "1.0.0" 245 | } 246 | }, 247 | "com.unity.modules.uielementsnative": { 248 | "version": "1.0.0", 249 | "depth": 1, 250 | "source": "builtin", 251 | "dependencies": { 252 | "com.unity.modules.ui": "1.0.0", 253 | "com.unity.modules.imgui": "1.0.0", 254 | "com.unity.modules.jsonserialize": "1.0.0" 255 | } 256 | }, 257 | "com.unity.modules.umbra": { 258 | "version": "1.0.0", 259 | "depth": 0, 260 | "source": "builtin", 261 | "dependencies": {} 262 | }, 263 | "com.unity.modules.unityanalytics": { 264 | "version": "1.0.0", 265 | "depth": 0, 266 | "source": "builtin", 267 | "dependencies": { 268 | "com.unity.modules.unitywebrequest": "1.0.0", 269 | "com.unity.modules.jsonserialize": "1.0.0" 270 | } 271 | }, 272 | "com.unity.modules.unitywebrequest": { 273 | "version": "1.0.0", 274 | "depth": 0, 275 | "source": "builtin", 276 | "dependencies": {} 277 | }, 278 | "com.unity.modules.unitywebrequestassetbundle": { 279 | "version": "1.0.0", 280 | "depth": 0, 281 | "source": "builtin", 282 | "dependencies": { 283 | "com.unity.modules.assetbundle": "1.0.0", 284 | "com.unity.modules.unitywebrequest": "1.0.0" 285 | } 286 | }, 287 | "com.unity.modules.unitywebrequestaudio": { 288 | "version": "1.0.0", 289 | "depth": 0, 290 | "source": "builtin", 291 | "dependencies": { 292 | "com.unity.modules.unitywebrequest": "1.0.0", 293 | "com.unity.modules.audio": "1.0.0" 294 | } 295 | }, 296 | "com.unity.modules.unitywebrequesttexture": { 297 | "version": "1.0.0", 298 | "depth": 0, 299 | "source": "builtin", 300 | "dependencies": { 301 | "com.unity.modules.unitywebrequest": "1.0.0", 302 | "com.unity.modules.imageconversion": "1.0.0" 303 | } 304 | }, 305 | "com.unity.modules.unitywebrequestwww": { 306 | "version": "1.0.0", 307 | "depth": 0, 308 | "source": "builtin", 309 | "dependencies": { 310 | "com.unity.modules.unitywebrequest": "1.0.0", 311 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 312 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 313 | "com.unity.modules.audio": "1.0.0", 314 | "com.unity.modules.assetbundle": "1.0.0", 315 | "com.unity.modules.imageconversion": "1.0.0" 316 | } 317 | }, 318 | "com.unity.modules.vehicles": { 319 | "version": "1.0.0", 320 | "depth": 0, 321 | "source": "builtin", 322 | "dependencies": { 323 | "com.unity.modules.physics": "1.0.0" 324 | } 325 | }, 326 | "com.unity.modules.video": { 327 | "version": "1.0.0", 328 | "depth": 0, 329 | "source": "builtin", 330 | "dependencies": { 331 | "com.unity.modules.audio": "1.0.0", 332 | "com.unity.modules.ui": "1.0.0", 333 | "com.unity.modules.unitywebrequest": "1.0.0" 334 | } 335 | }, 336 | "com.unity.modules.vr": { 337 | "version": "1.0.0", 338 | "depth": 0, 339 | "source": "builtin", 340 | "dependencies": { 341 | "com.unity.modules.jsonserialize": "1.0.0", 342 | "com.unity.modules.physics": "1.0.0", 343 | "com.unity.modules.xr": "1.0.0" 344 | } 345 | }, 346 | "com.unity.modules.wind": { 347 | "version": "1.0.0", 348 | "depth": 0, 349 | "source": "builtin", 350 | "dependencies": {} 351 | }, 352 | "com.unity.modules.xr": { 353 | "version": "1.0.0", 354 | "depth": 0, 355 | "source": "builtin", 356 | "dependencies": { 357 | "com.unity.modules.physics": "1.0.0", 358 | "com.unity.modules.jsonserialize": "1.0.0", 359 | "com.unity.modules.subsystems": "1.0.0" 360 | } 361 | } 362 | } 363 | } 364 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity中C#与Rust交互 2 | 3 | 最近在学习Rust,顺带就研究了一下如何在Unity中使用Rust。写了一个小项目来测试Rust与Unity的交互,此文仅作马克之用。 4 | 5 | Rust是一门对标C/C++的高性能语言。其独特之处在于既没有自动GC机制,也无需手动释放内存。在Unity中大约是可以用来写一些高计算量、性能敏感型的代码。 Unity目前在推的Burst Compiler / Job System也是为高性能计算服务的,两者自然是竞争关系。如果希望写一套库能同时给多个引擎使用,那么就不能使用Unity自带的那套技术方案了。 这时候C++/Rust就是一个好选项。具体用哪个呢,萝卜青菜各有所爱,反正主都不在乎。 6 | 7 | 首先,关于Rust的FFI可以参考官方文档 - [Foreign Function Interface](https://doc.rust-lang.org/nomicon/ffi.html) 8 | 9 | 这里假设我们已经知道如何使用cargo命令构建一个rust library项目,并将其编译成相应平台的动态库。在本测试项目中输出的动态库为`libunity_rust.dylib`,将其丢入Unity项目中。 10 | 11 | 下面将依次说一下如何在Unity中实现: 12 | 13 | - 在C#里调用Rust函数/方法 14 | - Rust返回对象到C# 15 | - 在C#里访问Rust Struct的数据 16 | - 在Rust里调用C#的静态函数 17 | - 在Rust里调用C#的成员函数 18 | 19 | 20 | # 1. C#调用Rust函数/方法 21 | 22 | 这其实很简单。。首先在Rust中函数实现如下: 23 | 24 | ```rust 25 | #[no_mangle] 26 | pub extern fn test_run_method(val:i32)->i32{ 27 | return val + 1; 28 | } 29 | ``` 30 | 31 | - `extern`表示这个函数可以被外部语言调用 32 | - `#[no_mangle]`这个attribute告诉rust编译器不要修改这个函数名字 33 | 34 | 这个函数会对输入值val进行 `+1` 并返回 35 | 36 | c#端定义如下: 37 | 38 | ```c# 39 | [DllImport("unity_rust")] 40 | private extern static int test_run_method(int val); 41 | ``` 42 | 43 | - DllImport中的"unity_rust"是Rust编译出的动态库名字 44 | 45 | 测试调用: 46 | 47 | ```c# 48 | var result = test_run_method(100); 49 | Assert.AreEqual(result,101); // 50 | ``` 51 | 52 | # 2. Rust返回对象到C# 53 | 54 | 现在假设我们在rust端有一个如下的struct对象: 55 | 56 | ```rust 57 | pub struct RustObject{ 58 | pub val:f32 59 | } 60 | ``` 61 | 62 | 我们希望在c#端能够创建RustObject对象,并对其进行维护。 63 | 64 | 在rust端定义函数如下: 65 | ```rust 66 | #[no_mangle] 67 | pub extern fn rust_object_new()-> * const RustObject{ 68 | let obj = RustObject{ 69 | val :0. 70 | }; 71 | let b = Box::new(obj); 72 | return Box::into_raw(b); 73 | } 74 | ``` 75 | 76 | 这里首先会构造一个RustObject实例`obj`。在rust中对象默认都是分配在栈上的,为了将obj这个对象返回给c#进行管理,我们需要将其先转移到堆上。Box是Rust中的一个智能指针,它可以将数据转移到堆上存储,并在自身内部维护一个指向堆上数据的指针。当box超出作用域时会自动回收堆上内存。 77 | 78 | 所以这里通过 79 | 80 | ```rust 81 | let b = Box::new(obj); 82 | ``` 83 | 84 | 就成功将obj转移到了堆上。 85 | 86 | 为了不让rust在函数结束时自动回收堆上内存,我们需要拿到这块内存的手动管理权限,可以通过以下方式做到: 87 | 88 | ```rust 89 | Box::into_raw(b) 90 | ``` 91 | 92 | `Box::into_raw`可以返回Box内部维护的指针,并将box对象consume掉。 93 | 这样rust将不再负责回收其指向的堆上内存,使用者需要再恰当的时机手动对其进行回收。 94 | 95 | c#端对应的定义: 96 | 97 | ```c# 98 | [DllImport("unity_rust")] 99 | internal static extern System.IntPtr rust_object_new(); 100 | ``` 101 | c#中使用`System.IntPtr`来代表一个指针对象。 102 | 103 | 这样我们就把一个RustObject对象返回给了C#,由C#负责其生命周期管理。 104 | 105 | 106 | 那么如何回收这份内存呢? 107 | 108 | 在rust端我们可以实现函数如下: 109 | 110 | ```rust 111 | #[no_mangle] 112 | pub extern fn rust_object_dispose(ptr: * mut RustObject){ 113 | unsafe{ 114 | Box::from_raw(ptr); 115 | } 116 | } 117 | ``` 118 | 119 | `Box::from_raw`是将指针对象重新由Box封装起来,然后函数结束时,box由于超出作用域自动对指针指向的内存进行回收。 120 | 121 | c#端相应声明如下: 122 | 123 | ```c# 124 | [DllImport("unity_rust")] 125 | internal static extern void rust_object_dispose(System.IntPtr rawPtr); 126 | ``` 127 | 128 | 通常而言,我们可以将`rust_object_dispose`与c#中的析构函数结合起来,这样就实现了由GC来自动回收rust端分配的内存。例如我们在c#端实现一个RustObject的绑定类如下: 129 | 130 | ```c# 131 | 132 | public class RustObject{ 133 | 134 | private System.IntPtr _rawPtr; 135 | 136 | public RustObject(){ 137 | _rawPtr = rust_object_new(); 138 | } 139 | 140 | private void Dispose() 141 | { 142 | if(_rawPtr != System.IntPtr.Zero){ 143 | rust_object_dispose(_rawPtr); 144 | _rawPtr = System.IntPtr.Zero; 145 | } 146 | } 147 | ~RustObject(){ 148 | Dispose(); 149 | } 150 | [DllImport("unity_rust")] 151 | internal static extern System.IntPtr rust_object_new(); 152 | 153 | [DllImport("unity_rust")] 154 | internal static extern void rust_object_dispose(System.IntPtr rawPtr); 155 | } 156 | ``` 157 | 158 | # 3. C#访问Rust Struct数据 159 | 160 | 在前面我们已经成功让c#拥有了一个Rust Struct对象的所有权。接下来要访问和修改这个对象的数据。这里有两种实现方式,下面依次介绍: 161 | 162 | ## 3.1 C# Safe的方式 163 | 164 | 首先在Rust端定义set/get函数如下: 165 | 166 | ```rust 167 | #[no_mangle] 168 | pub extern fn rust_object_set_value(ptr: * mut RustObject,val:f32){ 169 | let obj = unsafe{ 170 | ptr.as_mut().expect("invalid ptr") 171 | }; 172 | obj.val = val; 173 | } 174 | 175 | #[no_mangle] 176 | extern fn rust_object_get_value(ptr: * const RustObject)->f32{ 177 | let obj = unsafe { 178 | ptr.as_ref().expect("invalid ptr") 179 | }; 180 | return obj.val; 181 | } 182 | ``` 183 | 184 | 这两个函数均接受`RustObject*`指针作为首个参数,然后对其字段进行赋值或者读取。 185 | 186 | c#端声明如下: 187 | 188 | ```c# 189 | [DllImport("unity_rust")] 190 | private static extern void rust_object_set_value(System.IntPtr ptr,float val); 191 | 192 | [DllImport("unity_rust")] 193 | private static extern float rust_object_get_value(System.IntPtr ptr); 194 | ``` 195 | 196 | 然后封装一个属性访问: 197 | 198 | ```c# 199 | public float val{ 200 | get{ 201 | return rust_object_get_value(_rawPtr); 202 | }set{ 203 | rust_object_set_value(_rawPtr,value); 204 | } 205 | } 206 | ``` 207 | 208 | ## 3.2 C# Unsafe 方式 209 | 210 | 在c#我们定义一个struct如下: 211 | 212 | ```c# 213 | [StructLayout(LayoutKind.Sequential)] 214 | public struct RustObjectNative{ 215 | public float val; 216 | } 217 | ``` 218 | 注意这里的内存布局使用`LayoutKind.Sequential`. 219 | 220 | 同时rust端的struct也要加上attribute - `#[repr(C)]`: 221 | 222 | ```rust 223 | #[repr(C)] 224 | pub struct RustObject{ 225 | pub val:f32 226 | } 227 | ``` 228 | 229 | 这样我们就保证了两者的内存布局一致。 230 | 231 | 然后在c#端,可以直接将rust返回的指针`System.IntPtr`转为`RustObjectNative*`指针: 232 | 233 | ```c# 234 | private unsafe RustObjectNative* pointer{ 235 | get{ 236 | return (RustObjectNative*)_rawPtr; 237 | } 238 | } 239 | ``` 240 | 241 | 因为在c#中使用指针是unsafe的行为,所以需要unsafe标记。 242 | 243 | 然后直接对`RustObjectNative*`指针进行数据读写即可: 244 | 245 | ```c# 246 | public float val{ 247 | get{ 248 | unsafe{ 249 | return pointer->val; 250 | } 251 | }set{ 252 | unsafe{ 253 | pointer->val = value; 254 | } 255 | } 256 | } 257 | ``` 258 | 259 | 这种方式读写上应该更高效,但必须保证两端的struct内存对其。 对于比较复杂的对象,或者非自己可以完全掌控的对象可能难以做到这一点。 260 | 261 | # 4. 在Rust里调用C#静态函数 262 | 263 | 某些情况下我们希望在rust中能够执行一些c#端的函数。 例如我们将库集成到unity时,希望能够在rust里调用unity的`Debug.Log`来输出一些调试日志。 264 | 265 | 首先在rust项目里创建mod目录如下: 266 | 267 | - src 268 | - bindings 269 | - `debug.rs` 270 | - `mod.rs` 271 | 272 | `debug.rs`实现如下: 273 | 274 | ```rust 275 | 276 | use std::ffi::CString; 277 | use super::delegates::*; 278 | 279 | static mut _LOG: Option = None; 280 | 281 | pub fn log(data:&str){ 282 | let c_str = CString::new(data).unwrap(); 283 | unsafe{ 284 | _LOG.expect("have not binded")(c_str.as_ptr()); 285 | } 286 | } 287 | 288 | ///在外部语言调用进行绑定 289 | #[no_mangle] 290 | extern fn bind_unityengine_debug_log(func:UnityDVoidString){ 291 | unsafe{ 292 | _LOG = Some(func); 293 | } 294 | } 295 | ``` 296 | 297 | 这里定义了一个静态的变量_LOG,类型为`Option`,其中`UnityDVoidString`是一个函数类型,定义如下: 298 | 299 | ```rust 300 | pub type UnityDVoidString = unsafe extern "C" fn(data: *const c_char); 301 | ``` 302 | 303 | 我们将在c#端,通过调用`bind_unityengine_debug_log`,将c#侧的函数指针传入到rust中,并赋给_LOG变量。 304 | 305 | ```c# 306 | public class DebugBinding{ 307 | /// 308 | /// 调用Register,注册相关函数到rust中 309 | /// 310 | public static void Register(){ 311 | bind_unityengine_debug_log(unity_log); 312 | } 313 | private static void unity_log(string msg){ 314 | UnityEngine.Debug.Log(msg); 315 | } 316 | [DllImport("unity_rust")] 317 | private static unsafe extern void bind_unityengine_debug_log(System.Action func); 318 | } 319 | ``` 320 | 321 | 然后在rust端我们就可以通过如下代码调用debug.log: 322 | 323 | ```rust 324 | crate::bindings::debug::log("hello, i am from rust"); 325 | ``` 326 | 327 | # 5. 在Rust里调用c#成员函数 328 | 329 | 这里将在rust中实现一个简单的GameObject为例。在rust项目中创建: 330 | 331 | - src 332 | - bindings 333 | - `gameobject.rs` 334 | 335 | 定义三个静态变量和相应的绑定函数,分别对应构造、析构、以及`gameObject.SetActive`函数 336 | 337 | ```rust 338 | static mut _CONSTRUCTOR: Option = None; 339 | static mut _DESTRUCTOR:Option = None; 340 | static mut _SET_ACTIVE:Option = None; 341 | 342 | #[no_mangle] 343 | extern fn bind_unityengine_gameobject_constructor(func:UnityDU32){ 344 | unsafe{ 345 | _CONSTRUCTOR = Some(func); 346 | } 347 | } 348 | #[no_mangle] 349 | extern fn bind_unityengine_gameobject_destructor(func:UnityDVoidU32){ 350 | unsafe{ 351 | _DESTRUCTOR = Some(func); 352 | } 353 | } 354 | #[no_mangle] 355 | extern fn bind_unityengine_gameobject_set_active(func:UnityDVoidBool){ 356 | unsafe{ 357 | _SET_ACTIVE = Some(func); 358 | } 359 | } 360 | 361 | ``` 362 | 363 | c#端声明如下: 364 | 365 | ```c# 366 | [DllImport("unity_rust")] 367 | private static unsafe extern void bind_unityengine_gameobject_constructor(System.Func func); 368 | [DllImport("unity_rust")] 369 | private static unsafe extern void bind_unityengine_gameobject_destructor(System.Action func); 370 | [DllImport("unity_rust")] 371 | private static unsafe extern void bind_unityengine_gameobject_set_active(System.Action func); 372 | 373 | ``` 374 | 375 | constructor函数会在c#端创建一个gameObject,将其加入到一个objectCache中,并返回一个uint类型的objectId。 376 | 377 | ```c# 378 | private static uint Constructor(){ 379 | var go = new GameObject(); 380 | var id = ObjectCache.Add(go); 381 | return id; 382 | } 383 | public static void Register(){ 384 | bind_unityengine_gameobject_constructor(Constructor); 385 | //.... 386 | } 387 | ``` 388 | 389 | 我们将这个id返回到rust中,作为c#对象在rust中的一个handle。 390 | 391 | rust中实现GameObject如下: 392 | 393 | ```rust 394 | pub struct GameObject{ 395 | _unity_object_id:u32, //c# object handle 396 | } 397 | impl GameObject { 398 | pub fn new()->GameObject{ 399 | unsafe{ 400 | let handle = _CONSTRUCTOR.expect("GameObject have not binded")(); 401 | return GameObject{ 402 | _unity_object_id:handle, 403 | } 404 | } 405 | } 406 | } 407 | ``` 408 | 409 | 我们通过调用`_CONSTRUCTOR()`,在c#端创建一个gameObject,并在rust里拿到这个对象的id。然后在rust中用一个同名的`struct GameObject`对象包裹住这个`object_id`. 410 | 411 | 我们可以通过如下代码在rust中创建gameObject: 412 | 413 | ```rust 414 | let go = GameObject::new(); 415 | ``` 416 | 417 | 那么当rust中这个go对象被回收时,我们自然需要在c#端的ObjectCache中做同步移除。否则就会有内存泄露。 418 | 419 | 因此可以在rust中为GameObject这个struct实现Drop Trait: 420 | 421 | ```rust 422 | 423 | impl Drop for GameObject{ 424 | fn drop(&mut self) { 425 | unsafe{ 426 | _DESTRUCTOR.expect("GameObject have not binded")(self._unity_object_id); 427 | } 428 | } 429 | } 430 | ``` 431 | 432 | 当rust中go对象因为超出作用域而被回收时,会自动触发drop。在drop函数中通过调用c#侧的_DESTRUCTOR函数,实现将对象从ObjectCache中移除。_DESTRUCTOR在c#端实现如下: 433 | 434 | ```c# 435 | private static void Destructor(uint objectId){ 436 | ObjectCache.Remove(objectId); 437 | } 438 | public static void Register(){ 439 | //.... 440 | bind_unityengine_gameobject_destructor(Destructor); 441 | } 442 | 443 | ``` 444 | 445 | 这样我们就成功通过rust中的生命周期机制,实现了对c#对象的引用管理。 446 | 447 | 接下来以实现gameObject.SetActive这个函数为例,rust中实现如下 448 | 449 | ```rust 450 | impl GameObject { 451 | //..... 452 | pub fn set_active(&mut self,value:bool){ 453 | unsafe{ 454 | _SET_ACTIVE.expect("GameObject have not binded")(self._unity_object_id,value); 455 | } 456 | } 457 | //.... 458 | } 459 | ``` 460 | 461 | c#端对应的_SET_ACTIVE函数: 462 | 463 | ```c# 464 | private static void SetActive(uint objectId,bool val){ 465 | ObjectCache.Get(objectId).SetActive(val); 466 | } 467 | public static void Register(){ 468 | //..... 469 | bind_unityengine_gameobject_set_active(SetActive); 470 | } 471 | ``` 472 | 473 | 然后在rust中就可以通过如下方式进行调用: 474 | 475 | ```rust 476 | let mut go = GameObject::new(); 477 | go.set_active(false); 478 | ``` 479 | 480 | # 6. 在Rust中更新Mesh 481 | 482 | To be Written 483 | 484 | # 7. 总结 485 | 486 | 以上就是在Unity中使用Rust与C#交互的过程。在绝大多数用例里,应该都是通过c#调用rust来完成高性能计算,rust调用c#多数是用在callback的时候。剩下把c#对象绑定到rust中这种行为,似乎没有什么有用的场景。 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | -------------------------------------------------------------------------------- /UnityRust/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 22 7 | productGUID: b4903153a85f84335bce6c59e2bbd323 8 | AndroidProfiler: 0 9 | AndroidFilterTouchesWhenObscured: 0 10 | AndroidEnableSustainedPerformanceMode: 0 11 | defaultScreenOrientation: 4 12 | targetDevice: 2 13 | useOnDemandResources: 0 14 | accelerometerFrequency: 60 15 | companyName: DefaultCompany 16 | productName: UnityRust 17 | defaultCursor: {fileID: 0} 18 | cursorHotspot: {x: 0, y: 0} 19 | m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} 20 | m_ShowUnitySplashScreen: 1 21 | m_ShowUnitySplashLogo: 1 22 | m_SplashScreenOverlayOpacity: 1 23 | m_SplashScreenAnimation: 1 24 | m_SplashScreenLogoStyle: 1 25 | m_SplashScreenDrawMode: 0 26 | m_SplashScreenBackgroundAnimationZoom: 1 27 | m_SplashScreenLogoAnimationZoom: 1 28 | m_SplashScreenBackgroundLandscapeAspect: 1 29 | m_SplashScreenBackgroundPortraitAspect: 1 30 | m_SplashScreenBackgroundLandscapeUvs: 31 | serializedVersion: 2 32 | x: 0 33 | y: 0 34 | width: 1 35 | height: 1 36 | m_SplashScreenBackgroundPortraitUvs: 37 | serializedVersion: 2 38 | x: 0 39 | y: 0 40 | width: 1 41 | height: 1 42 | m_SplashScreenLogos: [] 43 | m_VirtualRealitySplashScreen: {fileID: 0} 44 | m_ShowUnitySplashAds: 0 45 | m_AdsAndroidGameId: 46 | m_AdsIosGameId: 47 | m_ShowSplashAdsSlogan: 0 48 | m_SloganImage: {fileID: 0} 49 | m_SloganHeight: 150 50 | m_HolographicTrackingLossScreen: {fileID: 0} 51 | defaultScreenWidth: 1024 52 | defaultScreenHeight: 768 53 | defaultScreenWidthWeb: 960 54 | defaultScreenHeightWeb: 600 55 | m_StereoRenderingPath: 0 56 | m_ActiveColorSpace: 0 57 | m_MTRendering: 1 58 | mipStripping: 0 59 | numberOfMipsStripped: 0 60 | m_StackTraceTypes: 010000000100000001000000010000000100000001000000 61 | iosShowActivityIndicatorOnLoading: -1 62 | androidShowActivityIndicatorOnLoading: -1 63 | iosUseCustomAppBackgroundBehavior: 0 64 | iosAllowHTTPDownload: 1 65 | allowedAutorotateToPortrait: 1 66 | allowedAutorotateToPortraitUpsideDown: 1 67 | allowedAutorotateToLandscapeRight: 1 68 | allowedAutorotateToLandscapeLeft: 1 69 | useOSAutorotation: 1 70 | use32BitDisplayBuffer: 1 71 | preserveFramebufferAlpha: 0 72 | disableDepthAndStencilBuffers: 0 73 | androidStartInFullscreen: 1 74 | androidRenderOutsideSafeArea: 1 75 | androidUseSwappy: 0 76 | androidBlitType: 0 77 | androidResizableWindow: 0 78 | androidDefaultWindowWidth: 1920 79 | androidDefaultWindowHeight: 1080 80 | androidMinimumWindowWidth: 400 81 | androidMinimumWindowHeight: 300 82 | androidFullscreenMode: 1 83 | defaultIsNativeResolution: 1 84 | macRetinaSupport: 1 85 | runInBackground: 1 86 | captureSingleScreen: 0 87 | muteOtherAudioSources: 0 88 | Prepare IOS For Recording: 0 89 | Force IOS Speakers When Recording: 0 90 | deferSystemGesturesMode: 0 91 | hideHomeButton: 0 92 | submitAnalytics: 1 93 | usePlayerLog: 1 94 | autoStreaming: 0 95 | useAnimationStreaming: 0 96 | useFontStreaming: 0 97 | autoStreamingId: 98 | instantGameAppId: 99 | bakeCollisionMeshes: 0 100 | forceSingleInstance: 0 101 | useFlipModelSwapchain: 1 102 | resizableWindow: 0 103 | useMacAppStoreValidation: 0 104 | macAppStoreCategory: public.app-category.games 105 | gpuSkinning: 1 106 | xboxPIXTextureCapture: 0 107 | xboxEnableAvatar: 0 108 | xboxEnableKinect: 0 109 | xboxEnableKinectAutoTracking: 0 110 | xboxEnableFitness: 0 111 | visibleInBackground: 1 112 | allowFullscreenSwitch: 1 113 | fullscreenMode: 1 114 | xboxSpeechDB: 0 115 | xboxEnableHeadOrientation: 0 116 | xboxEnableGuest: 0 117 | xboxEnablePIXSampling: 0 118 | metalFramebufferOnly: 0 119 | xboxOneResolution: 0 120 | xboxOneSResolution: 0 121 | xboxOneXResolution: 3 122 | xboxOneMonoLoggingLevel: 0 123 | xboxOneLoggingLevel: 1 124 | xboxOneDisableEsram: 0 125 | xboxOneEnableTypeOptimization: 0 126 | xboxOnePresentImmediateThreshold: 0 127 | switchQueueCommandMemory: 0 128 | switchQueueControlMemory: 16384 129 | switchQueueComputeMemory: 262144 130 | switchNVNShaderPoolsGranularity: 33554432 131 | switchNVNDefaultPoolsGranularity: 16777216 132 | switchNVNOtherPoolsGranularity: 16777216 133 | switchNVNMaxPublicTextureIDCount: 0 134 | switchNVNMaxPublicSamplerIDCount: 0 135 | stadiaPresentMode: 0 136 | stadiaTargetFramerate: 0 137 | vulkanNumSwapchainBuffers: 3 138 | vulkanEnableSetSRGBWrite: 0 139 | vulkanEnablePreTransform: 0 140 | vulkanEnableLateAcquireNextImage: 0 141 | m_SupportedAspectRatios: 142 | 4:3: 1 143 | 5:4: 1 144 | 16:10: 1 145 | 16:9: 1 146 | Others: 1 147 | bundleVersion: 0.1 148 | preloadedAssets: [] 149 | metroInputSource: 0 150 | wsaTransparentSwapchain: 0 151 | m_HolographicPauseOnTrackingLoss: 1 152 | xboxOneDisableKinectGpuReservation: 1 153 | xboxOneEnable7thCore: 1 154 | vrSettings: 155 | enable360StereoCapture: 0 156 | isWsaHolographicRemotingEnabled: 0 157 | enableFrameTimingStats: 0 158 | useHDRDisplay: 0 159 | D3DHDRBitDepth: 0 160 | m_ColorGamuts: 00000000 161 | targetPixelDensity: 30 162 | resolutionScalingMode: 0 163 | androidSupportedAspectRatio: 1 164 | androidMaxAspectRatio: 2.1 165 | applicationIdentifier: 166 | Standalone: com.DefaultCompany.UnityRust 167 | buildNumber: 168 | Standalone: 0 169 | iPhone: 0 170 | tvOS: 0 171 | overrideDefaultApplicationIdentifier: 0 172 | AndroidBundleVersionCode: 1 173 | AndroidMinSdkVersion: 19 174 | AndroidTargetSdkVersion: 0 175 | AndroidPreferredInstallLocation: 1 176 | aotOptions: 177 | stripEngineCode: 1 178 | iPhoneStrippingLevel: 0 179 | iPhoneScriptCallOptimization: 0 180 | ForceInternetPermission: 0 181 | ForceSDCardPermission: 0 182 | CreateWallpaper: 0 183 | APKExpansionFiles: 0 184 | keepLoadedShadersAlive: 0 185 | StripUnusedMeshComponents: 1 186 | VertexChannelCompressionMask: 4054 187 | iPhoneSdkVersion: 988 188 | iOSTargetOSVersionString: 11.0 189 | tvOSSdkVersion: 0 190 | tvOSRequireExtendedGameController: 0 191 | tvOSTargetOSVersionString: 11.0 192 | uIPrerenderedIcon: 0 193 | uIRequiresPersistentWiFi: 0 194 | uIRequiresFullScreen: 1 195 | uIStatusBarHidden: 1 196 | uIExitOnSuspend: 0 197 | uIStatusBarStyle: 0 198 | appleTVSplashScreen: {fileID: 0} 199 | appleTVSplashScreen2x: {fileID: 0} 200 | tvOSSmallIconLayers: [] 201 | tvOSSmallIconLayers2x: [] 202 | tvOSLargeIconLayers: [] 203 | tvOSLargeIconLayers2x: [] 204 | tvOSTopShelfImageLayers: [] 205 | tvOSTopShelfImageLayers2x: [] 206 | tvOSTopShelfImageWideLayers: [] 207 | tvOSTopShelfImageWideLayers2x: [] 208 | iOSLaunchScreenType: 0 209 | iOSLaunchScreenPortrait: {fileID: 0} 210 | iOSLaunchScreenLandscape: {fileID: 0} 211 | iOSLaunchScreenBackgroundColor: 212 | serializedVersion: 2 213 | rgba: 0 214 | iOSLaunchScreenFillPct: 100 215 | iOSLaunchScreenSize: 100 216 | iOSLaunchScreenCustomXibPath: 217 | iOSLaunchScreeniPadType: 0 218 | iOSLaunchScreeniPadImage: {fileID: 0} 219 | iOSLaunchScreeniPadBackgroundColor: 220 | serializedVersion: 2 221 | rgba: 0 222 | iOSLaunchScreeniPadFillPct: 100 223 | iOSLaunchScreeniPadSize: 100 224 | iOSLaunchScreeniPadCustomXibPath: 225 | iOSLaunchScreenCustomStoryboardPath: 226 | iOSLaunchScreeniPadCustomStoryboardPath: 227 | iOSDeviceRequirements: [] 228 | iOSURLSchemes: [] 229 | iOSBackgroundModes: 0 230 | iOSMetalForceHardShadows: 0 231 | metalEditorSupport: 1 232 | metalAPIValidation: 1 233 | iOSRenderExtraFrameOnPause: 0 234 | iosCopyPluginsCodeInsteadOfSymlink: 0 235 | appleDeveloperTeamID: 236 | iOSManualSigningProvisioningProfileID: 237 | tvOSManualSigningProvisioningProfileID: 238 | iOSManualSigningProvisioningProfileType: 0 239 | tvOSManualSigningProvisioningProfileType: 0 240 | appleEnableAutomaticSigning: 0 241 | iOSRequireARKit: 0 242 | iOSAutomaticallyDetectAndAddCapabilities: 1 243 | appleEnableProMotion: 0 244 | shaderPrecisionModel: 0 245 | clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea 246 | templatePackageId: com.unity.template.3d@4.2.8 247 | templateDefaultScene: Assets/Scenes/SampleScene.unity 248 | useCustomMainManifest: 0 249 | useCustomLauncherManifest: 0 250 | useCustomMainGradleTemplate: 0 251 | useCustomLauncherGradleManifest: 0 252 | useCustomBaseGradleTemplate: 0 253 | useCustomGradlePropertiesTemplate: 0 254 | useCustomProguardFile: 0 255 | AndroidTargetArchitectures: 1 256 | AndroidTargetDevices: 0 257 | AndroidSplashScreenScale: 0 258 | androidSplashScreen: {fileID: 0} 259 | AndroidKeystoreName: 260 | AndroidKeyaliasName: 261 | AndroidBuildApkPerCpuArchitecture: 0 262 | AndroidTVCompatibility: 0 263 | AndroidIsGame: 1 264 | AndroidEnableTango: 0 265 | androidEnableBanner: 1 266 | androidUseLowAccuracyLocation: 0 267 | androidUseCustomKeystore: 0 268 | m_AndroidBanners: 269 | - width: 320 270 | height: 180 271 | banner: {fileID: 0} 272 | androidGamepadSupportLevel: 0 273 | chromeosInputEmulation: 1 274 | AndroidMinifyWithR8: 0 275 | AndroidMinifyRelease: 0 276 | AndroidMinifyDebug: 0 277 | AndroidValidateAppBundleSize: 1 278 | AndroidAppBundleSizeToValidate: 150 279 | m_BuildTargetIcons: [] 280 | m_BuildTargetPlatformIcons: [] 281 | m_BuildTargetBatching: 282 | - m_BuildTarget: Standalone 283 | m_StaticBatching: 1 284 | m_DynamicBatching: 0 285 | - m_BuildTarget: tvOS 286 | m_StaticBatching: 1 287 | m_DynamicBatching: 0 288 | - m_BuildTarget: Android 289 | m_StaticBatching: 1 290 | m_DynamicBatching: 0 291 | - m_BuildTarget: iPhone 292 | m_StaticBatching: 1 293 | m_DynamicBatching: 0 294 | - m_BuildTarget: WebGL 295 | m_StaticBatching: 0 296 | m_DynamicBatching: 0 297 | m_BuildTargetGraphicsJobs: 298 | - m_BuildTarget: MacStandaloneSupport 299 | m_GraphicsJobs: 0 300 | - m_BuildTarget: Switch 301 | m_GraphicsJobs: 1 302 | - m_BuildTarget: MetroSupport 303 | m_GraphicsJobs: 1 304 | - m_BuildTarget: AppleTVSupport 305 | m_GraphicsJobs: 0 306 | - m_BuildTarget: BJMSupport 307 | m_GraphicsJobs: 1 308 | - m_BuildTarget: LinuxStandaloneSupport 309 | m_GraphicsJobs: 1 310 | - m_BuildTarget: PS4Player 311 | m_GraphicsJobs: 1 312 | - m_BuildTarget: iOSSupport 313 | m_GraphicsJobs: 0 314 | - m_BuildTarget: WindowsStandaloneSupport 315 | m_GraphicsJobs: 1 316 | - m_BuildTarget: XboxOnePlayer 317 | m_GraphicsJobs: 1 318 | - m_BuildTarget: LuminSupport 319 | m_GraphicsJobs: 0 320 | - m_BuildTarget: AndroidPlayer 321 | m_GraphicsJobs: 0 322 | - m_BuildTarget: WebGLSupport 323 | m_GraphicsJobs: 0 324 | m_BuildTargetGraphicsJobMode: 325 | - m_BuildTarget: PS4Player 326 | m_GraphicsJobMode: 0 327 | - m_BuildTarget: XboxOnePlayer 328 | m_GraphicsJobMode: 0 329 | m_BuildTargetGraphicsAPIs: 330 | - m_BuildTarget: AndroidPlayer 331 | m_APIs: 150000000b000000 332 | m_Automatic: 0 333 | - m_BuildTarget: iOSSupport 334 | m_APIs: 10000000 335 | m_Automatic: 1 336 | - m_BuildTarget: AppleTVSupport 337 | m_APIs: 10000000 338 | m_Automatic: 1 339 | - m_BuildTarget: WebGLSupport 340 | m_APIs: 0b000000 341 | m_Automatic: 1 342 | m_BuildTargetVRSettings: 343 | - m_BuildTarget: Standalone 344 | m_Enabled: 0 345 | m_Devices: 346 | - Oculus 347 | - OpenVR 348 | openGLRequireES31: 0 349 | openGLRequireES31AEP: 0 350 | openGLRequireES32: 0 351 | m_TemplateCustomTags: {} 352 | mobileMTRendering: 353 | Android: 1 354 | iPhone: 1 355 | tvOS: 1 356 | m_BuildTargetGroupLightmapEncodingQuality: [] 357 | m_BuildTargetGroupLightmapSettings: [] 358 | m_BuildTargetNormalMapEncoding: [] 359 | playModeTestRunnerEnabled: 0 360 | runPlayModeTestAsEditModeTest: 0 361 | actionOnDotNetUnhandledException: 1 362 | enableInternalProfiler: 0 363 | logObjCUncaughtExceptions: 1 364 | enableCrashReportAPI: 0 365 | cameraUsageDescription: 366 | locationUsageDescription: 367 | microphoneUsageDescription: 368 | bluetoothUsageDescription: 369 | switchNMETAOverride: 370 | switchNetLibKey: 371 | switchSocketMemoryPoolSize: 6144 372 | switchSocketAllocatorPoolSize: 128 373 | switchSocketConcurrencyLimit: 14 374 | switchScreenResolutionBehavior: 2 375 | switchUseCPUProfiler: 0 376 | switchUseGOLDLinker: 0 377 | switchApplicationID: 0x01004b9000490000 378 | switchNSODependencies: 379 | switchTitleNames_0: 380 | switchTitleNames_1: 381 | switchTitleNames_2: 382 | switchTitleNames_3: 383 | switchTitleNames_4: 384 | switchTitleNames_5: 385 | switchTitleNames_6: 386 | switchTitleNames_7: 387 | switchTitleNames_8: 388 | switchTitleNames_9: 389 | switchTitleNames_10: 390 | switchTitleNames_11: 391 | switchTitleNames_12: 392 | switchTitleNames_13: 393 | switchTitleNames_14: 394 | switchTitleNames_15: 395 | switchPublisherNames_0: 396 | switchPublisherNames_1: 397 | switchPublisherNames_2: 398 | switchPublisherNames_3: 399 | switchPublisherNames_4: 400 | switchPublisherNames_5: 401 | switchPublisherNames_6: 402 | switchPublisherNames_7: 403 | switchPublisherNames_8: 404 | switchPublisherNames_9: 405 | switchPublisherNames_10: 406 | switchPublisherNames_11: 407 | switchPublisherNames_12: 408 | switchPublisherNames_13: 409 | switchPublisherNames_14: 410 | switchPublisherNames_15: 411 | switchIcons_0: {fileID: 0} 412 | switchIcons_1: {fileID: 0} 413 | switchIcons_2: {fileID: 0} 414 | switchIcons_3: {fileID: 0} 415 | switchIcons_4: {fileID: 0} 416 | switchIcons_5: {fileID: 0} 417 | switchIcons_6: {fileID: 0} 418 | switchIcons_7: {fileID: 0} 419 | switchIcons_8: {fileID: 0} 420 | switchIcons_9: {fileID: 0} 421 | switchIcons_10: {fileID: 0} 422 | switchIcons_11: {fileID: 0} 423 | switchIcons_12: {fileID: 0} 424 | switchIcons_13: {fileID: 0} 425 | switchIcons_14: {fileID: 0} 426 | switchIcons_15: {fileID: 0} 427 | switchSmallIcons_0: {fileID: 0} 428 | switchSmallIcons_1: {fileID: 0} 429 | switchSmallIcons_2: {fileID: 0} 430 | switchSmallIcons_3: {fileID: 0} 431 | switchSmallIcons_4: {fileID: 0} 432 | switchSmallIcons_5: {fileID: 0} 433 | switchSmallIcons_6: {fileID: 0} 434 | switchSmallIcons_7: {fileID: 0} 435 | switchSmallIcons_8: {fileID: 0} 436 | switchSmallIcons_9: {fileID: 0} 437 | switchSmallIcons_10: {fileID: 0} 438 | switchSmallIcons_11: {fileID: 0} 439 | switchSmallIcons_12: {fileID: 0} 440 | switchSmallIcons_13: {fileID: 0} 441 | switchSmallIcons_14: {fileID: 0} 442 | switchSmallIcons_15: {fileID: 0} 443 | switchManualHTML: 444 | switchAccessibleURLs: 445 | switchLegalInformation: 446 | switchMainThreadStackSize: 1048576 447 | switchPresenceGroupId: 448 | switchLogoHandling: 0 449 | switchReleaseVersion: 0 450 | switchDisplayVersion: 1.0.0 451 | switchStartupUserAccount: 0 452 | switchTouchScreenUsage: 0 453 | switchSupportedLanguagesMask: 0 454 | switchLogoType: 0 455 | switchApplicationErrorCodeCategory: 456 | switchUserAccountSaveDataSize: 0 457 | switchUserAccountSaveDataJournalSize: 0 458 | switchApplicationAttribute: 0 459 | switchCardSpecSize: -1 460 | switchCardSpecClock: -1 461 | switchRatingsMask: 0 462 | switchRatingsInt_0: 0 463 | switchRatingsInt_1: 0 464 | switchRatingsInt_2: 0 465 | switchRatingsInt_3: 0 466 | switchRatingsInt_4: 0 467 | switchRatingsInt_5: 0 468 | switchRatingsInt_6: 0 469 | switchRatingsInt_7: 0 470 | switchRatingsInt_8: 0 471 | switchRatingsInt_9: 0 472 | switchRatingsInt_10: 0 473 | switchRatingsInt_11: 0 474 | switchRatingsInt_12: 0 475 | switchLocalCommunicationIds_0: 476 | switchLocalCommunicationIds_1: 477 | switchLocalCommunicationIds_2: 478 | switchLocalCommunicationIds_3: 479 | switchLocalCommunicationIds_4: 480 | switchLocalCommunicationIds_5: 481 | switchLocalCommunicationIds_6: 482 | switchLocalCommunicationIds_7: 483 | switchParentalControl: 0 484 | switchAllowsScreenshot: 1 485 | switchAllowsVideoCapturing: 1 486 | switchAllowsRuntimeAddOnContentInstall: 0 487 | switchDataLossConfirmation: 0 488 | switchUserAccountLockEnabled: 0 489 | switchSystemResourceMemory: 16777216 490 | switchSupportedNpadStyles: 22 491 | switchNativeFsCacheSize: 32 492 | switchIsHoldTypeHorizontal: 0 493 | switchSupportedNpadCount: 8 494 | switchSocketConfigEnabled: 0 495 | switchTcpInitialSendBufferSize: 32 496 | switchTcpInitialReceiveBufferSize: 64 497 | switchTcpAutoSendBufferSizeMax: 256 498 | switchTcpAutoReceiveBufferSizeMax: 256 499 | switchUdpSendBufferSize: 9 500 | switchUdpReceiveBufferSize: 42 501 | switchSocketBufferEfficiency: 4 502 | switchSocketInitializeEnabled: 1 503 | switchNetworkInterfaceManagerInitializeEnabled: 1 504 | switchPlayerConnectionEnabled: 1 505 | switchUseNewStyleFilepaths: 0 506 | switchUseMicroSleepForYield: 1 507 | switchMicroSleepForYieldTime: 25 508 | ps4NPAgeRating: 12 509 | ps4NPTitleSecret: 510 | ps4NPTrophyPackPath: 511 | ps4ParentalLevel: 11 512 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000 513 | ps4Category: 0 514 | ps4MasterVersion: 01.00 515 | ps4AppVersion: 01.00 516 | ps4AppType: 0 517 | ps4ParamSfxPath: 518 | ps4VideoOutPixelFormat: 0 519 | ps4VideoOutInitialWidth: 1920 520 | ps4VideoOutBaseModeInitialWidth: 1920 521 | ps4VideoOutReprojectionRate: 60 522 | ps4PronunciationXMLPath: 523 | ps4PronunciationSIGPath: 524 | ps4BackgroundImagePath: 525 | ps4StartupImagePath: 526 | ps4StartupImagesFolder: 527 | ps4IconImagesFolder: 528 | ps4SaveDataImagePath: 529 | ps4SdkOverride: 530 | ps4BGMPath: 531 | ps4ShareFilePath: 532 | ps4ShareOverlayImagePath: 533 | ps4PrivacyGuardImagePath: 534 | ps4ExtraSceSysFile: 535 | ps4NPtitleDatPath: 536 | ps4RemotePlayKeyAssignment: -1 537 | ps4RemotePlayKeyMappingDir: 538 | ps4PlayTogetherPlayerCount: 0 539 | ps4EnterButtonAssignment: 1 540 | ps4ApplicationParam1: 0 541 | ps4ApplicationParam2: 0 542 | ps4ApplicationParam3: 0 543 | ps4ApplicationParam4: 0 544 | ps4DownloadDataSize: 0 545 | ps4GarlicHeapSize: 2048 546 | ps4ProGarlicHeapSize: 2560 547 | playerPrefsMaxSize: 32768 548 | ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ 549 | ps4pnSessions: 1 550 | ps4pnPresence: 1 551 | ps4pnFriends: 1 552 | ps4pnGameCustomData: 1 553 | playerPrefsSupport: 0 554 | enableApplicationExit: 0 555 | resetTempFolder: 1 556 | restrictedAudioUsageRights: 0 557 | ps4UseResolutionFallback: 0 558 | ps4ReprojectionSupport: 0 559 | ps4UseAudio3dBackend: 0 560 | ps4UseLowGarlicFragmentationMode: 1 561 | ps4SocialScreenEnabled: 0 562 | ps4ScriptOptimizationLevel: 0 563 | ps4Audio3dVirtualSpeakerCount: 14 564 | ps4attribCpuUsage: 0 565 | ps4PatchPkgPath: 566 | ps4PatchLatestPkgPath: 567 | ps4PatchChangeinfoPath: 568 | ps4PatchDayOne: 0 569 | ps4attribUserManagement: 0 570 | ps4attribMoveSupport: 0 571 | ps4attrib3DSupport: 0 572 | ps4attribShareSupport: 0 573 | ps4attribExclusiveVR: 0 574 | ps4disableAutoHideSplash: 0 575 | ps4videoRecordingFeaturesUsed: 0 576 | ps4contentSearchFeaturesUsed: 0 577 | ps4CompatibilityPS5: 0 578 | ps4AllowPS5Detection: 0 579 | ps4GPU800MHz: 1 580 | ps4attribEyeToEyeDistanceSettingVR: 0 581 | ps4IncludedModules: [] 582 | ps4attribVROutputEnabled: 0 583 | monoEnv: 584 | splashScreenBackgroundSourceLandscape: {fileID: 0} 585 | splashScreenBackgroundSourcePortrait: {fileID: 0} 586 | blurSplashScreenBackground: 1 587 | spritePackerPolicy: 588 | webGLMemorySize: 16 589 | webGLExceptionSupport: 1 590 | webGLNameFilesAsHashes: 0 591 | webGLDataCaching: 1 592 | webGLDebugSymbols: 0 593 | webGLEmscriptenArgs: 594 | webGLModulesDirectory: 595 | webGLTemplate: APPLICATION:Default 596 | webGLAnalyzeBuildSize: 0 597 | webGLUseEmbeddedResources: 0 598 | webGLCompressionFormat: 1 599 | webGLWasmArithmeticExceptions: 0 600 | webGLLinkerTarget: 1 601 | webGLThreadsSupport: 0 602 | webGLDecompressionFallback: 0 603 | scriptingDefineSymbols: {} 604 | additionalCompilerArguments: {} 605 | platformArchitecture: {} 606 | scriptingBackend: {} 607 | il2cppCompilerConfiguration: {} 608 | managedStrippingLevel: {} 609 | incrementalIl2cppBuild: {} 610 | suppressCommonWarnings: 1 611 | allowUnsafeCode: 1 612 | useDeterministicCompilation: 1 613 | useReferenceAssemblies: 1 614 | enableRoslynAnalyzers: 1 615 | additionalIl2CppArgs: 616 | scriptingRuntimeVersion: 1 617 | gcIncremental: 0 618 | assemblyVersionValidation: 1 619 | gcWBarrierValidation: 0 620 | apiCompatibilityLevelPerPlatform: {} 621 | m_RenderingPath: 1 622 | m_MobileRenderingPath: 1 623 | metroPackageName: Template_3D 624 | metroPackageVersion: 625 | metroCertificatePath: 626 | metroCertificatePassword: 627 | metroCertificateSubject: 628 | metroCertificateIssuer: 629 | metroCertificateNotAfter: 0000000000000000 630 | metroApplicationDescription: Template_3D 631 | wsaImages: {} 632 | metroTileShortName: 633 | metroTileShowName: 0 634 | metroMediumTileShowName: 0 635 | metroLargeTileShowName: 0 636 | metroWideTileShowName: 0 637 | metroSupportStreamingInstall: 0 638 | metroLastRequiredScene: 0 639 | metroDefaultTileSize: 1 640 | metroTileForegroundText: 2 641 | metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} 642 | metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, 643 | a: 1} 644 | metroSplashScreenUseBackgroundColor: 0 645 | platformCapabilities: {} 646 | metroTargetDeviceFamilies: {} 647 | metroFTAName: 648 | metroFTAFileTypes: [] 649 | metroProtocolName: 650 | XboxOneProductId: 651 | XboxOneUpdateKey: 652 | XboxOneSandboxId: 653 | XboxOneContentId: 654 | XboxOneTitleId: 655 | XboxOneSCId: 656 | XboxOneGameOsOverridePath: 657 | XboxOnePackagingOverridePath: 658 | XboxOneAppManifestOverridePath: 659 | XboxOneVersion: 1.0.0.0 660 | XboxOnePackageEncryption: 0 661 | XboxOnePackageUpdateGranularity: 2 662 | XboxOneDescription: 663 | XboxOneLanguage: 664 | - enus 665 | XboxOneCapability: [] 666 | XboxOneGameRating: {} 667 | XboxOneIsContentPackage: 0 668 | XboxOneEnhancedXboxCompatibilityMode: 0 669 | XboxOneEnableGPUVariability: 1 670 | XboxOneSockets: {} 671 | XboxOneSplashScreen: {fileID: 0} 672 | XboxOneAllowedProductIds: [] 673 | XboxOnePersistentLocalStorageSize: 0 674 | XboxOneXTitleMemory: 8 675 | XboxOneOverrideIdentityName: 676 | XboxOneOverrideIdentityPublisher: 677 | vrEditorSettings: {} 678 | cloudServicesEnabled: 679 | UNet: 1 680 | luminIcon: 681 | m_Name: 682 | m_ModelFolderPath: 683 | m_PortalFolderPath: 684 | luminCert: 685 | m_CertPath: 686 | m_SignPackage: 1 687 | luminIsChannelApp: 0 688 | luminVersion: 689 | m_VersionCode: 1 690 | m_VersionName: 691 | apiCompatibilityLevel: 6 692 | activeInputHandler: 0 693 | cloudProjectId: 694 | framebufferDepthMemorylessMode: 0 695 | qualitySettingsNames: [] 696 | projectName: 697 | organizationId: 698 | cloudEnabled: 0 699 | legacyClampBlendShapeWeights: 0 700 | virtualTexturingSupportEnabled: 0 701 | --------------------------------------------------------------------------------