static void AddConversionSystems(World gameObjectWorld) { var declareConvert = gameObjectWorld.GetOrCreateSystem <GameObjectConversionDeclarePrefabsGroup>(); var earlyConvert = gameObjectWorld.GetOrCreateSystem <GameObjectBeforeConversionGroup>(); var convert = gameObjectWorld.GetOrCreateSystem <GameObjectConversionGroup>(); var lateConvert = gameObjectWorld.GetOrCreateSystem <GameObjectAfterConversionGroup>(); var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.GameObjectConversion); foreach (var system in systems) { var attributes = system.GetCustomAttributes(typeof(UpdateInGroupAttribute), true); if (attributes.Length == 0) { AddSystemAndLogException(gameObjectWorld, convert, system); } else { foreach (var attribute in attributes) { var groupType = (attribute as UpdateInGroupAttribute)?.GroupType; if (groupType == declareConvert.GetType()) { AddSystemAndLogException(gameObjectWorld, declareConvert, system); } else if (groupType == earlyConvert.GetType()) { AddSystemAndLogException(gameObjectWorld, earlyConvert, system); } else if (groupType == convert.GetType()) { AddSystemAndLogException(gameObjectWorld, convert, system); } else if (groupType == lateConvert.GetType()) { AddSystemAndLogException(gameObjectWorld, lateConvert, system); } else { Debug.LogWarning($"{system} has invalid UpdateInGroup[typeof({groupType}]"); } } } } declareConvert.SortSystemUpdateList(); earlyConvert.SortSystemUpdateList(); convert.SortSystemUpdateList(); lateConvert.SortSystemUpdateList(); }
internal static World CreateConversionWorld(GameObjectConversionSettings settings) { using (s_CreateConversionWorld.Auto()) { var gameObjectWorld = new World($"GameObject -> Entity Conversion '{settings.DebugConversionName}'", WorldFlags.Live | WorldFlags.Conversion | WorldFlags.Staging); gameObjectWorld.CreateSystem <GameObjectConversionMappingSystem>(settings); var systemTypes = settings.Systems ?? DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.GameObjectConversion); var includeExport = settings.GetType() != typeof(GameObjectConversionSettings); AddConversionSystems(gameObjectWorld, systemTypes.Concat(settings.ExtraSystems), includeExport); settings.ConversionWorldCreated?.Invoke(gameObjectWorld); return(gameObjectWorld); } }
internal static World CreateConversionWorld(GameObjectConversionSettings settings) { using (s_CreateConversionWorld.Auto()) { var gameObjectWorld = new World("GameObject World"); gameObjectWorld.CreateSystem <GameObjectConversionMappingSystem>(settings); var systemTypes = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.GameObjectConversion); systemTypes.AddRange(settings.ExtraSystems); var includeExport = settings.GetType() != typeof(GameObjectConversionSettings); AddConversionSystems(gameObjectWorld, systemTypes, includeExport); settings.ConversionWorldCreated?.Invoke(gameObjectWorld); return(gameObjectWorld); } }
static void AddConversionSystems(World gameObjectWorld) { var init = gameObjectWorld.GetOrCreateSystem <GameObjectConversionInitializationGroup>(); var convert = gameObjectWorld.GetOrCreateSystem <GameObjectConversionGroup>(); var afterConvert = gameObjectWorld.GetOrCreateSystem <GameObjectAfterConversionGroup>(); // Ensure the following systems run first in this order... init.AddSystemToUpdateList(gameObjectWorld.GetOrCreateSystem <ConvertGameObjectToEntitySystemDeclarePrefabs>()); init.AddSystemToUpdateList(gameObjectWorld.GetOrCreateSystem <ComponentDataProxyToEntitySystem>()); var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.GameObjectConversion); foreach (var system in systems) { var attributes = system.GetCustomAttributes(typeof(UpdateInGroupAttribute), true); if (attributes.Length == 0) { AddSystemAndLogException(gameObjectWorld, convert, system); } else { foreach (var attribute in attributes) { var groupType = (attribute as UpdateInGroupAttribute)?.GroupType; if (groupType == convert.GetType()) { AddSystemAndLogException(gameObjectWorld, convert, system); } else if (groupType == afterConvert.GetType()) { AddSystemAndLogException(gameObjectWorld, afterConvert, system); } else { Debug.LogWarning($"{system} has invalid UpdateInGroup[typeof({groupType}]"); } } } } convert.SortSystemUpdateList(); afterConvert.SortSystemUpdateList(); }
internal static World CreateConversionWorld(GameObjectConversionSettings settings, Scene scene = default) { using (s_CreateConversionWorld.Auto()) { var gameObjectWorld = new World($"GameObject -> Entity Conversion '{settings.DebugConversionName}'", WorldFlags.Live | WorldFlags.Conversion | WorldFlags.Staging); var mappingSystem = new GameObjectConversionMappingSystem(settings); gameObjectWorld.AddSystem(mappingSystem); if (mappingSystem.IsLiveLink) { mappingSystem.PrepareForLiveLink(scene); } var systemTypes = settings.Systems ?? DefaultWorldInitialization.GetAllSystems(settings.FilterFlags); var includeExport = settings.SupportsExporting; AddConversionSystems(gameObjectWorld, systemTypes.Concat(settings.ExtraSystems), includeExport, mappingSystem.IsLiveLink); settings.ConversionWorldCreated?.Invoke(gameObjectWorld); return(gameObjectWorld); } }
internal static World CreateConversionWorld(GameObjectConversionSettings settings) { using (s_CreateConversionWorld.Auto()) { var gameObjectWorld = new World($"GameObject -> Entity Conversion '{settings.DebugConversionName}'"); gameObjectWorld.CreateSystem <GameObjectConversionMappingSystem>(settings); var systemTypes = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.GameObjectConversion); if (settings.ExtraSystems.Length > 0) { var systems = new List <Type>(systemTypes.Count + settings.ExtraSystems.Length); systems.AddRange(systemTypes); systems.AddRange(settings.ExtraSystems); systemTypes = systems; } var includeExport = settings.GetType() != typeof(GameObjectConversionSettings); AddConversionSystems(gameObjectWorld, systemTypes, includeExport); settings.ConversionWorldCreated?.Invoke(gameObjectWorld); return(gameObjectWorld); } }