728x90 Unity3D54 Unity & C# ~ Lightmap 교체 public float powerOutageDuration = 3f;// 직렬화[Serializable]public class LightMapClone{ public Texture2D _dir; public Texture2D _light; public Texture2D _shadow;}public LightMapClone[] _lightmaps;private LightmapData[] savedLightMaps;private void Update(){ if (Input.GetKeyDown(KeyCode.Escape)) { StartCoroutine(SimulatePowerOutage()); }}private IEnumerator SimulatePowerOut.. 2025. 3. 19. Unity & C# ~ Object Pool using System.Collections.Generic;using UnityEngine;public class ObjectPool : MonoBehaviour{ private static ObjectPool instance = null; private static object _syncObj = new object(); public static ObjectPool Instance { get { lock (_syncObj) { if (instance == null) { ObjectPool objs = FindObjectOfT.. 2024. 10. 19. Unity & C# ~ 시간을 나타내는 법(float to string) float timeValue = 90; // second try { string time1 = string.Format("{0:#0}:{1:00}", Mathf.Floor(timeValue / 60), Mathf.Floor(timeValue) % 60); Debug.Log($"Change time second : {time1}"); } catch(Exception e) { Debug.LogError($"timeValue error {e}"); } try { string time2 = string.Format("{0:00}:{1:00}", Mathf.Floor(timeValue / 60), Mathf.Floor(timeValue) % 60); Debug.Log($"Change time second2 : {.. 2023. 11. 3. Unity & C# ~ 한/영 전환 하는 클래스 using System; using System.Diagnostics; using System.Runtime.InteropServices; public class ImeChange { #region imm32.dll :: Get_IME_Mode IME가져오기 [DllImport("imm32.dll")] public static extern IntPtr ImmGetContext(IntPtr hWnd); [DllImport("imm32.dll")] public static extern bool ImmSetConversionStatus(IntPtr hIMC, int fdwConversion, int fdwSentence); [DllImport("imm32.dll")] private static extern I.. 2023. 6. 29. Unity & C# ~ 이미지 파일을 로드하여 스프라이트로 만들기 (Image file Load to Sprite) - 저장된 이미지 경로를 가지고 이미지를 로드하여 스프라이트로 형 변환을 한 후, 유니티 image ui에 넣기 using System.IO; using UnityEngine; using UnityEngine.UI; public Image image;// unity ui image public string filePath;// image file path public Vector2 imageSize;// image size x : width, y : height public void LoadImage() { byte[] byteTexture = File.ReadAllBytes(filePath);// 파일 불러오기 Texture2D texture2d = new Texture2D((int)imageSize... 2023. 3. 14. Unity & C# ~ JsonConvert 사용법 using System; using System.IO; using UnityEngine; using Newtonsoft.Json; //serializable data [Serializable] public class TestData { public string testStr; public TestData(string _inputString) { testStr = _inputString; } } public class TestJson : MonoBehaviour { // Start is called before the first frame update void Start() { //load string filePath = Application.dataPath + "/TestData.json"; string.. 2023. 2. 24. 이전 1 2 3 4 ··· 9 다음 SMALL