English 中文(简体)
利用因特网与无雷文本
原标题:Using .NET with UnrealScript

UDK uses .NET. So maybe it is possible somehow to use .NET from UnrealScript?
It is really great to use C# with UnrealScript.

可以肯定地建立C++层,在......之间进行互动。 NET and Unreal texts which will usedllimport, but it is not the subject to this question.

最佳回答

因此似乎无法进入。 直接来自“Unreal”的网络图书馆,但可以将和“Unrealalle Interop”系统,以便与......互动。 该网络没有中间C++包裹。

让我们看一看在C#中与纸浆、铺设、结构与填充无弹性的字典交换的简单例子。

1 创建C#级

using System;
using System.Runtime.InteropServices;
using RGiesecke.DllExport;
namespace UDKManagedTestDLL
{

    struct TestStruct
    {
        public int Value;
    }

    public static class UnmanagedExports
    {
        // Get string from C#
        // returned strings are copied by UnrealScript interop system so one
        // shouldn t worry about allocationdeallocation problem
        [DllExport("GetString", CallingConvention = CallingConvention.StdCall]
        [return: MarshalAs(UnmanagedType.LPWStr)]
        static string GetString()
        {
            return "Hello UnrealScript from C#!";
        }

        //This function takes int, squares it and return a structure
        [DllExport("GetStructure", CallingConvention = CallingConvention.StdCall]
        static TestStructure GetStructure(int x)
        {
             return new TestStructure{Value=x*x};
        }

        //This function fills UnrealScript string
        //(!) warning (!) the string should be initialized (memory allocated) in UnrealScript
        // see example of usage below            
        [DllExport("FillString", CallingConvention = CallingConvention.StdCall]
        static void FillString([MarshalAs(UnmanagedType.LPWStr)] StringBuilder str)
        {
            str.Clear();    //set position to the beginning of the string
            str.Append("ha ha ha");
        }
    }
}

2 Compile the C# Code, 指出,作为UDKManaged Test.dll and place to [BinariesWin32UserCode] (or Win64)

3 在非文本方面,应宣布职能:

class TestManagedDLL extends Object
    DLLBind(UDKManagedTest);

struct TestStruct
{
   int Value;
}

dllimport final function string GetString();
dllimport final function TestStruct GetStructure();
dllimport final function FillString(out string str);


DefaultProperties
{
}

然后可以使用这些职能。


唯一的trick子是填充《世界人权宣言》,就像在《冲积方法》中所示。 由于我们穿透了固定长度的缓冲,因此,这种伸缩的审慎态度是初步的。 初步加强管理的时间长或等于C#的长度。


还可进一步阅读here

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签