
0
Fixed
AOT Stubs Namespacing issue with Singleton
I have some problems with the AOT Pre-Build. It was working on Bolt 1.3.0 and Unity 2017.4.3f1 + .NET 3. And I haven't changed any scripts after it as I have used only Bolt's Flow or State Machines.
Now using Unity 2018.2.1f1, Bolt 1.4.0f5, .NET 3
Now when I build the AOT, every one of my singleton using "managers" results in compile error and the generate AotStubs needs to be deleted to continue working or trying again to AOT build.
Here is one e.g where the problem is my PlayerFigureManager.
Error 1 on console: Assets/Ludiq/Ludiq.Core/Generated/AotStubs.cs(4804,35): error CS0311: The type `PlayerFigureManager' cannot be used as type parameter `T' in the generic type or method `Ludiq.Singleton<T>'. There is no implicit reference conversion from `PlayerFigureManager' to `Ludiq.ISingleton'
Error 2 on console: Assets/Ludiq/Ludiq.Core/Generated/AotStubs.cs(4804,66): error CS0117: `Ludiq.Singleton<PlayerFigureManager>' does not contain a definition for `Instance'
Here is the actual PlayerFigureManager class
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerFigureManager : Singleton<PlayerFigureManager> { public bool IsBought(int index) { // real logic here return false; } public bool Buy(int index) { // real logic here return true; } }
And here is the singleton class:
using UnityEngine; public class Singleton<T> : MonoBehaviour where T : MonoBehaviour { private static T instance; public static T Instance { get { if (instance == null) { var t = typeof(T); instance = (new GameObject(t.Name)).AddComponent<T>(); } else if (instance != FindObjectOfType<T>()) { Destroy(FindObjectOfType<T>()); } DontDestroyOnLoad(FindObjectOfType<T>()); return instance; } } }
Any idea why this does happen now with newer Bolt (and Unity) ? And how I might solve this issue?
Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Customer support service by UserEcho
Hi serialkamikaze,
Sorry you're having this issue, it seems like a regression introduced while fixing AOT stubs for extension methods.
Can you paste the method in AotStubs.cs with the line where you get this error?
Hello Lazlo,
Here are the lines 4906-4913 from the AotStubs.cs:
I see, this seems like a namespacing issue. The AOT stubs appears to be looking for Bolt.Singleton instead of your own custom global::Singleton class. I'll try to fix that, but in the mean time, it can be avoided by putting your singleton class in a namespace.
Thanks! Creating a namespace did get it working for me.
This will be fixed for v.1.4.0f6, all type references in AOT stubs will now explicitly specify the global:: prefix.