유니티 심화 86

[복습] SpaceShooter2D - Player, Bullet -> Main으로 옮기기, 오브젝트 풀링 기반 만들기

BulletController using System.Collections; using System.Collections.Generic; using System.Threading; using UnityEngine; public class BulletController : MonoBehaviour { [SerializeField] private float force = 3f; private GameObject targetTr; // Start is called before the first frame update void Start() { this.targetTr = this.GetComponent(); this.targetTr = GameObject.Find("Player"); this.transform..

오브젝트 풀링 - 총알, 이펙트

EffectPoolManager using System.Collections; using System.Collections.Generic; using UnityEngine; public class EffectPoolManager : MonoBehaviour { public static EffectPoolManager instance; //리스트로 이펙트 풀 생성 public List effectPool = new List(); //이펙트 프리팹 가져오기 [SerializeField] private GameObject effectPrefab; //몇개나 할지 max정하기 private int maxEffects = 10; //코루틴 방지 private Coroutine effectRoutine; priva..

유니티 심화 2023.08.28

절대강좌 유니티 - 오브젝트 풀링

사용할 때마다 Instantiate하지말고 미리 만들어놓고 쓰자 GameManager // 오브젝트 풀링 using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; public class GameManager : MonoBehaviour { //public Transform[] points; [SerializeField] private GameObject monsterPrefab; //몬스터 생성 시간 private float createTime = 3.0f; public List points = new List(); //게임 오버 private bool isGameOver = false;..

유니티 심화 2023.08.28

절대강좌 유니티 - 싱글톤, Invoke, CancelInvoke, DontDestroyonLoad

GameManager.p498 using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameManager : MonoBehaviour { public Transform[] points; //public List points = new List(); private void Reset() { Debug.Log("Reset"); } // Start is called before the first frame update void Start() { Transform spawnPointGroup = GameObject.Find("SpawnPointGroup")?.transform; Debug.LogForm..

유니티 심화 2023.08.28

[주말과제/미완] HeroShooter - 총알나가고 삭제

미완 - 총알을 한발씩 발사하고싶은데 어떻게 해야할지 모르겠음[야매로 만들어서 이상함] - 총알맞으면 피격 애니메이션 - 총알 맞고 죽는 애니메이션 - 죽으면 몇초 후 사라지게하기 - 사라진 후 Text와 문 열리기 BulletController using System.Collections; using System.Collections.Generic; using UnityEngine; public class BulletController : MonoBehaviour { [SerializeField] private float bulletSpeed = 500f; private Rigidbody rBody; private int damage = 1; // Start is called before the fir..

유니티 심화 2023.08.28

HeroShooter - 몬스터를 발견하면 공격애니메이션 실행

PlayerController onAttack 대리자만 추가해줘서 몬스터가 인식할 때 대리자를 Main쪽에 부를 수 있게 해주었다. using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class PlayerController : MonoBehaviour { //캐릭터 움직임 속도 [SerializeField] private float moveSpeed = 5f; //애니메이션 private Animator anim; //포탈태그했을 때 publi..

유니티 심화 2023.08.25

절대강좌 유니티 - UI

private void OnGUI() { GUI.Label(new Rect(10, 10, 200, 50), "SpaceShooter"); } https://docs.unity3d.com/kr/2021.2/Manual/UIE-VisualTree.html 시각적 트리 - Unity 매뉴얼 UI 툴킷의 가장 기본적인 빌딩 블록은 시각적 요소입니다. 시각적 요소는 부모-자식 관계가 있는 계층 구조 트리로 정렬됩니다. 아래 다이어그램은 계층 구조 트리의 단순화된 예와 UI 툴킷의 렌 docs.unity3d.com Overlay UI항목들이 가장 상위 계층으로 표현됨. Simple로 하고 Set Native Size하면 원본사이즈로 나온다 Image Type = Filled, Horizontal, Vertical ..

유니티 심화 2023.08.25

[복습 & 추가] HeroShooter - 몬스터 Indicator.. 잘모르는 것들

뭔가 혼자 해보고 해보다가 절대 모르겠어서 카페에 나와있는 코드를 보고 따라해봤다. 따라해봤을 때는 이해가 되는 것들도 있었지만 이해가 되지 않는 것들이 훨씬 많았다. 잘 모르는 것들 https://docs.unity3d.com/ScriptReference/Object.FindObjectOfType.html Unity - Scripting API: Object.FindObjectOfType Object.FindObjectOfType will not return Assets (meshes, textures, prefabs, ...) or inactive objects. It will not return an object that has HideFlags.DontSave set. Please note tha..