Tôi phải tạo một tập lệnh Unity để nhập và xuất một số mô hình 3D. Tôi đang cố gắng để tham khảo Servicestack.Redis từ kịch bản của tôi để tôi có thể nói chuyện với redis. Nó biên dịch tốt nhưng sự thống nhất sẽ không tải thư viện.Làm cách nào để tham chiếu thư viện ServiceStack trong tập lệnh Unity C#?
tôi đã sao chép của dll từ xây dựng/phát hành/MonoDevelop/SericeStack.Redis.zip vào thư mục tài sản của tôi trong sự hiệp nhất, (đó là đúng?) Tôi chỉ có ServiceStack bằng cách nhân bản https://github.com/ServiceStack/ServiceStack.Redis
Khi Unity cố gắng tải tập lệnh có nội dung là
Internal compiler error. See the console log for more information. output was:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes() [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.LoadReferences() [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Compile() [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
Mã của tôi cho đến thời điểm này. Đó là một kịch bản biên tập. Nó chỉ làm cho một cửa sổ với một nút và khi nút được nhấp vào nó cố gắng để kết nối với redis trên localhost và nhận được một chìa khóa
using UnityEngine;
using UnityEditor;
using System.Collections;
using ServiceStack.Redis;
public class MyWindow : EditorWindow
{
// Add menu item named "My Window" to the Window menu
[MenuItem("Window/My Window")]
public static void ShowWindow()
{
//Show existing window instance. If one doesn't exist, make one.
EditorWindow.GetWindow(typeof(MyWindow));
}
void OnGUI()
{
if (GUILayout.Button("Press to Rotate"))
{
ProcessAsset();
}
}
void ProcessAsset()
{
using (var client = new RedisClient("localhost"))
{
client.Get ("hello");
}
}
}
Tôi có lẽ chỉ không tham khảo thư viện một cách chính xác. Tôi khá mới với các ngôn ngữ được biên dịch.
Thật không may, số lượng mono và thống nhất không tương thích Tôi đã tìm thấy đã khiến tôi phải từ bỏ sự hiệp nhất và viết lại quá trình xuất khẩu của tôi trong python. – Nathan