본문 바로가기
728x90

Unity/FAS project 코드 정리9

Button Click Timer 설정 1. using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class ButtonTimer : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { [SerializeField] float SetTime; float timeremain; Button UIButton; void Start() { UIButton = GetComponent(); timeremain = SetTime; } public void OnPointerEnter(PointerEventData eventData) { InvokeRepeating("countDown", 0, Time.deltaTime.. 2020. 12. 13.
Button 클릭 시, Sound 효과 설정 1. UI Button 생성 2. Audio Source 생성 3. Audio 적용 파일 ( wav, mp4, mp3 등 )을 프로젝트 창으로 입력해두기. 4. Code 작성 using UnityEngine; public class ButtonSound : MonoBehaviour { public AudioSource ButtonAudio => GetComponent(); public AudioClip OnHover, OnEnter; public void SoundHover() { ButtonAudio.playOnAwake = false; ButtonAudio.PlayOneShot(OnHover); } public void SoundEnter() { ButtonAudio.playOnAwake = fals.. 2020. 12. 13.
Camera 인식 범위 조정 1. Camera의 속성을 확인하고, Debug mode를 통하여 접근 명칭 알아내기 using UnityEngine; public class PlayerMove : MonoBehaviour { public Camera camera; public float camera_time = 0; void Update() { CameraClip(); } void CameraClip() { camera_time = 1 * Time.time; camera_time++; Debug.Log(camera_time); if (camera_time >= 2000 ) { camera.farClipPlane = 100; } if (camera_time < 500) { camera.nearClipPlane = 0.5f; } } } .. 2020. 12. 13.
Skybox 회전하기 1. Asset Store에서 Skybox Material Download 2. Skybox Material을 적용할 Cube Object 1개 생성 3. Code 적용 using UnityEngine; public class Skybox : MonoBehaviour { void Update() { RenderSettings.skybox.SetFloat("_Rotation", Time.deltaTime + 10); } } ** 강사님의 도움으로 작성한 코드이나, 실제 작용이 안되었으므로, 다시 공부하면서 어떻게 작용하는 것인지 확인할 예정 2020. 12. 13.