Loading...

Texture2D Alpha channel

내가원하는 것은 간단하다1. 원하는 텍스처를 가져온다2. 해당 텍스처의 알파값을 가져온다3. 새 텍스처에 알파값을 넣는다. 이를 위해 알아야 할 것은 아래와 같다.1. 텍스처 정보값을 얻기 위해 GetPixel, SetPixel을 쓰려면 해당 텍스처가 Read/Write Enabled 옵션이 설정되어 있어야 한다. 2. 이상하게 RGB16으로하면 안된다. RGB32로 해야 한다. 3. 이건 왠지 유니티 버그인듯 한데 GetPixel() 함수를 사용하면 제대로 값을 가져오지 못한다 그런데 GetPixels() 함수로 값을 가져와서 for loop을 돌면서 SetPixel()을 사용하면 제대로 된다. Texture2D destTex = new Texture2D(sourceTex.width, sourceTex..

2015. 7. 7. 20:30

unity 에서 log보기

우선 이클립스를 깔아준다.그 후에 아래의 과정을 거친다. 1. Show View - Other 2. LogCat 클릭 3. 아래쪽 버튼을 눌러준다. 4. Unity 라고 넣어준다.

singleton

언제나 많이 쓰는 싱글톤.유니티 c# 스크립트 버전도 검색하면 많이 나옴. 그냥 그대로 써도 되긴 하지만 기본적으로 유니티는 신 전환시신에 올라와 있는 오브젝트를 다 날려버려서 두가지 버전의 싱글톤을 사용하고 있다.첫번째 버전은 현재 신 버전에서만 유용한 녀석. 가벼운 녀석이다. public class Singleton : MonoBehaviour where T : MonoBehaviour { protected static T instance; //Returns the instance of this singleton public static T Instance { get { if (instance == null) { instance = (T)FindObjectOfType(typeof(T)); if (in..

2015. 2. 18. 10:16

C# keywords

요즘 유니티 C# 스크립트 작업중에 가끔 모르는 문법이 나온다.나올때 마다 정리해야지. Partial : 부분적인, 불완전한 1. 우선 파일을 두개 만든다. 2. TestClass.cs 파일의 클래스에 Partial을 사용하여 클래스를 만들고 멤버변수를 추가한다. 3. Program.cs에 TestClass.cs를 Partial과 함께 만들고 Program에서 사용 여기서 중요한 것은 TestClass가 중복되었다는 것과 현재 TestClass버전에는 alpha변수가 없는데사용할 수 있다는 것이다. 결국 partial키워드를 쓰면 따로따로 클래스를 만들 수 있다.허용범위는 컴파일이 한번에 진행되는 모든 곳이며 여러 인원이 작업을 할 때거대한 클래스가 있다면 분담해서 작업할 때 쓰면 좋을 듯 하다. Ref..

2013. 12. 18. 21:00

void OnDrawGizmos()

debug용으로 갠춘한듯. void OnDrawGizmos() { Gizmos.color = Color.red; Gizmos.DrawWireSphere(transform.position, attackRange); Gizmos.color = Color.blue; Gizmos.DrawWireSphere(transform.position, searchRange); }

2013. 11. 16. 14:18

unity - camera smooth follow

if(cameraFollowX) { Vector3 targetPos = new Vector3(cameraTarget.transform.position.x, thisTransform.position.y, thisTransform.position.z); Vector3 localVel = new Vector3(velocity.x, 0.0f, 0.0f); thisTransform.position = Vector3.SmoothDamp(thisTransform.position,targetPos, ref localVel, smoothTime); } if(cameraFollowY) { Vector3 targetPos = new Vector3(thisTransform.position.x, cameraTarget.tran..

2013. 11. 3. 16:12

Unity - Character Controller

케릭터를 스피드값을 이용해서 움직이기. using UnityEngine;using System.Collections; [RequireComponent(typeof(CharacterController))] public class example : MonoBehaviour { public float speed = 3.0F; public float rotateSpeed = 3.0F; void Update() { CharacterController controller = GetComponent(); transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0); Vector3 forward = transform.TransformDirection(Vector..

2013. 10. 30. 22:59

unity - time 출력

파일 : GUILayout.Label을 이용한 왼쪾의 하얀 글자들. GUISkin을 사용하여 폰트 관련 정보를 바꾸는 방법. Sprite 애니메이션으로 폰트를 출력하는 방법.