void _InitGame() { #region variable GameObject obj; int Scene = PlayerPrefs.GetInt("Scene"); #endregion #region UI canvasUI.currentLevelText.text = "Level " + (Scene + 1); #endregion #region Init Background Script bool isActive = false; foreach (var value in backGroundList) { if (value.active) { isActive = true; } } if (!isActive) { int randomInt = Random.Range(0, backGroundList.Count); backGroundList[randomInt].SetActive(true); } #endregion #region Init Position Single Objects obj = campfire; obj.transform.position = obj.GetComponent <Campfire>().scenePos[Scene]; ActiveObjectPosition(obj); #endregion #region Init Position Array Objects SetPositionArray(rockObjs, Scene); SetPositionArray(pathObjs, Scene); SetPositionArray(barrelObjs, Scene); SetPositionArray(stone, Scene); SetPositionArray(enemyObjs, Scene); #endregion #region NavMeshSurface baked Settings - (Note : new Object should add script_Name: Nav Mesh Surface) NavMeshSurface[] listSurface = GameObject.FindObjectsOfType <NavMeshSurface>(); for (int i = 0; i < listSurface.Length; i++) { if (listSurface[i].isActiveAndEnabled) { listSurface[i].BuildNavMesh(); } } #endregion #region Init Particle Controller particleController.dad = new GameObject("Particle Objects"); particleController.childrenSmoke = new GameObject("SmokeEffect"); particleController.childrenLightning = new GameObject("Lightning Effect"); particleController.childrenRock = new GameObject("Rock Effect"); /* Effect */ GameObject smokeEffect = particleController.smokeEffect; GameObject lightningEffect = particleController.lightningStrikeEffect; GameObject rockEffect = particleController.rockEffect; /* Parent Objects */ GameObject dad = particleController.dad; GameObject childrenSmoke = particleController.childrenSmoke; GameObject childrenLightning = particleController.childrenLightning; GameObject childrenRock = particleController.childrenRock; childrenSmoke.transform.SetParent(dad.transform); childrenLightning.transform.SetParent(dad.transform); childrenRock.transform.SetParent(dad.transform); /* Create Effect */ int Count = 0; for (int i = 0; i < enemyObjs.transform.childCount; i++) { GameObject value = enemyObjs.transform.GetChild(i).gameObject; if (value.active) { ++Count; } } particleController.CreateEffect(smokeEffect, Count, childrenSmoke); particleController.CreateEffect(lightningEffect, Count, childrenLightning); Count = 0; for (int i = 0; i < stone.transform.childCount; i++) { GameObject value = enemyObjs.transform.GetChild(i).gameObject; if (value.active) { ++Count; } } particleController.CreateEffect(rockEffect, Count, childrenRock); #endregion #region Init Enemy Animator for (int i = 0; i < enemyObjs.transform.childCount; i++) { GameObject value = enemyObjs.transform.GetChild(i).gameObject; if (value.activeSelf) { value.GetComponent <Enemy>()._Animator(); } } #endregion }