반응형
반응형
코드 작성using System;using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class Example : MonoBehaviour{ public float shakeAmount = 3.0f; public float shakeTime = 1.0f; private void Start() { StartCoroutine(Shake(shakeAmount, shakeTime)); } IEnumerator Shake(float ShakeAmount, float ShakeTime) { float timer = 0; ..
코드 작성 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { DateTime today; DateTime now; private void Start() //날짜 디버그 출력 { today = System.DateTime.Today; now = System.DateTime.Now; Debug.Log(today.ToString("yyyy-MM-dd")); Debug.Log(now.ToString("yyyy-MM-dd-hh-mm-ss")); } void AddDateTime() //날짜 ..
코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { private void Start() { StartCoroutine(ExampleCoroutine()); StartCoroutine(Example2Coroutine()); StopAllCoroutine(); //모든 코루틴 정지 } IEnumerator ExampleCoroutine() { Debug.Log("코루틴 실행중"); yield return new WaitForSeconds(1f); StartCoroutine(ExampleCoroutin..
코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SkillManager : MonoBehaviour { [Range(0, 20)] public float skillTime = 10.0f; [Range(0, 20)] public float skillCoolTime = 10.0f; public Image skillFillAmount; public Text skillCoolTimeText; bool isUseSkill = true; private void Awake() { skillInformationText.text = "Skill OFF"; ..
코드 작성 (적용하고 싶은 오브젝트에 적용) using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public Transform target; public float moveSpeed = 1.0f; private void Update() { Vector2 relativePos = target.transform.position - transform.position; float angle = Mathf.Atan2(relativePos.y, relativePos.x) * Mathf.Rad2Deg; transform...
코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { bool isPause = false; void Awake() { Time.timeScale = 1; } public void Pause() { if (!isPause) //정지됨 { isPause = true; Time.timeScale = 0; } else //해제 { isPause = false; Time.timeScale = 1; } } }
코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; public class TouchManager : MonoBehaviour { private Vector2 startPos; public float minSwipeDistY = 50f; public float minSwipeDistX = 50f; private bool firstSwipe = false; public string direction = ""; //Up, Down, Left, Right로 입력이 들어옵니다. void Update() { if (Time.timeScale == 0) { InputButtonUp(); return; } } publ..
코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public int width = 1080; //가로 public int height = 1920; //세로 private void Start() { Screen.SetResolution(width, height, true); } }
유니티 C# 시스템 언어 가져오기 System Language 간단 사용법코드 작성using System.Collections;using System.Collections.Generic;using UnityEngine;public class Example : MonoBehaviour{ void Start() { if (Application.systemLanguage == SystemLanguage.English) { Debug.Log("영어"); } else if (Application.systemLanguage == SystemLanguage.Korean) { Debug.Log("한국어");..
코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Example : MonoBehaviour { void Start() { #if UNITY_EDITOR Debug.Log("유니티 에디터에서 실행"); #elif UNITY_ANDROID Debug.Log("안드로이드에서 실행"); #elif UNITY_IOS Debug.Log("아이폰에서 실행"); #elif UNITY_WEBGL Debug.Log("웹에서 실행"); #endif } } 다른 방법 using System.Collections; using System.Collections.Generic; using UnityEngi..
공전 public class MoonRevolution : MonoBehaviour { public Transform target; [Range(0, 100)] public float rotateSpeed = 10f; private void Update() { transform.RotateAround(target.transform.position, new Vector3(0, 1, 0), rotateSpeed * Time.deltaTime); } } 자전 public class EarthRotation : MonoBehaviour { [Range(0, 100)] public float speed = 25f; private void Update() { transform.Rotate(new Vector3(0,..
Blend Shape이란? 스킨드 매쉬 랜더러 애니메이션을 적용하고 싶을때 사용 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Example : MonoBehaviour { SkinnedMeshRenderer skinnedMeshRenderer; private void Awake() { skinnedMeshRenderer = GetComponent(); } private void OnEnable() { StartCoroutine(SetBlendShapeCoroution(skinnedMeshRenderer)); } private void OnDisable() { StopAllCoroutin..