public virtual Toggle GenerateTab(Toggle original) { var newUI = GameObjectUtils.InstantiateInactive(original.gameObject); newUI.GetComponentInChildren <XlateText>(true).key = NameKey; var toggle = newUI.GetComponent <Toggle>(); toggle.onValueChanged = GetOnSelectAction(); newUI.transform.SetParent(original.transform.parent, false); newUI.SetActive(true); return(toggle); }
public GameObject SpawnTriggersTutorial(int num) { GameObject triggerPrefab = (GameObject)Resources.Load("NinjaTrigger" + num.ToString()); Vector3 triggerLocation; switch (num) { case 1: triggerLocation = new Vector3(-4.5f, -2.7f, 0); break; case 2: triggerLocation = new Vector3(-3.3f, -1.4f, 0); break; case 3: triggerLocation = new Vector3(-1.8f, 0.25f, 0); break; case 4: triggerLocation = new Vector3(0.05f, 1.3f, 0); break; case 5: triggerLocation = new Vector3(2f, 2f, 0); break; case 6: triggerLocation = new Vector3(4f, 2.4f, 0); break; default: triggerLocation = new Vector3(0, 2.8f, 0); break; } //instantiate trigger GameObject triggerObject = GameObjectUtils.AddChild(spawnParent, triggerPrefab); triggerObject.transform.position = triggerLocation; triggerObject.transform.localEulerAngles = triggerPrefab.transform.localEulerAngles; Rigidbody triggerObjectRigidbody = triggerObject.GetComponent <Rigidbody>(); triggerObjectRigidbody.useGravity = false; triggerObjectRigidbody.constraints = RigidbodyConstraints.None; triggerObjectRigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY; return(triggerObject); }
public GameObject InstantiatePrefab(GameObject prefabObject) { GameObject prefabInstance = null; if (prefabObject != null) { prefabInstance = GameObjectUtils.SafeInstantiate(prefabObject); prefabInstance.name = prefabObject.name; } return(prefabInstance); }
// Loads the prefab and inits the prefab's PopupController values public IEnumerator ShowPopup(string prefabName, string title, string message, PopupController.Callback specialButtonCallback) { GameObject popupRef = Resources.Load <GameObject>(prefabName); GameObject popup = GameObjectUtils.AddChildGUI(gameObject, popupRef); PopupController controller = popup.GetComponent <PopupController>(); controller.Init(title, message, specialButtonCallback); yield return(0); // Wait a frame for the popup to finish controller.ShowPopup(); }
private void InitHideItem() { GameObjectUtils.CreateChilds(this.m_content, this.m_itemGameobj.transform, this.m_childCount); for (int i = 0; i < this.m_childCount; i++) { GameObject gameObject = this.m_content.transform.GetChild(i).gameObject; gameObject.transform.localPosition = this.m_itemPosDic[i]; gameObject.transform.localScale = Vector3.one; gameObject.name = i.ToString(); AItemHandler aBaseItemHandler = gameObject.GetComponent <AItemHandler>(); if (aBaseItemHandler == null) { aBaseItemHandler = (gameObject.AddComponent(this.m_handlerType) as AItemHandler); aBaseItemHandler.Init(); aBaseItemHandler.dataType = this.m_dataType; } if (this.m_dataList != null) { aBaseItemHandler.Show(i, this.m_dataList[i]); } else { aBaseItemHandler.Show(i, null); } aBaseItemHandler.initPos = this.m_itemPosDic[i]; if (!this.m_handlerDic.ContainsKey(i)) { this.m_handlerDic.Add(i, aBaseItemHandler); } else { this.m_handlerDic[i] = aBaseItemHandler; } } this.ScrollRectEvent(Vector2.zero); int num = (this.m_itemIdIntUp - 1) * this.m_constraintCount; if (num > 0 && this.m_childCount > num) { for (int j = 0; j < num; j++) { this.m_handlerDic[j].trans.gameObject.SetActive(false); } } num = (this.m_itemIdIntDown + 1) * this.m_constraintCount; if (num > 0 && this.m_childCount > num) { for (int k = num; k < this.m_childCount; k++) { this.m_handlerDic[k].trans.gameObject.SetActive(false); } } }
private void ItemStackClear() { if (this.m_itemStack.Count > 0) { for (int i = 0; i < this.m_itemStack.Count; i++) { GameObject obj = this.m_itemStack.Pop(); UnityEngine.Object.DestroyImmediate(obj); } } GameObjectUtils.DestroyChilds(this.m_poolObj.transform); }
void Awake() { if (instance != null) { GameObjectUtils.Destroy(gameObject); } else { instance = this; CreateParticleSystemPool(); } }
/// <summary> /// Генерация меша. /// </summary> /// <param name="worldLength">Длина мира</param> /// <param name="worldWidth">Высота мира</param> public Grid <RendererObject> GenerateMesh(int worldLength, int worldWidth) { // Поиск и очистка родительского объекта var tileParentTransform = transform.Find("tileParent"); if (tileParentTransform == null) { tileParent = new GameObject("tileParent"); tileParent.transform.parent = transform; } else { tileParent = tileParentTransform.gameObject; } // Очищение потерянных объектов if (tileParent.transform.childCount > 0) { GameObjectUtils.DestroyAllChildrens(tileParent.transform); } ClearGrid(); if (TileGridVisual != null) { throw new Exception("Tile grid visual не очищен перед инициализацией"); } TileGridVisual = new Grid <RendererObject>(worldLength, worldWidth, tileSizeHorizontal, tileSizeVertical); if (TileGridVisual != null || TileGridVisual.Count != 0) { // Определяем базис SetIsoBasis(); // Генерируем меш TileGridVisual.ForEachSet((x, y) => { var cell = MeshUtils.CreateDiamondMesh(tileSizeHorizontal, tileSizeVertical) .TransformToRenderer(tileMaterial, "tileMesh"); cell.transform.parent = tileParent.transform; cell.transform.position = IsoBasis.GetIsoVector(x, y); return(cell); }); } return(TileGridVisual); }
public void SetUpSlots() { GameObjectUtils.ClearChildren(container.transform); _slots.Clear(); OnStackUpdate = null; int index = 0; //WeaponSlotSetup if (weaponItemStackSlot != null) { weaponItemStackSlot.Init(index++, _weaponInventory.GetStackAtSlot(0), this, 0, _weaponInventory); _slots.Add(weaponItemStackSlot); } int armorIndex = 0; //ArmorSlotSetup foreach (IItemStackSlot slot in armorItemStackSlots) { if (slot == null) { continue; } slot.Init(index++, _armorInventory.GetStackAtSlot(armorIndex), this, armorIndex++, _armorInventory); _slots.Add(slot); } //ItemInventorySetup if (slotPrefab == null) { return; } int itemIndex = 0; foreach (ItemStack stack in _itemInventory.GetItemStacks()) { GameObject slotObj = Instantiate(slotPrefab, container.transform); if (!slotObj.TryGetComponent(out IItemStackSlot slot)) { continue; } slot.Init(index++, stack, this, itemIndex++, _itemInventory); _slots.Add(slot); OnStackUpdate += slot.UpdateUi; } UpdateSlots(); }
// MonoBehaviour's interface protected override void Awake() { base.Awake(); // Get Component. m_ObjectPoolController = GetComponent <ObjectPoolController>(); // UI if (m_CountdownPanelPrefab != null) { tnPanel_Countdown countdownPanel = Instantiate <tnPanel_Countdown>(m_CountdownPanelPrefab); countdownPanel.transform.SetParent(transform, true); m_CountdownPanel = countdownPanel; } if (m_EndGamePanelPrefab != null) { tnPanel_EndGame endGamePanel = Instantiate <tnPanel_EndGame>(m_EndGamePanelPrefab); endGamePanel.transform.SetParent(transform, true); m_EndGamePanel = endGamePanel; } if (m_FlatBackgroundPanelPrefab != null) { tnPanel_FlatBackground flatBackgroundPanel = Instantiate <tnPanel_FlatBackground>(m_FlatBackgroundPanelPrefab); flatBackgroundPanel.transform.SetParent(transform, true); m_FlatBackgroundPanel = flatBackgroundPanel; } if (m_PauseMenuPanelPrefab != null) { tnPanel_PauseMenu pauseMenuPanel = Instantiate <tnPanel_PauseMenu>(m_PauseMenuPanelPrefab); pauseMenuPanel.transform.SetParent(transform, true); m_PauseMenuPanel = pauseMenuPanel; } if (m_InGameOptionsPanelPrefab != null) { tnPanel_InGameOptions inGameOptionsPanel = Instantiate <tnPanel_InGameOptions>(m_InGameOptionsPanelPrefab); inGameOptionsPanel.transform.SetParent(transform, true); m_InGameOptionsPanel = inGameOptionsPanel; } m_LoadingPanel = GameObjectUtils.FindObjectWithTag <UIController>(s_Loading_Tag); }
private void Awake() { //SINGLETON if (instance == null) { instance = this; } else { GameObjectUtils.DebugErrorStop("Multiple instances of singleton."); } //SINGLETON }
static GameObject CreateIdInstanceInternal <T>(string id) where T : IdHandler { if (!idHandlerPrefabs.TryGetValue(typeof(T), out var gameObj)) { return(null); } var newG = GameObjectUtils.InstantiateInactive(gameObj); newG.GetComponent <T>().director = GlobalIdDirector; GlobalIdDirector.persistenceDict[newG.GetComponent <T>()] = ModdedStringRegistry.IsModdedString(id) ? id : ModdedStringRegistry.ClaimID(GetPrefix <T>(), id); return(newG); }
static public int constructor(IntPtr l) { try { GameObjectUtils o; o = new GameObjectUtils(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int StopMovieShow_s(IntPtr l) { try { UnityEngine.GameObject a1; checkType(l, 1, out a1); GameObjectUtils.StopMovieShow(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public void ShowRetentionPet(bool isFlipped, Vector3 position) { RemoveRetentionPet(); GameObject goResource = Resources.Load("TutorialRetentionPet") as GameObject; goRetentionPet = GameObjectUtils.AddChildGUI(TutorialManager.Instance.UICanvasParent, goResource); goRetentionPet.transform.localPosition = position; if (isFlipped) { goRetentionPet.transform.localScale = new Vector3(-1f, 1f, 1f); } }
protected override void UpdateView() { if (m_model == null) { return; } ChapterNoText.text = string.Format("第{0}章", m_model.ChapterNo); // 根据是否解锁了来展示不同的视图 GameObjectUtils.SetActiveRecursively(LockPanel, !m_model.IsUnlocked); GetComponent <Button>().enabled = m_model.IsUnlocked; }
private void OpenAsEndGameMenu(RecordedScore recordedScore) { if (!recordedScore.IsWinningScoreReached()) { Debug.LogError($"Opening ingame menu as triggered by event `WinningScoreReached`, " + $"but no players have met or surpassed the score: {recordedScore}"); } title.text = recordedScore.IsLeftPlayerWinning() ? "Game Won" : "Game Lost"; subtitle.text = recordedScore.LeftPlayerScore.ToString() + " - " + recordedScore.RightPlayerScore.ToString(); GameObjectUtils.SetButtonActiveAndEnabled(resumeButton, false); ToggleMenuVisibility(true); }
private void HideMaterialList() { // destroy list items foreach (RectTransform t in MaterialList.GetComponentInChildren <RectTransform>()) { if (t != MaterialList) { Destroy(t.gameObject); } } GameObjectUtils.SetActiveForChildren(gameObject, false); }
// shoots a smog ball at the player void ShootSmogBall() { if (!isDead) { AudioManager.Instance.PlayClip("shooterEnemySpit"); animator.SetBool("Spit", true); animator.SetBool("IsSpitMode", false); bulletAux = GameObjectUtils.AddChild(null, bulletPrefab); bulletAux.transform.position = transform.position; LeanTween.moveX(bulletAux, player.transform.position.x, 2.0f); StartCoroutine(WaitASecond()); } }
public static void Create() { Camera c = GameObject.FindObjectOfType <Camera>(); if (c != null) { GameObjectUtils.EnsureComponent <GameCamera>(c.gameObject); } else { MyLogger.LogError("GameCamera", "Create()", "Cannot Find Camera In Scene!"); } }
public virtual System.Collections.IEnumerator Execute() { ActionNode176_obj = Group.gameObject; ActionNode176_state = BoolNode177; // ActionNode while (this.DebugInfo("8cb82bb7-2d9d-452b-ba92-12398c02e1b6", "9cbc95df-ea2c-4181-9c07-104f64e2c26c", this) == 1) { yield return(null); } // Visit GameObjectUtils.setActive GameObjectUtils.setActive(ActionNode176_obj, ActionNode176_state); yield break; }
// in each case we are going to listen to events that tell us to move along protected override void ProcessStep(int nStep) { switch (nStep) { //runs for about 4 sec then starts the game the timer is in the memory game manager case 0: MemoryGameManager.Instance.proceed += MoveAlong; //prompt user to shoot memoryCards = (GameObject)Resources.Load("MemoryTut"); tutBoards = GameObjectUtils.AddChildGUI(GameObject.Find("Canvas"), memoryCards); break; } }
/// <summary> /// 用来加速的按钮 /// </summary> //private ETCButton m_speedUpBtn; #if !UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IOS /// <summary> /// 初始化,用来在当前场景添加GameInput对象 /// </summary> public static void Create() { if (m_instance != null) { throw new Exception("GameInput 不能重复初始化"); } // 实例化GameInput的prefab GameObject prefab = Resources.Load <GameObject>("GameInputForPC"); GameObject go = GameObject.Instantiate(prefab); m_instance = GameObjectUtils.EnsureComponent <GameInput>(go); }
public virtual System.Collections.IEnumerator Execute() { ActionNode178_obj = Group.gameObject; ActionNode178_state = BoolNode179; // ActionNode while (this.DebugInfo("afbc5001-5e11-44c9-bc89-603a26360905", "e0a55816-3c04-4cb8-9bd7-bf22eecabf3f", this) == 1) { yield return(null); } // Visit GameObjectUtils.setActive GameObjectUtils.setActive(ActionNode178_obj, ActionNode178_state); yield break; }
static public int ResetSpin2DAnim_s(IntPtr l) { try { UnityEngine.GameObject a1; checkType(l, 1, out a1); GameObjectUtils.ResetSpin2DAnim(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public virtual System.Collections.IEnumerator Execute() { ActionNode180_obj = Group.gameObject; ActionNode180_state = BoolNode181; // ActionNode while (this.DebugInfo("b2ad6fce-fbce-434c-85b3-e9976fbed7a4", "fa8d044e-dfc4-489d-a365-7c4b08bc0a19", this) == 1) { yield return(null); } // Visit GameObjectUtils.setActive GameObjectUtils.setActive(ActionNode180_obj, ActionNode180_state); yield break; }
void Awake() { buttonsToHideWhenPanelIsOpen = GameObjectUtils.FindAllObjectsWithTags <Button>(tagsOfButtonsToHideWhenPanelIsOpen); labelsToHideWhenPanelIsOpen = GameObjectUtils.FindAllObjectsWithTags <TMPro.TextMeshProUGUI>(tagsOfLabelsToHideWhenPanelIsOpen); mainMenuPanelController.SetActionOnStartPressed(() => LoadGame()); mainMenuPanelController.SetActionOnPanelOpen(() => ToggleMenuVisibility(true)); mainMenuPanelController.SetActionOnPanelClose(() => ToggleMenuVisibility(false)); #if UNITY_WEBGL GameObjectUtils.SetButtonActiveAndEnabled(quitButton, false); #endif }
void CreatePacmanLayer() { pacmanLayer = new Layer("PacmanLayer", gameObject.transform.position, Width, Height); GameObjectUtils.AppendChild(gameObject, pacmanLayer.LayerGameObject); pacmanLayer.LayerGameObject.transform.position = Vector3.zero; int pacmanX = Random.Range(0, Width); int pacmanY = Random.Range(0, Height); pacmanLayer.AddTileFromPrefab(PacmanPrefab, pacmanX, pacmanY); CreatePacdot(); }
void Awake() { if (_instance == null) { _instance = this; SetPosition(); } else { Debug.LogWarning("Instance of CameraController already exists. Destroying duplicate."); GameObjectUtils.Destroy(gameObject); } }
public virtual System.Collections.IEnumerator Execute() { ActionNode146_obj = Group.gameObject; ActionNode146_state = BoolNode147; // ActionNode while (this.DebugInfo("291ffeaa-dbda-403c-b412-a656b50143bf", "62210118-65dd-4da2-ab94-1e4f97490b50", this) == 1) { yield return(null); } // Visit GameObjectUtils.setActive GameObjectUtils.setActive(ActionNode146_obj, ActionNode146_state); yield break; }