Skip to content

Instantly share code, notes, and snippets.

@ApprenticeGC
Last active April 19, 2017 22:56
Show Gist options
  • Select an option

  • Save ApprenticeGC/1abf10a4b1f508e6769d50830959a90a to your computer and use it in GitHub Desktop.

Select an option

Save ApprenticeGC/1abf10a4b1f508e6769d50830959a90a to your computer and use it in GitHub Desktop.
Try to use Akka .Net in Unity 2017 beta version

Jumping to summary directly, it doesn't work.

Although Akka.dll can be placed into Plugins folder without too much trouble, the use of Akka fails. Trying to implement simple GreetingActor sample from official site can not even be run without probelm. The first error(at assemble loading) is from

Receive<Greet>(greet => {})

The error is

Reference to type `System.Func`2<T,bool>' claims it is defined assembly `mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', but it could not be found

Even if the line is commented, other part will still generate error at run time

TypeLoadException: Could not load type 'Akka.Event.EventStream' from assembly 'Akka, Version=1.2.0.33, Culture=neutral, PublicKeyToken=null'.
Akka.Actor.Internal.ActorSystemImpl..ctor (System.String name, Akka.Configuration.Config config) (at <ca083fc567ea43ddaf4e1ed1d63c779b>:0)

This is combined with Zenject, but I think it may not be any different with or without Zenject. Since Akka.dll is loaded, Unity is constantly crashed. Any script change or even some UI operation will result Unity crash. Under such extreme condition, the development won't go any further either.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Akka;
using Akka.Actor;
namespace GiantCroissant.UseAkka.Game
{
public class Greet
{
public Greet(string who)
{
Who = who;
}
public string Who { get;private set; }
}
public class GreetingActor : ReceiveActor
{
public GreetingActor()
{
// Receive<Greet>(greet =>
// {
// var desc = string.Format("Hello {0}", greet.Who);
// Debug.Log(desc);
// });
//Receive<Greet>(GreetFunction);
}
void GreetFunction(Greet greet)
{
var desc = string.Format("Hello {0}", greet.Who);
Debug.Log(desc);
}
}
public class ScenewideInstaller : Zenject.MonoInstaller
{
public override void InstallBindings()
{
//var system = ActorSystem.Create("MySystem");
Container.BindInterfacesAndSelfTo<SceneOperator>().AsSingle();
Container
.Bind<ActorSystem>()
//.FromInstance(system)
.FromMethod((c) =>
{
return ActorSystem.Create("Scene");
})
.AsSingle();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment