응용프로그램/유니티(Unity) 57

Unity - Editor 개념 및 사용

※ 참조 Sebastian Lague 나르메님 블로그 에디터1 나르메님 블로그 에디터2 유니티 EditorGUILayout 레퍼런스 (데이터 타입 모음) 유니티 GUILayout 레퍼런스 (게임 실행시의 GUI 모음) Editor란 무었일가? - Inspector 변경값을 실시간으로 반영하고 싶을 때 사용. - 아래의 그림과 같은 Inspector에 팝업형태의 버튼을 넣고 싶을때 사용 Editor의 사용 반드시 Editor라는 폴더에 스크립트가 존재해야 동작한다. MapEditor.cs using UnityEditor; [CustomEditor (typeof(MapGenerator)), CanEditMultipleObjects] public class MapEditor : Editor{ public ov..

Unity - 근접했을때도 발사체 동작하게 하기

근접했을때도 발사체 동작하게 하기 출처 : Sebastian Lague Projectile.cs using UnityEngine; using System.Collections; public class Projectile : MonoBehaviour { public LayerMask collisionMask; float speed = 10; float damage = 1; float lifetime = 3; float skinWidth = 0.1f; void Start() { Destroy(gameObject, lifetime); Collider[] initialCollisions = Physics.OverlapSphere (transform.position, 0.1f, collisionMask); // ..

Unity - 적 공격으로 Player에게 데미지 입히기

적 공격으로 Player 데미지 입히기 출처 : Sebastian Lague IDeamageable.cs using UnityEngine; public interface IDamageable { void TakeHit(float damage, RaycastHit hit); void TakeDamage(float damage); } LivingEntity.cs using UnityEngine; using System.Collections; public class LivingEntity : MonoBehaviour, IDamageable { public float startingHealth; protected float health; protected bool dead; public event System...

Unity - 스폰 시스템 만들기

스폰시스템 만들기 출처 : Sebastian Lague LivingEntity에서 아래의 코드를 잘 삽입~ public event System.Action OnDeath; if (OnDeath != null) { OnDeath(); //죽을때마다. 이벤트가 들어감 } Spawner.cs using UnityEngine; using System.Collections; public class Spawner : MonoBehaviour { public Wave[] waves; public Enemy enemy; int enemiesRemainingToSpawn; int enemiesRemainingAlive; float nextSpawnTime; Wave currentWave; int currentWaveNu..

Unity - 데미지 시스템

데미지 시스템 출처 : Sebastian Lague 상속과 오버라이드 virtual, override base.start(); 변수의 접근제한 protected interface IDamageable.cs using UnityEngine; public interface IDamageable { void TakeHit(float damage, RaycastHit hit); } LivingEntity.cs using UnityEngine; using System.Collections; public class LivingEntity : MonoBehaviour, IDamageable { public float startingHealth; protected float health; protected bool d..

Unity - 충돌감지관련

충돌감지관련 출처 : Sebastian Lague의 동영상 강의 using UnityEngine; using System.Collections; public class Projectile : MonoBehaviour { public LayerMask collisionMask; float speed = 10; public void SetSpeed(float newSpeed) { speed = newSpeed; } void Update () { float moveDistance = speed * Time.deltaTime; CheckCollisioins(moveDistance); transform.Translate(Vector3.forward * Time.deltaTime * speed); } void Ch..

유니티 DB 사용하기

유니티 DB관련 참고자료 SQLite 소개 http://www.csharpstudy.com/Practical/Prac-sqlite.aspx c#으로 SQLite 연결하기 http://answers.unity3d.com/questions/743400/database-sqlite-setup-for-unity.htmlhttp://nsinc.tistory.com/127 보조도구 http://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki 예제 http://forum.unity3d.com/threads/tutorial-how-to-integrate-sqlite-in-c.192282/ http://www.codeproject.com/Articles/6343/..

Unity - 3D게임만들기(Ray로 오브젝트 방향전환)

Ray로 오브젝트 방향전환하기 오브젝트를 생성한뒤 소스코드를 붙이고 아래의 코드를 실행하면 됩니다. Player.cs using UnityEngine; using System.Collections; [RequireComponent (typeof(PlayerController))] public class Player : MonoBehaviour { public float moveSpeed = 5; Camera viewCamera; PlayerController controller; void Start () { controller = GetComponent(); viewCamera = Camera.main; } void Update () { Vector3 moveInput = new Vector3(Input..