728x90 Unity3D/Unity & C#44 Unity & C# ~ 문자열에서 단어 검색 방법 string factMessage = "Extension methods have all the capabilities of regular static methods."; // Write the string and include the quotation marks. Console.WriteLine($"\"{factMessage}\""); // Simple comparisons are always case sensitive! // 문자열에 검색할 단어가 있는지 확인 bool containsSearchResult = factMessage.Contains("extension"); Console.WriteLine($"Contains \"extension\"? {containsSearchResult}"); // F.. 2022. 10. 24. Unity & C# ~ 두 오브젝트의 색상과 이미지가 중복되지 않는 랜덤 출력 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class TestRandomObjectsColor : MonoBehaviour { [SerializeField] List RanColors; // 사용될 색상 [SerializeField] List RanObjects; // 1번 이미지에 사용될 이미지들 [SerializeField] List RanObjects1; // 2번 이미지에 사용될 이미지들 private Coroutine RanCoroutine = null; private int ColorValue { get; set; } // 1번 이미지 색상 값 .. 2022. 10. 7. Unity & C# ~ Crop Image using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class TestCropTexture : MonoBehaviour { public Texture2D sourceImg; // 소스 이미지 public Image img; // Image UGUI // Start is called before the first frame update void Start() { TestCrop(); } void TestCrop() { var tex = sourceImg.GetRawTextureData(); // 소스 이미지 텍스쳐 RAW DATA 변환 // 소스 이미지 texture.. 2022. 10. 7. Unity & C# ~ Mic 음성을 Spectrum 표현하기 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; [RequireComponent(typeof(AudioSource))] public class AudioSourceGetSpectrumDataExample : MonoBehaviour { [SerializeField] private Image bar; // 원본 막대 prefab [SerializeField] private Transform trBarParent; // 막대 부모 // 스펙트럼 표현 막대들 // Canvas 하위 객체 private RectTransform[] bars = new RectTransform[128.. 2022. 10. 5. Unity & C# ~ string.Format 글자 색상 적용 [SerializeField] Text text; void Start() { Color c = Color.blue; text.text = string.Format($"Text"); } 2022. 9. 26. Unity & C# ~ Text 형식 표기법(NO, F0, P0, D0 등) 실수 소수점 표기 F //F0 String s = float.parse("1.11").ToString("F0"); => 1 //F1 String s = float.parse("1.11").ToString("F1"); => 1.1 //F2 String s = float.parse("1.11").ToString("F2"); => 1.11 실수 자릿수 및 천단위 표기 N //N0 String s = float.parse("1111.11").ToString("N0"); => 1,111 //N1 String s = float.parse("1111.11").ToString("N0"); => 1,111.1 //N2 String s = float.parse("1111.11").ToString("N0"); => 1,11.. 2022. 8. 22. 이전 1 2 3 4 5 6 ··· 8 다음 SMALL