728x90 유니티40 1개의 Color Gradient를 구간으로 나누기 [SerializeField] Color color1; [SerializeField] Color color2; Color[] colors; float smoothness = 0; public void Function(int _length) { colors = new Color[_length + 1]; for(int i = 0; i < colors.Length; i++) { smoothness += 1f / colors.Length; colors[i] = Color.Lerp(color1, color2, smoothness); } } -참고영상 https://youtu.be/rj5wdmOY-8U 2022. 3. 17. Unity & C# ~ using 문 * 최초 작성일 : 2022.02.17 * 최종 수정일 : 2022.02.17 using문은 using문을 사용한 메서드의 닫는 중괄호에 도달하면 해당 파일이 삭제(dispose)됨. //예제 using (var file = new System.IO.StreamWriter("WriteLines2.txt")) { int skippedLines = 0; foreach (string line in lines) { if (!line.Contains("Second")) { file.WriteLine(line); } else { skippedLines++; } } return skippedLines; } // file is disposed here (불러온 파일이 삭제) 2022. 2. 17. Unity & C# ~ lock 문 * 최초 작성일 : 2022.02.17 * 최종 수정일 : 2022.02.17 - lock 문은 자신에게 소속된 코드가 실행이 완료되기 전까지 연속적인 호출에도 잠금 상태를 유지함 - 연속적인 호출에도 하위 코드가 완료되지 않으면 하위 코드를 중복 실행하지 않음. lock(x) { //하위 코드 } - 주의사항 * try...finally 예외처리를 사용할 경우 예외가 throw 되더라도 잠금이 해제 * await 연산자 사용 불가 * 교착, 잠금 경합이 발생할 수 있으므로 this, Type인스턴스, 문자열 인스턴스는 최대한 짧은 시간 동안 잠금을 유지. 2022. 2. 17. 단축키 Ctrl+shift+f : 내가 보고 있는 화면을 보도록 카메라 가져오기F: 포커스, 현재 선택된 오브젝트에 포커스를 맞추기 Alt+shift+a : 선택한 오브젝트 on / off Ctrl+p : Play / Stop Ctrl+shift+p : Pause 2013. 4. 24. 이전 1 ··· 4 5 6 7 다음 SMALL