static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 5 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 4) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 5)) { uint _u32_0 = LuaAPI.xlua_touint(L, 2); uint _u32_1 = LuaAPI.xlua_touint(L, 3); uint _u32_2 = LuaAPI.xlua_touint(L, 4); uint _u32_3 = LuaAPI.xlua_touint(L, 5); UnityEngine.Hash128 gen_ret = new UnityEngine.Hash128(_u32_0, _u32_1, _u32_2, _u32_3); translator.Push(L, gen_ret); return(1); } if (LuaAPI.lua_gettop(L) == 1) { translator.Push(L, default(UnityEngine.Hash128)); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Hash128 constructor!")); }
static StackObject *LoadFromCacheOrDownload_24(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.UInt32 crc = (uint)ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.Hash128 hash = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.String url = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = UnityEngine.WWW.LoadFromCacheOrDownload(url, hash, crc); object obj_result_of_this_method = result_of_this_method; if (obj_result_of_this_method is CrossBindingAdaptorType) { return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance)); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static object PerformMemberwiseClone(ref object o) { var ins = new UnityEngine.Hash128(); ins = (UnityEngine.Hash128)o; return(ins); }
static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Hash128 @hash = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.String @name = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = new UnityEngine.CachedAssetBundle(@name, @hash); if (!isNewObj) { __ret--; WriteBackInstance(__domain, __ret, __mStack, ref result_of_this_method); return(__ret); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 4); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.UInt32 @u32_3 = (uint)ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.UInt32 @u32_2 = (uint)ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.UInt32 @u32_1 = (uint)ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 4); System.UInt32 @u32_0 = (uint)ptr_of_this_method->Value; var result_of_this_method = new UnityEngine.Hash128(@u32_0, @u32_1, @u32_2, @u32_3); if (!isNewObj) { __ret--; WriteBackInstance(__domain, __ret, __mStack, ref result_of_this_method); return(__ret); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static int _m_GetAssetBundleHash(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.AssetBundleManifest gen_to_be_invoked = (UnityEngine.AssetBundleManifest)translator.FastGetCSObj(L, 1); { string _assetBundleName = LuaAPI.lua_tostring(L, 2); UnityEngine.Hash128 gen_ret = gen_to_be_invoked.GetAssetBundleHash( _assetBundleName); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public void Conversions_MatchUnityEngine() { var hashEntities = new Hash128(1, 2, 3, 4); var hashUnity = new UnityEngine.Hash128(1, 2, 3, 4); var hashUnityToEntities = (Hash128)hashUnity; var hashEntitiesToUnity = (UnityEngine.Hash128)hashEntities; Assert.That(hashEntities, Is.EqualTo(hashUnityToEntities)); Assert.That(hashUnity, Is.EqualTo(hashEntitiesToUnity)); }
public void TestDynamicPoolInitialState([Values(1, 22, 333, 4444)] int total) { // Prepare PersistencySettings settings = CreateTestSettings(); PersistentSceneSystem persistentSceneSystem = World.GetOrCreateSystem <PersistentSceneSystem>(); BeginFramePersistencySystem beginFramePersistencySystem = World.GetExistingSystem <BeginFramePersistencySystem>(); beginFramePersistencySystem.ReplaceSettings(settings); PersistentDataStorage dataStorage = persistentSceneSystem.PersistentDataStorage; Hash128 identifier = Hash128.Compute("DynamicPoolTests"); NativeArray <PersistableTypeHandle> typeHandles = new NativeArray <PersistableTypeHandle>(Archetype.Length, Allocator.Persistent); for (int i = 0; i < typeHandles.Length; i++) { typeHandles[i] = settings.GetPersistableTypeHandleFromFullTypeName(Archetype[i].GetManagedType().FullName); // This is not advised in a game } // Action Entity prefabEntity = m_Manager.CreateEntity(Archetype); m_Manager.SetComponentData(prefabEntity, new EcsTestData(1)); m_Manager.AddComponent <Prefab>(prefabEntity); persistentSceneSystem.InitializePool(prefabEntity, total, identifier, typeHandles); // Verify { Assert.True(dataStorage.IsInitialized(identifier), "PoolContainer is not initialized!"); PersistentDataContainer container = dataStorage.GetInitialStateReadContainer(identifier); int sizePerEntity = container.GetDataLayoutAtIndex(0).SizePerEntity; Assert.AreEqual(sizePerEntity * total, container.GetRawData().Length, "The data container was not of the expected size!"); int amountNonZero = container.GetRawData().Count(dataByte => dataByte != 0); Assert.NotZero(amountNonZero, "The datacontainer didn't have valid initial state."); } // Action 2 total += 31; persistentSceneSystem.InstantChangePoolCapacity(identifier, total); // Verify { Assert.True(dataStorage.IsInitialized(identifier), "PoolContainer is not initialized!"); dataStorage.ToIndex(0); PersistentDataContainer container = dataStorage.GetReadContainerForCurrentIndex(identifier); int sizePerEntity = container.GetDataLayoutAtIndex(0).SizePerEntity; Assert.AreEqual(sizePerEntity * total, container.GetRawData().Length, "The data container was not of the expected size after an InstantResize!"); int amountNonZero = container.GetRawData().Count(dataByte => dataByte != 0); Assert.NotZero(amountNonZero, "The datacontainer grew but didn't have valid initial state."); } // Cleanup m_Manager.DestroyEntity(m_Manager.UniversalQuery); }
static void WriteBackInstance(CSHotFix.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref UnityEngine.Hash128 instance_of_this_method) { ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.Object: { __mStack[ptr_of_this_method->Value] = instance_of_this_method; } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { var t = __domain.GetType(___obj.GetType()) as CLRType; t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method); } } break; case ObjectTypes.StaticFieldReference: { var t = __domain.GetType(ptr_of_this_method->Value); if (t is ILType) { ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method; } else { ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as UnityEngine.Hash128[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; } break; } }
static int _m_Compute_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 1 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1)) { int _val = LuaAPI.xlua_tointeger(L, 1); UnityEngine.Hash128 gen_ret = UnityEngine.Hash128.Compute(_val); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 1 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1)) { float _val = (float)LuaAPI.lua_tonumber(L, 1); UnityEngine.Hash128 gen_ret = UnityEngine.Hash128.Compute(_val); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 1 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)) { string _data = LuaAPI.lua_tostring(L, 1); UnityEngine.Hash128 gen_ret = UnityEngine.Hash128.Compute(_data); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Hash128.Compute!")); }
static StackObject *LoadFromCacheOrDownload_24(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Hash128 hash = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.String url = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = UnityEngine.WWW.LoadFromCacheOrDownload(url, hash); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static StackObject *ToString_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); UnityEngine.Hash128 instance_of_this_method = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); var result_of_this_method = instance_of_this_method.ToString(); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); __intp.Free(ptr_of_this_method); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static StackObject *set_imageContentsHash_29(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Hash128 @value = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.Texture instance_of_this_method = (UnityEngine.Texture) typeof(UnityEngine.Texture).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.imageContentsHash = value; return(__ret); }
static StackObject *Ctor_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.UInt32 crc = (uint)ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.Hash128 hash = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); System.String url = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = new UnityEngine.Networking.DownloadHandlerAssetBundle(url, hash, crc); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static StackObject *op_Inequality_6(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Hash128 hash2 = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.Hash128 hash1 = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = hash1 != hash2; __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method ? 1 : 0; return(__ret + 1); }
static StackObject *get_isValid_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); UnityEngine.Hash128 instance_of_this_method = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); var result_of_this_method = instance_of_this_method.isValid; ptr_of_this_method = ILIntepreter.Minus(__esp, 1); WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); __intp.Free(ptr_of_this_method); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method ? 1 : 0; return(__ret + 1); }
static int _m_Parse_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); { string _hashString = LuaAPI.lua_tostring(L, 1); UnityEngine.Hash128 gen_ret = UnityEngine.Hash128.Parse(_hashString); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static StackObject *set_hash_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Hash128 @value = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); UnityEngine.CachedAssetBundle instance_of_this_method; instance_of_this_method = (UnityEngine.CachedAssetBundle) typeof(UnityEngine.CachedAssetBundle).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); instance_of_this_method.hash = value; WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); return(__ret); }
static StackObject *Ctor_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.UInt64 @u64_1 = *(ulong *)&ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.UInt64 @u64_0 = *(ulong *)&ptr_of_this_method->Value; var result_of_this_method = new UnityEngine.Hash128(@u64_0, @u64_1); if (!isNewObj) { __ret--; WriteBackInstance(__domain, __ret, __mStack, ref result_of_this_method); return(__ret); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public static Guid ToGuid(this UnityEngine.Hash128 hash128) { return(new Guid(hash128.ToString())); }
public static UnityEngine.Hash128 FromGuid(this UnityEngine.Hash128 hash128, Guid guid) { return(UnityEngine.Hash128.Parse(guid.ToString("N"))); }
public void TestDynamicPoolApplyAndPersist([Values(InstantiationType.Manager, InstantiationType.Command, InstantiationType.ParallelCommand)] InstantiationType instantiationType, [Values(1, 2, 3, 444, 5555)] int total, [Values(false, true)] bool groupedJobs) { // Prepare PersistencySettings settings = CreateTestSettings(); settings.ForceUseGroupedJobsInEditor = groupedJobs; settings.ForceUseNonGroupedJobsInBuild = !groupedJobs; Assert.True(groupedJobs == settings.UseGroupedJobs()); PersistentSceneSystem persistentSceneSystem = World.GetOrCreateSystem <PersistentSceneSystem>(); BeginFramePersistencySystem beginFramePersistencySystem = World.GetExistingSystem <BeginFramePersistencySystem>(); beginFramePersistencySystem.ReplaceSettings(settings); EndFramePersistencySystem endFramePersistencySystem = World.GetOrCreateSystem <EndFramePersistencySystem>(); endFramePersistencySystem.ReplaceSettings(settings); EndInitializationEntityCommandBufferSystem ecbSystem = World.GetOrCreateSystem <EndInitializationEntityCommandBufferSystem>(); PersistentDataStorage dataStorage = persistentSceneSystem.PersistentDataStorage; Hash128 identifier = Hash128.Compute("DynamicPoolTests"); NativeArray <PersistableTypeHandle> typeHandles = new NativeArray <PersistableTypeHandle>(Archetype.Length, Allocator.Persistent); for (int i = 0; i < typeHandles.Length; i++) { typeHandles[i] = settings.GetPersistableTypeHandleFromFullTypeName(Archetype[i].GetManagedType().FullName); // This is not advised in a game } // Action Entity prefabEntity = m_Manager.CreateEntity(Archetype); m_Manager.AddComponent <Prefab>(prefabEntity); persistentSceneSystem.InitializePool(prefabEntity, total, identifier, typeHandles); int amountSpawned = 0; InstantiatePersistent(instantiationType, m_Manager, prefabEntity, ref amountSpawned, total); persistentSceneSystem.InstantChangePoolCapacity(identifier, total * 2); // double amount InstantiatePersistent(instantiationType, m_Manager, prefabEntity, ref amountSpawned, total); m_Manager.RemoveComponent <EmptyEcsTestData>(m_Manager.CreateEntityQuery(typeof(PersistenceState))); Entities.ForEach((Entity e, ref EcsTestData testData, DynamicBuffer <DynamicBufferData1> buffer) => { testData.Value = 1; buffer.Add(new DynamicBufferData1() { Value = 1 }); }); dataStorage.ToIndex(0); endFramePersistencySystem.RequestPersist(dataStorage.GetWriteContainerForCurrentIndex(identifier)); endFramePersistencySystem.Update(); m_Manager.CompleteAllJobs(); beginFramePersistencySystem.RequestApply(dataStorage.GetInitialStateReadContainer(identifier)); beginFramePersistencySystem.Update(); ecbSystem.Update(); // Test int amountSurvivingEntities = m_Manager.CreateEntityQuery(typeof(EcsTestData)).CalculateEntityCount(); Assert.True(amountSurvivingEntities == total * 2, $"{instantiationType} didn't create the expected amount of entities({amountSurvivingEntities}vs{total*2})! (Or they were destroyed by Apply)"); Entities.ForEach((Entity e, ref EcsTestData testData, DynamicBuffer <DynamicBufferData1> buffer) => { Assert.True(testData.Value == 0, "The apply didn't restore the component value!"); Assert.True(buffer.IsEmpty, "The apply didn't restore the buffer!"); Assert.True(m_Manager.HasComponent <EmptyEcsTestData>(e), "The apply didn't restore the component!"); }); // Action dataStorage.ToIndex(0); beginFramePersistencySystem.RequestApply(dataStorage.GetWriteContainerForCurrentIndex(identifier)); beginFramePersistencySystem.Update(); ecbSystem.Update(); // Test amountSurvivingEntities = m_Manager.CreateEntityQuery(typeof(EcsTestData)).CalculateEntityCount(); Assert.True(amountSurvivingEntities == total * 2, $"Some entities were unexpectedly destroyed!"); Entities.ForEach((Entity e, ref EcsTestData testData, DynamicBuffer <DynamicBufferData1> buffer) => { Assert.True(testData.Value == 1, "The second apply didn't restore the component value!"); Assert.True(buffer[0].Value == 1, "The second apply didn't restore the buffer!"); Assert.False(m_Manager.HasComponent <EmptyEcsTestData>(e), "The second apply didn't restore the component!"); }); // Cleanup m_Manager.DestroyEntity(m_Manager.UniversalQuery); }
internal static void RegisterCustomDependency(string dependency, Hash128 hashOfValue) => AssetDatabaseExp.RegisterCustomDependency(dependency, hashOfValue);
protected override void OnUpdate() { if (GetEntityQuery(ComponentType.ReadOnly <UnityEngine.Shader>()).CalculateEntityCount() == 0) { return; } if (!TryGetBuildConfigurationComponent <DotsRuntimeBuildProfile>(out var profile)) { return; } bool includeAllPlatform = false; if (TryGetBuildConfigurationComponent <TinyShaderSettings>(out var shaderSettings)) { includeAllPlatform = shaderSettings.PackageShadersForAllPlatforms; } var platforms = ShaderCompilerClient.GetSupportedPlatforms(profile.Target, includeAllPlatform); var context = new BlobAssetComputationContext <ShaderSettings, PrecompiledShaderPipeline>(BlobAssetStore, 128, Allocator.Temp); Entities.ForEach((UnityEngine.Shader uShader) => { if (MaterialConversion.GetMaterialType(uShader) != MaterialConversion.SupportedMaterialType.Custom) { return; } var entity = GetPrimaryEntity(uShader); // Note: all shader stages are in a single source file string filepath = Path.GetFullPath(AssetDatabase.GetAssetPath(uShader)); if (!File.Exists(filepath)) { throw new InvalidDataException($"Could not open shader file '{filepath}'"); } string shaderSrc = File.ReadAllText(filepath); if (m_Client == null) { InitShaderCompiler(); } m_Client.Preprocess(shaderSrc, filepath, uShader.name, out string hlslSrc, out int startLine, out uint[] includeHash); Hash128 includeHash128 = new Hash128(includeHash[0], includeHash[1], includeHash[2], includeHash[3]); Hash128 hash = new Hash128(); unsafe { fixed(char *p = shaderSrc) { UnityEngine.HashUnsafeUtilities.ComputeHash128(p, (ulong)shaderSrc.Length, &hash); UnityEngine.HashUtilities.AppendHash(ref includeHash128, ref hash); } } context.AssociateBlobAssetWithUnityObject(hash, uShader); if (context.NeedToComputeBlobAsset(hash)) { context.AddBlobAssetToCompute(hash, default); var blobAsset = m_Client.CompileShaderForPlatforms(hlslSrc, platforms, filepath, startLine, uShader.name); if (!blobAsset.IsCreated) { return; } context.AddComputedBlobAsset(hash, blobAsset); } context.GetBlobAsset(hash, out var shaderBlob); DstEntityManager.AddComponentData(entity, new CustomShader { Status = ShaderStatus.Invalid, Name = Path.GetFileNameWithoutExtension(filepath) }); DstEntityManager.AddComponentData(entity, new ShaderBinData { shaders = shaderBlob }); }); ShutdownShaderCompiler(); context.Dispose(); }
/// <summary> /// 最新バージョン以外の AssetBundle キャッシュをクリアする /// </summary> /// <param name="assetBundleName"></param> private void ClearOtherCachedVersions(string assetBundleName) { UnityEngine.Hash128 hash = this.RootAssetBundleManifest.GetAssetBundleHash(assetBundleName); UnityEngine.Caching.ClearOtherCachedVersions(assetBundleName, hash); }
static StackObject *ComputeHash128_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.Hash128 @hash = (UnityEngine.Hash128) typeof(UnityEngine.Hash128).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Byte[] @value = (System.Byte[]) typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); UnityEngine.HashUtilities.ComputeHash128(@value, ref @hash); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); switch (ptr_of_this_method->ObjectType) { case ObjectTypes.StackObjectReference: { var ___dst = *(StackObject **)&ptr_of_this_method->Value; object ___obj = @hash; if (___dst->ObjectType >= ObjectTypes.Object) { if (___obj is CrossBindingAdaptorType) { ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; } __mStack[___dst->Value] = ___obj; } else { ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); } } break; case ObjectTypes.FieldReference: { var ___obj = __mStack[ptr_of_this_method->Value]; if (___obj is ILTypeInstance) { ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @hash; } else { var ___type = __domain.GetType(___obj.GetType()) as CLRType; ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @hash); } } break; case ObjectTypes.StaticFieldReference: { var ___type = __domain.GetType(ptr_of_this_method->Value); if (___type is ILType) { ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @hash; } else { ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @hash); } } break; case ObjectTypes.ArrayReference: { var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as UnityEngine.Hash128[]; instance_of_arrayReference[ptr_of_this_method->ValueLow] = @hash; } break; } __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); __intp.Free(ptr_of_this_method); return(__ret); }
// This function is responsible for providing all the subscenes to the build. // // The way these files get generated is that we have a SceneWithBuildConfiguration file, (which is a bit of a hack to work around the inability for scriptable importers to take arguments, so // instead we create a different file that points to the scene we want to import, and points to the buildconfiguration we want to import it for). The SubsceneImporter will import this file, // and it will make 3 (relevant) kind of files: // - headerfile // - entitybinaryformat file (the actual entities payloads) // - a SerializedFile that has an array of UnityEngine.Object PPtrs that are used by this entity file. // // The first two we deal with very simply: they just need to be copied into the build, and we're done. // the third one, we will feed as input to the Scriptable build pipeline (which is actually about creating assetbundles), and create an assetbundle that // has all those objects in it that the 3rd file referred to. We do this with a batch api, first we loop through all subscenes, and register with this batch // api which assetbundles we'd like to see produced, and then at the end, we say "okay make them please". this assetbundle creation api has a caching system // that is separate from the assetpipeline caching system, so if all goes well, the call to produce these assetbundles will return very fast and did nothing. // // The reason for the strange looking api, where a two callbacks get passed in is to make integration of the new incremental buildpipeline easier, as this code // needs to be compatible both with the current buildpipeline in the dots-repo, as well as with the incremental buildpipeline. When that is merged, we can simplify this. public static void PrepareAdditionalFiles(GUID[] sceneGuids, ArtifactKey[] entitySceneArtifacts, BuildTarget target, Action <string, string> RegisterFileCopy, string outputStreamingAssetsDirectory, string buildWorkingDirectory) { if (target == BuildTarget.NoTarget) { throw new InvalidOperationException($"Invalid build target '{target.ToString()}'."); } if (target != EditorUserBuildSettings.activeBuildTarget) { throw new InvalidOperationException($"ActiveBuildTarget must be switched before the {nameof(SubSceneBuildCode)} runs."); } Assert.AreEqual(sceneGuids.Length, entitySceneArtifacts.Length); var content = new BundleBuildContent(new AssetBundleBuild[0]); var bundleNames = new HashSet <string>(); var subScenePaths = new Dictionary <Hash128, string>(); var dependencyInputData = new Dictionary <SceneSection, SectionDependencyInfo>(); var refExt = EntityScenesPaths.GetExtension(EntityScenesPaths.PathType.EntitiesUnityObjectReferences); var headerExt = EntityScenesPaths.GetExtension(EntityScenesPaths.PathType.EntitiesHeader); var binaryExt = EntityScenesPaths.GetExtension(EntityScenesPaths.PathType.EntitiesBinary); string conversionLogExtension = EntityScenesPaths.GetExtension(EntityScenesPaths.PathType.EntitiesConversionLog); var group = BuildPipeline.GetBuildTargetGroup(target); var parameters = new BundleBuildParameters(target, @group, buildWorkingDirectory) { BundleCompression = BuildCompression.LZ4Runtime }; var artifactHashes = new UnityEngine.Hash128[entitySceneArtifacts.Length]; AssetDatabaseCompatibility.ProduceArtifactsRefreshIfNecessary(entitySceneArtifacts, artifactHashes); for (int i = 0; i != entitySceneArtifacts.Length; i++) { var sceneGuid = sceneGuids[i]; var sceneBuildConfigGuid = entitySceneArtifacts[i].guid; var artifactHash = artifactHashes[i]; bool foundEntityHeader = false; if (!artifactHash.isValid) { throw new Exception($"Building EntityScene artifact failed: '{AssetDatabaseCompatibility.GuidToPath(sceneGuid)}' ({sceneGuid}). There were exceptions during the entity scene imports."); } AssetDatabaseCompatibility.GetArtifactPaths(artifactHash, out var artifactPaths); foreach (var artifactPath in artifactPaths) { //UnityEngine.Debug.Log($"guid: {sceneGuid} artifact: '{artifactPath}'"); //@TODO: This looks like a workaround. Whats going on here? var ext = Path.GetExtension(artifactPath).Replace(".", ""); if (ext == conversionLogExtension) { var res = ConversionLogUtils.PrintConversionLogToUnityConsole(artifactPath); if (res.HasException) { throw new Exception("Building entity scenes failed. There were exceptions during the entity scene imports."); } } else if (ext == headerExt) { foundEntityHeader = true; if (!string.IsNullOrEmpty(artifactPaths.FirstOrDefault(a => a.EndsWith(refExt)))) { subScenePaths[sceneGuid] = artifactPath; } else { //if there are no reference bundles, then deduplication can be skipped var destinationFile = EntityScenesPaths.RelativePathFolderFor(sceneGuid, EntityScenesPaths.PathType.EntitiesHeader, -1); DoCopy(RegisterFileCopy, outputStreamingAssetsDirectory, artifactPath, destinationFile); } } else if (ext == binaryExt) { var destinationFile = EntityScenesPaths.RelativePathFolderFor(sceneGuid, EntityScenesPaths.PathType.EntitiesBinary, EntityScenesPaths.GetSectionIndexFromPath(artifactPath)); DoCopy(RegisterFileCopy, outputStreamingAssetsDirectory, artifactPath, destinationFile); } else if (ext == refExt) { content.CustomAssets.Add(new CustomContent { Asset = sceneBuildConfigGuid, Processor = (guid, processor) => { var sectionIndex = EntityScenesPaths.GetSectionIndexFromPath(artifactPath); processor.GetObjectIdentifiersAndTypesForSerializedFile(artifactPath, out ObjectIdentifier[] objectIds, out Type[] types);