public override void Init() { base.Init(); m_GOPoolService = ServiceMgr.GetServiceMgr().GetService <GameObjectPoolService>(); m_ResService = ServiceMgr.GetServiceMgr().GetService <ResourceService>(); UnityActor unityActor = (UnityActor)Actor; m_GameObject = unityActor.GameObject; UpdateRenderObject(); }
private async void UpdateRenderObject() { if (m_ResService == null) { return; } if (m_GOPoolService == null) { return; } m_Prototype = await m_ResService.GetAsync <GameObject>(new ResourcePath(ResourcePath.PathType.Resource, m_PrefabName)); if (m_Prototype == null) { Debug.LogError("prefab: " + m_PrefabName + "load failed"); return; } if (m_Destroyed) { return; } GameObjectPoolService.AquireResult res = m_GOPoolService.Acquire(m_Prototype, false); m_RenderObject = res.GameObject; m_RenderObject.transform.localScale = m_Scale; ActorProxy proxy = null; if (!res.Pooled) { proxy = m_RenderObject.AddComponent <ActorProxy>(); } else { proxy = m_RenderObject.GetComponent <ActorProxy>(); } proxy.Actor = Actor; UnityActor unityActor = (UnityActor)(Actor); Utils.Attach(unityActor.GameObject, m_RenderObject); m_RenderObject.SetActive(true); }