Giter VIP home page Giter VIP logo

Comments (15)

pixeltris avatar pixeltris commented on August 27, 2024 3

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.

demonixis avatar demonixis commented on August 27, 2024 2

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.

pixeltris avatar pixeltris commented on August 27, 2024 2

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.

pixeltris avatar pixeltris commented on August 27, 2024 1

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?

ScoreText.AttachToComponent(RootComponent, FName.None, EAttachmentRule.KeepRelative, EAttachmentRule.KeepRelative, EAttachmentRule.KeepRelative, false);

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.

pixeltris avatar pixeltris commented on August 27, 2024 1

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.

pixeltris avatar pixeltris commented on August 27, 2024 1

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.

demonixis avatar demonixis commented on August 27, 2024 1

I agree a call to the native method is better

from usharp.

Tanner555 avatar Tanner555 commented on August 27, 2024

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.

demonixis avatar demonixis commented on August 27, 2024

Ok it's not a big deal ;) However how do you use SetupAttachment?

from usharp.

demonixis avatar demonixis commented on August 27, 2024

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.

Tanner555 avatar Tanner555 commented on August 27, 2024

You can create a PR if you like.

from usharp.

demonixis avatar demonixis commented on August 27, 2024

Why not if it's OK for you. Where do you put this kind of code?

from usharp.

Tanner555 avatar Tanner555 commented on August 27, 2024

I don't think it's overkill. You should add it demonixis. Every bit helps. 😄

from usharp.

pixeltris avatar pixeltris commented on August 27, 2024

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.

demonixis avatar demonixis commented on August 27, 2024

Thank you! That way I'll be able to add native methods if they're missing.

from usharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.