본문 바로가기

Unity/C# 문법12

[유니티] Mathf using System.Collections; using System.Collections.Generic; using UnityEngine; public class MathfTest : MonoBehaviour { // Start is called before the first frame update void Start() { //절대값 : Mathf.Abs(float) float absVal = Mathf.Abs(-10f); Debug.Log("Mathf.Abs(절대값) : " + absVal); //최소 , 최대 제한 float limit = Mathf.Clamp(9f, 10f, 20f); Debug.Log("Mathf.Clamp(값, 최소값, 최대값) : " + limit); //올림, 버림, 반올.. 2021. 5. 6.
[유니티] 제네릭 문법 ********************************* Generic 안 썼을때 막 코드 ********************************* 1. Stack 스택 제한적으로 접근할 수 있는 나열 구조 여러가지 아이템을 먹었을 때 먼저 먹은 아이템부터 사용하고 싶을때 ex) 카트라이더 using System.Collections; using System.Collections.Generic; using UnityEngine; public class CStackInt { int emptyStack; int[] items; int top; int size; public CStackInt(int size) { this.size = size; items = new int[size]; emptyStac.. 2021. 5. 6.
[유니티] 3D 게임 기본문법 1. Asset 다운받기 Stylized Grass Texture Import Micro Dragon Fino - Faceted style Import Cartoon FX Free Import 2. 스프라이트 Prefabs -> Micro_Dragon_fino 드래그 3. 애니메이션 폴더 만들기 Create -> Animations 폴더 생성 -> MicroDragon 폴더 생성 -> Animator Controller 생성 이름 바꾸기 MicroDragonAnimator 기존 Animations 폴더안에 idle 애니메이션 복제 -> 새로 만든 애니메이션 폴더에 붙여넣기 Animator에 idle 드래그 MicroDragon의 Amiator Controller에 드래그&드롭 재생해보면 스프라이트가 마구.. 2021. 5. 4.
[유니티] 객체 배열/업캐스팅 1. 배열 사용전/후 using System.Collections; using System.Collections.Generic; using UnityEngine; //속성 메소드 중복 => 수정해야할때 문제가 될 수 있음 //=> 상속으로 해결! public class HumanBefore { public string name; //중복 public int hp; //중복 public int damage; //중복 public int level; public int gravity; public string talkMessage; public void Talk() { Debug.Log(name + "대화내용 : " + talkMessage); } //중복 public void Move() { Debug.L.. 2021. 4. 27.