Code Monkey home page Code Monkey logo

Comments (12)

ScottKane avatar ScottKane commented on May 20, 2024 1

Ok thanks for the info, will spend some time having fun with my own execution plan and see what I can come up with.

from unrealclr.

nxrighthere avatar nxrighthere commented on May 20, 2024

Show me your code please.

from unrealclr.

ScottKane avatar ScottKane commented on May 20, 2024
using System;
using System.Drawing;
using UnrealEngine.Framework;

namespace Game
{
    public static class Main
    { // Indicates the main entry point for automatic loading by the plugin
        public static void OnWorldBegin() => Debug.AddOnScreenMessage(-1, 10.0f, Color.DeepPink, "Hello, Unreal Engine!");

        public static void OnWorldEnd() => Debug.AddOnScreenMessage(-1, 10.0f, Color.DeepPink, "See you soon, Unreal Engine!");

        public static void OnWorldPrePhysicsTick(float deltaTime) => Debug.AddOnScreenMessage(1, 10.0f, Color.DeepPink, "On pre physics tick invoked!");

        public static void OnWorldDuringPhysicsTick(float deltaTime) => Debug.AddOnScreenMessage(2, 10.0f, Color.DeepPink, "On during physics tick invoked!");

        public static void OnWorldPostPhysicsTick(float deltaTime) => Debug.AddOnScreenMessage(3, 10.0f, Color.DeepPink, "On post physics tick invoked!");

        public static void OnWorldPostUpdateTick(float deltaTime) => Debug.AddOnScreenMessage(4, 10.0f, Color.DeepPink, "On post update tick invoked!");
    }
}

from unrealclr.

nxrighthere avatar nxrighthere commented on May 20, 2024

It works fine for me. The test project works for you? Which version of the plugin are you using?

from unrealclr.

ScottKane avatar ScottKane commented on May 20, 2024

I'm using the latest version of the plugin with UE4.25.3 and dotnet-sdk-3.1.401-win-x64 although during the installer I said no to the tests, will retry with the tests now

from unrealclr.

nxrighthere avatar nxrighthere commented on May 20, 2024

If the test project doesn't work for you, then make sure that the plugin is properly initialized https://github.com/nxrighthere/UnrealCLR#running

from unrealclr.

ScottKane avatar ScottKane commented on May 20, 2024

It's working now, I think it's because I was building with dotnet build -o %Project%\Managed\ but when I switched to dotnet build -o %Project%\Managed\ClassLib it's now working. I didn't realise output needed to be in a folder relative to the assembly name. Makes sense but could do with being a bit more clear in the docs

from unrealclr.

nxrighthere avatar nxrighthere commented on May 20, 2024

Nevermind, I found why this might happen, going to fix it quickly.

from unrealclr.

ScottKane avatar ScottKane commented on May 20, 2024

Awesome, also just been digging into the Tests and noticed that everything is static. What is the reason for this? Just wondering because in C++ you can for example do ACharacterBase : ACharacter whereas here if everything is static how do you do CharacterBase : Character? I ask because I was planning on using Dependency Injection which would require constructors.

from unrealclr.

nxrighthere avatar nxrighthere commented on May 20, 2024

I did that in tests to quickly switch between them. If you have experience working with regular .NET applications where you have Main() entry point, then the principle here is the same. You have static entry points from where you kickstart your logic and then organize your code the way you like. There's no intermediate scripts manager or stuff like that. You can use inheritance here too, see this test.

from unrealclr.

ScottKane avatar ScottKane commented on May 20, 2024

Ok yeah that makes sense, I was assuming I could do something like the following based on my understanding of the C++ workflow:

public class PlayerCharacter : Character
{
    protected override void Tick()
    {
        base.Tick();
        Debug.Log(LogLevel.Display, "Tick");
    }
}

from unrealclr.

nxrighthere avatar nxrighthere commented on May 20, 2024

Yea, the approach here is very different. The framework is not following idioms of the engine, so you can organize the execution flow and stuff the way you like with full control over it and keep it all managed. So to reproduce the same approach as in your example, you can create an intermediate scripts manager to execute logic using the object-oriented design or any other one.

from unrealclr.

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.