반응형
반응형
Substring string myString = "Hello World!"; string subString = myString.Substring(6, 5); Debug.Log(subString); // Output: "World" Split string myString = "Hello, World!"; string[] substrings = myString.Split(','); // Output: "Hello", " World!" Replace string myString = "Hello World!"; string replacedString = myString.Replace("Hello", "Hi"); Debug.Log(replacedString); // Output: "Hi World!" Index..
코드 작성 using UnityEngine; using UnityEngine.UI; public class UIOverlapChecker : MonoBehaviour { public RectTransform rectTransform1; public RectTransform rectTransform2; private Rect rect1; private Rect rect2; void Update() { rect1 = new Rect(rectTransform1.position.x - rectTransform1.rect.width / 2, rectTransform1.position.y - rectTransform1.rect.height / 2, rectTransform1.rect.width, rectTransf..
코드 작성 using UnityEngine; public class PlayerController : MonoBehaviour { public float jumpForce = 10f; public float moveSpeed = 5f; public float groundCheckRadius = 0.2f; public LayerMask whatIsGround; public Transform groundCheck; private Rigidbody2D rb; private bool isGrounded = false; void Start() { rb = GetComponent(); } void FixedUpdate() { isGrounded = Physics2D.OverlapCircle(groundCheck.p..
코드 작성using UnityEngine;using System.Collections;public class Roulette : MonoBehaviour{ public int[] numbers; //당첨될 것들 private int winningNumber; //당첨 번호 private bool spinning = false; public float spinTime = 5.0f; void Start() { winningNumber = -1; } void Update() { if (spinning) { transform.Rotate(Vector3.up, 10.0f); } } ..
ArgumentNullException: Object Graph cannot be null. 해결법 증상 콘솔창에 해당 에러로그가 무한정 생성됨 파일을 클릭했는데 인스펙터 창에 내용이 표시되지 않을 경우 해결법 프로젝트를 먼저 끄고 프로젝트 최상단 폴더 안에 있는 .sln 파일을 모두 지워준 후 다시 프로젝트를 켠다.
코드 작성 using UnityEngine; public class Enemy : MonoBehaviour { public float speed = 5f; private Transform player; void Start() { // 태그로 플레이어 찾기 player = GameObject.FindGameObjectWithTag("Player").transform; } void Update() { Vector3 direction = player.position - transform.position; direction.Normalize(); transform.position += direction * speed * Time.deltaTime; } }
숫자 정렬using System.Linq;using UnityEngine;public enum MyEnum{ First, Second, Third}public class MyObject{ public MyEnum EnumValue { get; set; } public int SomeValue { get; set; }}public class Example : MonoBehaviour{ private List objects; private void Start() { objects = new List() { new MyObject() { EnumValue = MyEnum.Third, SomeValue = 5 }, ..
옵저버 패턴 객체 간에 일대다 종속 관계를 정의하여 한 객체의 상태 변경이 다른 객체에 자동으로 통지되는 패턴. 게임 내에서 이벤트 시스템 또는 UI 업데이트와 같은 상황에서 유용합니다. using UnityEngine; using System; // 이벤트에 대한 데이터 public class EventData { public string eventName; public int eventValue; } // 옵서버 인터페이스 public interface IObserver { void OnNotify(EventData data); } // 옵서버를 관리하는 클래스 public class Subject { private List _observers = new List(); // 옵서버 등록 public ..
코드 작성 using UnityEngine; public class AngleCalculator : MonoBehaviour { public Transform pointA; public Transform pointB; void Start() { Vector2 direction = pointB.position - pointA.position; float angle = Vector2.Angle(Vector2.right, direction); Debug.Log("Angle between the two points: " + angle); } } 다른 예시 using UnityEngine; public class AngleCalculator : MonoBehaviour { public Transform point..
코드 작성 using UnityEngine; using System.Collections.Generic; public class RandomNumberGenerator : MonoBehaviour { private List exclusionList = new List() { 2, 3, 5, 6 }; //제외할 값 private int GenerateRandomNumber(int min, int max) { int randomValue = Random.Range(min, max); while (exclusionList.Contains(randomValue)) { randomValue = Random.Range(min, max); } return randomValue; } }
기본 단축키Win + D: 바탕 화면 보기/숨기기Win + E: 파일 탐색기 열기Win + L: PC 잠금Win + M: 모든 창 최소화Win + Shift + M: 최소화된 창 복원Win + R: 실행 대화 상자 열기Win + S: 검색 열기Win + I: 설정 열기Win + A: 알림 센터 열기창 관리Win + Arrow Keys: 창을 화면의 좌/우/상/하로 이동Win + Shift + Arrow Keys: 창을 다른 모니터로 이동Win + Home: 현재 창을 제외한 모든 창 최소화/복원Win + Tab: 작업 보기 열기Alt + Tab: 열린 앱 간 전환Alt + F4: 활성 창 닫기가상 데스크톱Win + Ctrl + D: 새 가상 데스크톱 만들기Win + Ctrl + Right/Left Arr..
Flutter 플러터 Progress bar 진행바 간단 구현import 'package:flutter/material.dart';class MyWidget extends StatefulWidget { const MyWidget({Key? key}) : super(key: key); @override _MyWidgetState createState() => _MyWidgetState();}class _MyWidgetState extends State { double _progressValue = 0.0; void _updateProgress() { setState(() { _progressValue += 0.1; if (_progressValue >= 1.0) { ..