Comments (15)
I think it would be better to call the native C++ SetupAttachment
function as the code path in the AttachToComponent
function does seem a little overkill. But to answer where you put that kind of code: https://github.com/pixeltris/USharp/tree/master/Managed/UnrealEngine.Runtime/UnrealEngine.Runtime/Internal/InjectedClasses/Engine these files get copied over when the C# engine wrapper code generator runs.
from usharp.
I simulated SetupAttachment using an extension method
public static class UActorComponentExtensions
{
public static void SetupAttachment(this USceneComponent thisComponent, USceneComponent Parent)
{
thisComponent.AttachToComponent(Parent, FName.None, EAttachmentRule.KeepRelative, EAttachmentRule.KeepRelative, EAttachmentRule.KeepRelative, false);
}
}
It's ok for the rest , thanks.
from usharp.
I'm not saying don't add SetupAttachment
. I'm saying add SetupAttachment
but call the C++ function. Doing so is a little more complicated as a new C++ pinvoke method is needed. But I'll link the solution here for future reference of doing something similar.
from usharp.
The reason why a local var of PrimaryActorTick
is require is that PrimaryActorTick
is a property and FTickFunction is a struct, so you can't set CanEverTick
directly. There are now function such as this.PrimaryActorTick.SetCanEverTick(true)
which should work though.
Is SetupAttachment
the same as AttachToComponent
?
It looks like SetupAttachment
isn't exposed as a UFUNCTION in C++, where as AttachToComponent
is. It might be worth manually adding support for SetupAttachment
as the logic behind it is a lot simpler.
from usharp.
AttachToComponent
is a lot more verbose in terms of source code. SetupAttachment
just sets 2 members. I think it would be worth manually wrapping SetupAttachment
. I'll look into doing this soon.
from usharp.
As for SetTrackingSource
; it's possibly merged into a property called TrackingSource
which should have a getter/setter. USharp will currently merge any property which has GetXXX / SetXXX functions into a single property. Or maybe it wasn't generated at all? The functions are marked as deprecated in C++.
from usharp.
I agree a call to the native method is better
from usharp.
The primary tick part should be written into the wiki. You have to create an instance variable of the PrimaryActorTick property. Here's an example.
var myATick = this.PrimaryActorTick;
myATick.CanEverTick = true;
It's a bit weird. Creating a variable like this actually returns a reference to the primary actor tick property. I forgot why Pixeltris didn't just use the conventional method. Something to do with interrop and memory management issues.
from usharp.
Ok it's not a big deal ;) However how do you use SetupAttachment
?
from usharp.
SetupAttachment takes one argument (the component) while the other one take many parameters. Not sure to the difference of them. I'll take a look at the source code..
from usharp.
You can create a PR if you like.
from usharp.
Why not if it's OK for you. Where do you put this kind of code?
from usharp.
I don't think it's overkill. You should add it demonixis. Every bit helps. 😄
from usharp.
1924545 so this commit shows adding a new pinvoke method, and calling the method from an InjectedClasses file. You will need to regenerate the C# engine wrapper code for this (which can be done in the console via USharpGen modules
/ USharpGen compile
or delete your modules folder at /USharp/Binaries/Managed/Modules/
and then reopen your unreal project file (it should prompt to regenerate / compile the wrapper code).
from usharp.
Thank you! That way I'll be able to add native methods if they're missing.
from usharp.
Related Issues (20)
- Question about CodeGenerator HOT 3
- crash when overriding some of my C++ native event and blueprint implementable event HOT 8
- Losing reference to C# class when restarting UE4 HOT 1
- Question: Creating mesh with USharp HOT 3
- Error and crash after hotreload with disabled USharpMinHotReload HOT 1
- FRandRange error!
- USharp doesn't compile HOT 11
- PluginInstaller can't find MSBuild with VisualStudio2019 Professional
- Error in Unreal Editor when recompiling MyProject.Managed.dll
- How to get GetWorld() in C#? HOT 1
- Support for default values on C# auto properties exposed to UE4 HOT 1
- Crash when hotreloading after changing the layout of a struct
- Replace method name string with nameof's
- Missing Engine Module ApexDestruction HOT 2
- UUserWidget -> GetWidgetFromName implementation? HOT 1
- [Bug] TMap's iterator is different between C# and C++ in UE 4.22 HOT 6
- Full dev integration HOT 4
- Class redirectors don't work HOT 1
- File.ReadAllText( ... ) crashes UE4 HOT 2
- Support for latent functions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from usharp.