Skip to content

Instantly share code, notes, and snippets.

View gkagm2's full-sized avatar
😆
..

Sagacity Jang gkagm2

😆
..
View GitHub Profile
@gkagm2
gkagm2 / Distance
Created April 20, 2019 00:16
Uselful API(Distance, Random, FindChild
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class csDistance : MonoBehaviour {
//거리를 구하기 위한 게임 오브젝트들의 트랜스폼을 저장할 변수 선언.
public Transform box1;
public Transform box2;
public Transform box3;
@gkagm2
gkagm2 / AsyncOperation
Last active April 20, 2019 12:59
웹 통신 할 떄의 Coroutine 사용법
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class csCoroutine2 : MonoBehaviour {
//비동기 작업이 끝날 때까지 댁시
public string url; //웹 주소를 저장할 스트링 변수를 퍼블릭으로 선언한다.
WWW www; //WWW 타입의 변수를 선언한다.
@gkagm2
gkagm2 / PlayerPrefs
Created April 20, 2019 14:38
PlayerPrefs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor; // need
public class csGameManager : MonoBehaviour {
// Use this for initialization
void Start () {
@gkagm2
gkagm2 / NGUI Button (GameObject)
Last active April 23, 2019 01:05
NGUI Button을 이용한 Label control
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// 방법 1
public class ButtonManager : MonoBehaviour {
public bool flag = true;
public GameObject label; //GameObject를 이용한다
public void StartBtn()
@gkagm2
gkagm2 / UISprite (change icon)
Created April 25, 2019 07:04
UISprite (NGUI)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpriteManager : MonoBehaviour {
public UISprite icon;
// Use this for initialization
void Start () {
@gkagm2
gkagm2 / touch screen1
Last active April 25, 2019 16:01
Touch Screen (mobile)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TouchScreenEx : MonoBehaviour {
//손가락을 화면에 닿은 상태에서 움직이면 물체가 움직인다
void Update () {
if(Input.touchCount > 0 ){
@gkagm2
gkagm2 / Shader
Created May 20, 2019 08:47
ShaderEx
Shader "Custom/NewSurfaceShader" {
Properties { // 인스펙터 창에서 보여주는
_Brightness("Change Brightness!!", Range(0,1)) = 0.5
_TestFloat("Test Float!!", Float) = 0.5
_TestColor("Test Color!!", Color) = (1,1,1,1)
_TestVector("Test Vector", Vector) = (1,1,1,1)
_TestTexture("Test Texture",2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
Shader "Custom/Tex" {
Properties {
///
/// "Albedo (RGB)" : Albedo 텍스쳐를 넣는 곳이고, 알파는 사용하지 않고 RGB 채널만 사용하겠다는 의미.
/// 2D : 이 인터페이스가 2D 텍스쳐를 받는 부분이라는 의미.
/// "white"{} : 는 이 텍스쳐가 인터페이스가 처음 생겨서 아무것도 들어 있지 않을 때. 흰색 텍스쳐가 들어있다고 생각되도록 만들라는 의미
_MainTex ("Albedo (RGB)", 2D) = "white" {} // 텍스쳐를 입력받는 변수.
}
SubShader {
@gkagm2
gkagm2 / 2D 플레이어 x축 움직임 제한 함수
Created May 30, 2019 17:50
2D 플레이어 x축 움직임 제한 함수
// 2D 플레이어 x축 움직임 제한
private void ScreenCheck(){
Vector3 worldPos = Camera.WorldToViewportPoint(this.transform.position);
if(worldPos.x < 0.05f) worldPos.x = 0.05f;
if(worldPos.x > 0.95f) worldPos.x = 0.95f;
this.transform.position = Camera.main.ViewportToWorldPoint(worldPos);
}
@gkagm2
gkagm2 / CSV Reader
Created June 12, 2019 02:00
csv 파일 검출
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
public class CSVReader
{
static string SPLIT_RE = @",(?=(?:[^""]*""[^""]*"")*(?![^""]*""))";
static string LINE_SPLIT_RE = @"\r\n|\n\r|\n|\r";