public void Resize(int count) { if (instance == null) { return; } if (count == cachedObjects.Count) { return; } if (count < cachedObjects.Count) { var deleteCount = cachedObjects.Count - count; for (var i = 0; i < deleteCount; i++) { var item = cachedObjects.Dequeue(); UnityUtility.DeleteGameObject(item); } } else { var addCount = count - cachedObjects.Count; var items = UnityUtility.Instantiate <T>(instance, prefab, addCount); foreach (var item in items) { Release(item); } } }
private void SetupHitBox() { if (hitBoxEnable) { var parent = scrollRect.viewport; if (hitBox == null) { hitBox = UnityUtility.CreateGameObject <GraphicCast>(parent.gameObject, "HitBox"); } else { UnityUtility.SetParent(hitBox, parent); } // HitBoxは全域使用. var rt = hitBox.transform as RectTransform; rt.FillRect(); } else { UnityUtility.DeleteGameObject(hitBox); } }
public void Delete(string identifier) { var advObject = advObjects.GetValueOrDefault(identifier); advObjects.Remove(identifier); UnityUtility.DeleteGameObject(advObject); }
public void DeleteAll() { foreach (var item in advObjects.Values) { UnityUtility.DeleteGameObject(item); } advObjects.Clear(); }
//----- field ----- //----- property ----- //----- method ----- protected static void ModifyComponent(GameObject rootObject) { var canvasRenderers = rootObject.DescendantsAndSelf().OfComponent <CanvasRenderer>(); foreach (var canvasRenderer in canvasRenderers) { var gameObject = canvasRenderer.gameObject; var graphicComponents = gameObject.GetComponents <Graphic>(); if (graphicComponents.Any()) { continue; } UnityUtility.DeleteGameObject(canvasRenderer); EditorUtility.SetDirty(gameObject); } }
public void Clean() { foreach (var scenePopup in scenePopups) { UnityUtility.DeleteGameObject(scenePopup); } scenePopups.Clear(); UnityUtility.SetParent(touchBloc.gameObject, parentGlobal.Parent); UnityUtility.SetLayer(parentGlobal.Parent, touchBloc.gameObject, true); if (globalPopups.IsEmpty()) { if (touchBlocDisposable != null) { touchBlocDisposable.Dispose(); touchBlocDisposable = null; } touchBloc.Hide(); touchBloc.transform.SetSiblingIndex(0); } }
void OnDestroy() { UnityUtility.DeleteGameObject(eventTrigger); }