shoval savir
shoval savir

Reputation: 3

Make windows form appear in a Unity game

I downloaded a game which is based on unity engine, and I programmed a windows form which reads the log file the game creates in realtime and do somethings with the data.

Is there a way to kind of inject the form into the game? I mean the form will appear as-is inside the game.

Thanks for all :)

Upvotes: 0

Views: 1791

Answers (1)

Fᴀʀʜᴀɴ Aɴᴀᴍ
Fᴀʀʜᴀɴ Aɴᴀᴍ

Reputation: 6251

First of all make sure that your form has the TopMost property set to True. Next, attach this script to the Main Camera:

using UnityEngine;
using System.Collections;
using System.Diagnostics;

public class Overlay : MonoBehaviour {

    bool onlyOnce = true;
    // Use this for initialization
    void Start () {
        if (onlyOnce) {
            Process p = Process.Start (@"Overlay.exe"); //Change to the exe of your form
            onlyOnce = false;
        }
    }

    // Update is called once per frame
    void Update () {

    }
}

Now you should be able to use the form all good.

BUT:

Reading your question, I think you do not have access to the source code of the game. In that case, you can program your form to start the game from within it. Otherwise, you have to use DLL injection. Search google and you will get loads of info about it and how to do it. However, it's not that easy.

Upvotes: 1

Related Questions