protected override void OnUpdate() { // Debug.Log("on OnUpdate role looks system"); var requestArray = SpawnGroup.ToComponentDataArray <RoleLooksSpawnRequest>(Allocator.TempJob); if (requestArray.Length == 0) { requestArray.Dispose(); return; } var requestEntityArray = SpawnGroup.ToEntityArray(Allocator.TempJob); // Copy requests as spawning will invalidate Group var spawnRequests = new RoleLooksSpawnRequest[requestArray.Length]; for (var i = 0; i < requestArray.Length; i++) { spawnRequests[i] = requestArray[i]; PostUpdateCommands.DestroyEntity(requestEntityArray[i]); } for (var i = 0; i < spawnRequests.Length; i++) { var request = spawnRequests[i]; // var playerState = EntityManager.GetComponentObject<RoleState>(request.ownerEntity); var looksInfo = EntityManager.GetComponentData <LooksInfo>(request.ownerEntity); int career = request.career; int body = request.body; int hair = request.hair; // Debug.Log("body : "+body+" hair:"+hair); string bodyPath = ResPath.GetRoleBodyResPath(career, body); string hairPath = ResPath.GetRoleHairResPath(career, hair); // Debug.Log("SpawnRoleLooks bodyPath : "+bodyPath); XLuaFramework.ResourceManager.GetInstance().LoadAsset <GameObject>(bodyPath, delegate(UnityEngine.Object[] objs) { if (objs != null && objs.Length > 0) { GameObject bodyObj = objs[0] as GameObject; GameObjectEntity bodyOE = m_world.Spawn <GameObjectEntity>(bodyObj); var parentTrans = EntityManager.GetComponentObject <Transform>(request.ownerEntity); parentTrans.localPosition = request.position; bodyOE.transform.SetParent(parentTrans); bodyOE.transform.localPosition = Vector3.zero; bodyOE.transform.localRotation = Quaternion.identity; ECSHelper.UpdateNameboardHeight(request.ownerEntity, bodyOE.transform); LoadHair(hairPath, bodyOE.transform.Find("head")); // Debug.Log("load ok role model"); looksInfo.CurState = LooksInfo.State.Loaded; looksInfo.LooksEntity = bodyOE.Entity; EntityManager.SetComponentData <LooksInfo>(request.ownerEntity, looksInfo); } else { Debug.LogError("cannot fine file " + bodyPath); } }); } requestEntityArray.Dispose(); requestArray.Dispose(); }