private void OnGUI() { if (GUILayout.Button("Click1")) { if (m_IObjectPoo01.CanSpawn("对象池01_对象1")) { Debug.Log((m_TempObj = m_IObjectPoo01.Spawn("对象池01_对象1").Target as GameObject).name); } } if (GUILayout.Button("Click2")) { m_IObjectPoo01.Unspawn(m_TempObj); } if (GUILayout.Button("Click3")) { m_Target = gameObject.Spawn <OPDemo>("对象池03_对象1", "对象1"); } if (GUILayout.Button("Click4")) { m_Target.Unspawn <OPDemo>("对象池03_对象1"); } }
/// <summary> /// 加载资源代理轮询。 /// </summary> /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param> /// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param> public void Update(float elapseSeconds, float realElapseSeconds) { if (m_WaitingType == WaitingType.None) { return; } if (m_WaitingType == WaitingType.WaitForAsset) { if (IsAssetLoading(m_Task.AssetName)) { return; } m_WaitingType = WaitingType.None; AssetObject assetObject = m_AssetPool.Spawn(m_Task.AssetName); if (assetObject == null) { TryLoadAsset(); return; } OnAssetObjectReady(assetObject); return; } if (m_WaitingType == WaitingType.WaitForDependencyAsset) { LinkedListNode <string> current = m_LoadingDependencyAssetNames.First; while (current != null) { if (!IsAssetLoading(current.Value)) { LinkedListNode <string> next = current.Next; if (!m_AssetPool.CanSpawn(current.Value)) { OnError(LoadResourceStatus.DependencyError, string.Format("Can not find dependency asset object named '{0}'.", current.Value)); return; } m_LoadingDependencyAssetNames.Remove(current); current = next; continue; } current = current.Next; } if (m_LoadingDependencyAssetNames.Count > 0) { return; } m_WaitingType = WaitingType.None; OnDependencyAssetReady(); return; } if (m_WaitingType == WaitingType.WaitForResource) { if (IsResourceLoading(m_Task.ResourceInfo.ResourceName.Name)) { return; } ResourceObject resourceObject = m_ResourcePool.Spawn(m_Task.ResourceInfo.ResourceName.Name); if (resourceObject == null) { OnError(LoadResourceStatus.DependencyError, string.Format("Can not find resource object named '{0}'.", m_Task.ResourceInfo.ResourceName.Name)); return; } m_WaitingType = WaitingType.None; OnResourceObjectReady(resourceObject); return; } }