Unity и WPF как передавать данные между 2 приложениями?

На данный момент приложение Unity запускается из WPF приложения:

[DllImport("User32.dll")]
    static extern bool MoveWindow(IntPtr handle, int x, int y, int width, int height, bool redraw);

    internal delegate int WindowEnumProc(IntPtr hwnd, IntPtr lparam);
    [DllImport("user32.dll")]
    internal static extern bool EnumChildWindows(IntPtr hwnd, WindowEnumProc func, IntPtr lParam);

    [DllImport("user32.dll")]
    static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);

    private Process process;
    private IntPtr unityHWND = IntPtr.Zero;

    private const int WM_ACTIVATE = 0x0006;
    private readonly IntPtr WA_ACTIVE = new IntPtr(1);
    private readonly IntPtr WA_INACTIVE = new IntPtr(0);

    public Performance(string nameTema, string nameLesson)
    {
        InitializeComponent();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        MainWindow.DBConnect();

        string uri = "C:/Users/Extro/source/repos/Project/Project/Resources/Literature/";
        webView.LoadUrl($"{uri}{MainWindow._context.ButtonGen.Local.ToObservableCollection().Where(i => i.id == Lessen.tempID).Select(lit => lit.literature).FirstOrDefault()}");
        process = new Process();
    }

    private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        string tempObjectUri = MainWindow._context.ButtonGen.Local.ToObservableCollection()
            .Where(i => i.id == Lessen.tempID).Select(lit => lit.objectUri).FirstOrDefault();

        if (tempObjectUri != "")
        {
            tab2.Visibility = Visibility.Visible;
            if (tab2.IsSelected == true)
            {
               
                process.StartInfo.FileName = $"{tempObjectUri}";
                process.StartInfo.Arguments = "-parentHWND " + panel1.Handle.ToInt32() + " " + Environment.CommandLine;
                process.StartInfo.UseShellExecute = true;
                process.StartInfo.CreateNoWindow = true;

                process.Start();

                process.WaitForInputIdle();
                EnumChildWindows(panel1.Handle, WindowEnum, IntPtr.Zero);
            }
        }
        else
        {
            tab2.Visibility = Visibility.Collapsed;
        }

    }

    private void panel1_Resize(object sender, EventArgs e)
    {
        MoveWindow(unityHWND, 0, 0, panel1.Width, panel1.Height, true);
    }

    private int WindowEnum(IntPtr hwnd, IntPtr lparam)
    {
        unityHWND = hwnd;
        return 0;
    }

Ответы (0 шт):