diff --git a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs index d312f64b2..81ca1af34 100644 --- a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs @@ -525,7 +525,7 @@ namespace FlaxEditor.CustomEditors.Dedicated var restored = actor.AddScript(removed.PrefabObject.GetType()); var prefabId = actor.PrefabID; var prefabObjectId = restored.PrefabObjectID; - Script.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), ref prefabId, ref prefabObjectId); + Script.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), prefabId, prefabObjectId); string data = JsonSerializer.Serialize(removed.PrefabObject); JsonSerializer.Deserialize(restored, data); @@ -547,7 +547,7 @@ namespace FlaxEditor.CustomEditors.Dedicated string data = JsonSerializer.Serialize(removedActor.PrefabObject); JsonSerializer.Deserialize(restored, data); Presenter.Owner.SceneContext.Spawn(restored, parentActor, removedActor.OrderInParent); - Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), ref prefabId, ref prefabObjectId); + Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(restored), prefabId, prefabObjectId); return; } diff --git a/Source/Editor/SceneGraph/Actors/CameraNode.cs b/Source/Editor/SceneGraph/Actors/CameraNode.cs index 8f50b6284..853e140b7 100644 --- a/Source/Editor/SceneGraph/Actors/CameraNode.cs +++ b/Source/Editor/SceneGraph/Actors/CameraNode.cs @@ -56,7 +56,7 @@ namespace FlaxEditor.SceneGraph.Actors return false; } - return Camera.Internal_IntersectsItselfEditor(FlaxEngine.Object.GetUnmanagedPtr(_actor), ref ray.Ray, out distance); + return Camera.Internal_IntersectsItselfEditor(FlaxEngine.Object.GetUnmanagedPtr(_actor), ray.Ray, out distance); } /// diff --git a/Source/Editor/Undo/Actions/AddRemoveScriptAction.cs b/Source/Editor/Undo/Actions/AddRemoveScriptAction.cs index 5374cf009..6578b58c9 100644 --- a/Source/Editor/Undo/Actions/AddRemoveScriptAction.cs +++ b/Source/Editor/Undo/Actions/AddRemoveScriptAction.cs @@ -191,7 +191,7 @@ namespace FlaxEditor.Actions script.OrderInParent = _orderInParent; _orderInParent = script.OrderInParent; // Ensure order is correct for script that want to use it later if (_prefabObjectId != Guid.Empty) - SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(script), ref _prefabId, ref _prefabObjectId); + SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(script), _prefabId, _prefabObjectId); Editor.Instance.Scene.MarkSceneEdited(parentActor.Scene); } } diff --git a/Source/Editor/Undo/Actions/BreakPrefabLinkAction.cs b/Source/Editor/Undo/Actions/BreakPrefabLinkAction.cs index 037e414a1..d3a493b70 100644 --- a/Source/Editor/Undo/Actions/BreakPrefabLinkAction.cs +++ b/Source/Editor/Undo/Actions/BreakPrefabLinkAction.cs @@ -137,7 +137,7 @@ namespace FlaxEditor.Actions var item = items[i]; var obj = Object.Find(ref item.ID); if (obj != null) - SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), ref item.PrefabID, ref item.PrefabObjectID); + SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), item.PrefabID, item.PrefabObjectID); } } diff --git a/Source/Editor/Undo/Actions/DeleteActorsAction.cs b/Source/Editor/Undo/Actions/DeleteActorsAction.cs index 75594ecb9..36450dd5a 100644 --- a/Source/Editor/Undo/Actions/DeleteActorsAction.cs +++ b/Source/Editor/Undo/Actions/DeleteActorsAction.cs @@ -204,7 +204,7 @@ namespace FlaxEditor.Actions Guid prefabId = _prefabIds[i]; if (prefabId != Guid.Empty) { - Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(actors[i]), ref prefabId, ref _prefabObjectIds[i]); + Actor.Internal_LinkPrefab(FlaxEngine.Object.GetUnmanagedPtr(actors[i]), prefabId, _prefabObjectIds[i]); } } } diff --git a/Source/Editor/Undo/Actions/ParentActorsAction.cs b/Source/Editor/Undo/Actions/ParentActorsAction.cs index 312ce578d..5d89b7242 100644 --- a/Source/Editor/Undo/Actions/ParentActorsAction.cs +++ b/Source/Editor/Undo/Actions/ParentActorsAction.cs @@ -183,7 +183,7 @@ namespace FlaxEditor.Actions { var obj = Object.Find(ref _idsForPrefab[i]); if (obj != null && _prefabIds[i] != Guid.Empty) - SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), ref _prefabIds[i], ref _prefabObjectIds[i]); + SceneObject.Internal_LinkPrefab(Object.GetUnmanagedPtr(obj), _prefabIds[i], _prefabObjectIds[i]); } } } diff --git a/Source/Engine/Level/Actor.cs b/Source/Engine/Level/Actor.cs index 0670c5f2f..51b24e25f 100644 --- a/Source/Engine/Level/Actor.cs +++ b/Source/Engine/Level/Actor.cs @@ -80,7 +80,7 @@ namespace FlaxEngine set { Quaternion.Euler(ref value, out var orientation); - Internal_SetOrientation(__unmanagedPtr, ref orientation); + Internal_SetOrientation(__unmanagedPtr, orientation); } } @@ -98,7 +98,7 @@ namespace FlaxEngine set { Quaternion.Euler(ref value, out var orientation); - Internal_SetLocalOrientation(__unmanagedPtr, ref orientation); + Internal_SetLocalOrientation(__unmanagedPtr, orientation); } } diff --git a/Source/Engine/Render2D/Render2D.cs b/Source/Engine/Render2D/Render2D.cs index 06eb03d5a..60230b95a 100644 --- a/Source/Engine/Render2D/Render2D.cs +++ b/Source/Engine/Render2D/Render2D.cs @@ -12,7 +12,7 @@ namespace FlaxEngine /// The transformation to apply. public static void PushTransform(Matrix3x3 transform) { - Internal_PushTransform(ref transform); + Internal_PushTransform(transform); } /// @@ -21,7 +21,7 @@ namespace FlaxEngine /// The axis aligned clipping mask rectangle. public static void PushClip(Rectangle clipRect) { - Internal_PushClip(ref clipRect); + Internal_PushClip(clipRect); } /// @@ -32,7 +32,7 @@ namespace FlaxEngine public static void DrawTexture(GPUTextureView rt, Rectangle rect) { var color = Color.White; - Internal_DrawTexture(FlaxEngine.Object.GetUnmanagedPtr(rt), ref rect, ref color); + Internal_DrawTexture(FlaxEngine.Object.GetUnmanagedPtr(rt), rect, color); } /// @@ -43,7 +43,7 @@ namespace FlaxEngine public static void DrawTexture(GPUTexture t, Rectangle rect) { var color = Color.White; - Internal_DrawTexture1(FlaxEngine.Object.GetUnmanagedPtr(t), ref rect, ref color); + Internal_DrawTexture1(FlaxEngine.Object.GetUnmanagedPtr(t), rect, color); } /// @@ -54,7 +54,7 @@ namespace FlaxEngine public static void DrawTexture(TextureBase t, Rectangle rect) { var color = Color.White; - Internal_DrawTexture2(FlaxEngine.Object.GetUnmanagedPtr(t), ref rect, ref color); + Internal_DrawTexture2(FlaxEngine.Object.GetUnmanagedPtr(t), rect, color); } /// @@ -75,7 +75,7 @@ namespace FlaxEngine public static void DrawTexturePoint(GPUTexture t, Rectangle rect) { var color = Color.White; - Internal_DrawTexturePoint(FlaxEngine.Object.GetUnmanagedPtr(t), ref rect, ref color); + Internal_DrawTexturePoint(FlaxEngine.Object.GetUnmanagedPtr(t), rect, color); } /// @@ -96,7 +96,7 @@ namespace FlaxEngine public static void DrawMaterial(MaterialBase material, Rectangle rect) { var color = Color.White; - Internal_DrawMaterial(FlaxEngine.Object.GetUnmanagedPtr(material), ref rect, ref color); + Internal_DrawMaterial(FlaxEngine.Object.GetUnmanagedPtr(material), rect, color); } /// diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cache.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cache.cs index c85410a7a..bb969975b 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cache.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cache.cs @@ -19,7 +19,7 @@ namespace Flax.Build.Bindings partial class BindingsGenerator { private static readonly Dictionary TypeCache = new Dictionary(); - private const int CacheVersion = 23; + private const int CacheVersion = 24; internal static void Write(BinaryWriter writer, string e) { diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs index 14058aaf5..3bd9174a6 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; namespace Flax.Build.Bindings { @@ -1041,7 +1042,12 @@ namespace Flax.Build.Bindings if (isGetter) propertyInfo.Getter = functionInfo; else + { propertyInfo.Setter = functionInfo; + + // Setter value parameter should always be const, forces bindings to pass value as "in" instead of "ref" + CollectionsMarshal.AsSpan(functionInfo.Parameters)[0].IsConst = true; + } propertyInfo.DeprecatedMessage = functionInfo.DeprecatedMessage; propertyInfo.IsHidden |= functionInfo.IsHidden; diff --git a/Source/Tools/Flax.Build/Bindings/ClassInfo.cs b/Source/Tools/Flax.Build/Bindings/ClassInfo.cs index f2d82cc6e..07d0005d7 100644 --- a/Source/Tools/Flax.Build/Bindings/ClassInfo.cs +++ b/Source/Tools/Flax.Build/Bindings/ClassInfo.cs @@ -113,6 +113,7 @@ namespace Flax.Build.Bindings { Name = "value", Type = fieldInfo.Type, + IsConst = true, }, }, IsVirtual = false, diff --git a/Source/Tools/Flax.Build/Bindings/FunctionInfo.cs b/Source/Tools/Flax.Build/Bindings/FunctionInfo.cs index d8b440ccd..c56cb2e63 100644 --- a/Source/Tools/Flax.Build/Bindings/FunctionInfo.cs +++ b/Source/Tools/Flax.Build/Bindings/FunctionInfo.cs @@ -17,6 +17,7 @@ namespace Flax.Build.Bindings public string DefaultValue; public string Attributes; public bool IsRef; + public bool IsConst; public bool IsOut; public bool IsThis; public bool IsParams; @@ -36,6 +37,7 @@ namespace Flax.Build.Bindings BindingsGenerator.Write(writer, Attributes); // TODO: convert into flags writer.Write(IsRef); + writer.Write(IsConst); writer.Write(IsOut); writer.Write(IsThis); writer.Write(IsParams); @@ -49,6 +51,7 @@ namespace Flax.Build.Bindings Attributes = BindingsGenerator.Read(reader, Attributes); // TODO: convert into flags IsRef = reader.ReadBoolean(); + IsConst = reader.ReadBoolean(); IsOut = reader.ReadBoolean(); IsThis = reader.ReadBoolean(); IsParams = reader.ReadBoolean();