Lately I've been playing around with Unity3D. The one fun thing was, you were able to execute command from another file by using.
GetComponent(). What you were able to do is, for example set users speed, even though script wasn't attached to player, so you technically were able to execute a function (void), from another script and actually make it work, you could've managed player by saying

public GameObject Player;

Player.AddForce("20");

I do realize this is familiar thing as OOP. But I can't seem to find clear tutorial in pure C#. You included external script with GetComponent(), but I don't think MS's .NET libraries have such a command. I've Googled so far, but I cannot find name for it, and OOP programming is already basically known by me, just not this type. Do you maybe know how to issue/use such a thing? Or maybe you know how it's called, so I can Google it instead?

@edit

Another example of part of script that I found that is using this:

using (AllocatedMemory memory = new AllocatedMemory(4)) {
    Executor executor = new Executor();
    IntPtr FloatingFont = Memory.Base.Read<IntPtr>((IntPtr)Offsets.LoL.FloatingFont);
    memory.WriteString(Text);
    executor.AddLine("push {0}", ObjectManager.Me.BaseAddress);
    executor.AddLine("push 0");
    executor.AddLine("push {0}", memory.Address);
    executor.AddLine("push {0}", Type);
    executor.AddLine("push {0}", GameObject.BaseAddress);
    executor.AddLine("mov esi, {0}", GameObject.BaseAddress);
    executor.AddLine("xor edi, edi");
    executor.AddLine("xor ebx, ebx");
    executor.AddLine("mov ecx, {0}", FloatingFont);
    executor.AddLine("mov eax, {0}", ObjectManager.Me.BaseAddress);
    executor.AddLine("call {0}", Offsets.LoL.DrawFloatText);
    executor.AddLine("ret");
    executor.Execute();
 }

Someone has created (or it was pre-created) executor and it has functions AddLine(); and Execute();, I'd love to learn to create own things like this.

Edited 1 Year Ago by RikTelner

Hi

I have no experience with Unity 3D but having read your post a couple of times, I am a little confused. You mention at the top that you are familiar with OOP but then provide an example of using an Executor class to call it's AddLine and Execute methods and would like to know how to create these yourself.

Do you need some good tutorials on OOP or are you looking for something else?

I would recommend getting a good book on OOP if that is what you are looking for. Perhaps this one: Beginning C# Object-Oriented Programming

top that you are familiar with OOP but then provide an example of using an Executor class to call it's AddLine and Execute methods and would like to know how to create these yourself.

and OOP programming is already basically known by me

Basically. Noticed that part?

I would recommend getting a good book on OOP if that is what you are looking for. Perhaps this one: Beginning C# Object-Oriented Programming

I know basically how OOP works, just not that type of it.

but then provide an example of using an Executor class to call it's AddLine and Execute methods and would like to know how to create these yourself.

Yes... but this is the OOP we know:

class Program{
    static void Main(string[] args) {
        Car myCar = new Car ();
        myCar.numberOfDoors=4;
        Console.WriteLine (myCar.numberOfDoors);
        myCar.Accelerate ();
    }
}

That's a little bit something else than what I see in the script I provided.

But nevermind, I found already my source of answer (school).

Edited 1 Year Ago by RikTelner

If school will teach you what you need (which it should do) then great. However if you can get that book I would recommend it. It would put you in a very good position to understand your class and maybe even put you at the top of it if you put the extra effort in.

This article has been dead for over six months. Start a new discussion instead.