Seven is the number.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

99 lines
2.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using BoltInternal;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Scripting;
namespace Bolt
{
[Preserve]
public static class BoltDynamicData
{
public static void Setup()
{
BoltNetworkInternal.DebugDrawer = new BoltInternal.UnityDebugDrawer();
#if UNITY_PRO_LICENSE
BoltNetworkInternal.UsingUnityPro = true;
#else
BoltNetworkInternal.UsingUnityPro = false;
#endif
BoltNetworkInternal.GetActiveSceneIndex = GetActiveSceneIndex;
BoltNetworkInternal.GetSceneName = GetSceneName;
BoltNetworkInternal.GetSceneIndex = GetSceneIndex;
BoltNetworkInternal.GetGlobalBehaviourTypes = GetGlobalBehaviourTypes;
BoltNetworkInternal.EnvironmentSetup = BoltInternal.BoltNetworkInternal_User.EnvironmentSetup;
BoltNetworkInternal.EnvironmentReset = BoltInternal.BoltNetworkInternal_User.EnvironmentReset;
// Setup Unity Config
#if ENABLE_IL2CPP
UnitySettings.IsBuildIL2CPP = true;
#elif ENABLE_MONO
UnitySettings.IsBuildMono = true;
#elif ENABLE_DOTNET
UnitySettings.IsBuildDotNet = true;
#endif
UnitySettings.CurrentPlatform = Application.platform;
}
static int GetActiveSceneIndex()
{
return SceneManager.GetActiveScene().buildIndex;
}
static int GetSceneIndex(string name)
{
return BoltInternal.BoltScenes_Internal.GetSceneIndex(name);
}
static string GetSceneName(int index)
{
return BoltInternal.BoltScenes_Internal.GetSceneName(index);
}
static public List<STuple<BoltGlobalBehaviourAttribute, Type>> GetGlobalBehaviourTypes()
{
List<STuple<BoltGlobalBehaviourAttribute, Type>> result = new List<STuple<BoltGlobalBehaviourAttribute, Type>>();
try
{
var asmIter = BoltAssemblies.AllAssemblies;
while (asmIter.MoveNext())
{
var asm = GetAssemblyByName(asmIter.Current);
if (asm == null) { continue; }
foreach (Type type in asm.GetTypes())
{
if (typeof(MonoBehaviour).IsAssignableFrom(type))
{
var attrs = (BoltGlobalBehaviourAttribute[]) type.GetCustomAttributes(typeof(BoltGlobalBehaviourAttribute), false);
if (attrs.Length == 1)
{
result.Add(new STuple<BoltGlobalBehaviourAttribute, Type>(attrs[0], type));
}
}
}
}
}
catch (Exception e)
{
BoltLog.Exception(e);
}
return result;
}
static Assembly GetAssemblyByName(string name)
{
return AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(assembly => assembly.GetName().Name == name);
}
}
}