parksh3641의 등록된 링크

키자드에 등록된 총 461개의 포스트를 확인하실 수 있습니다.

Tistory

유니티 C# 절대값 구하기 Mathf.Abs 또는 삼항 연산자 간단 구현

Mathf.Abs 사용 float num1 = -10.5f; float num2 = 7.2f; float absValue1 = Mathf.Abs(num1); float absValue2 = Mathf.Abs(num2); Debug.Log(num1 + "의 절대값 : " + absValue1); Debug.Log(num2 + "의 절대값 : " + absValue2); 삼항 연산자 구현 float num1 = -10.5f; float num2 = 7.2f; float absValue1 = num1 < 0 ? -num1 : num1; float absValue2 = num2 < 0 ? -num2 : num2; Debug.Log(num1 + "의 절대값 : " + absValue1); Debug.Log(num..

Tistory

파이썬 python 문자열, 정수 입력받기 input 간단 구현법

문자열 받기 name = input("이름을 입력해주세요 : ") print("안녕하세요! " + name + "님") 정수 받기 age_str = input("당신의 나이를 입력해주세요 : ") age_int = int(age_str) if age_int >= 20: print("당신은 어른입니다.") else: print("당신은 어른이 아닙니다.")

Tistory

유니티 C# 다음주 월요일 알아내는 간단 방법 DayOfWeek

코드 작성 DateTime today = DateTime.Today; int daysUntilMonday = ((int)DayOfWeek.Monday - (int)today.DayOfWeek + 7) % 7; DateTime nextMonday = today.AddDays(daysUntilMonday); if (nextMonday == today) { nextMonday = nextMonday.AddDays(7); } Debug.Log("다음주 월요일 : " + nextMonday.ToString("yyyy-MM-dd"));

Tistory

유니티 C# UI끼리 겹쳤을 때 체크하는 법 Unity UI Overlap

코드 작성 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..

Tistory

파이썬 Python gif를 jpg로 변환하기 간단 구현

코드 작성 from PIL import Image gif_image = Image.open('example.gif') for frame_num in range(gif_image.n_frames): gif_image.seek(frame_num) jpeg_image = gif_image.convert('RGB') jpeg_image.save(f'example_{frame_num:03d}.jpg') 단일 변환 from PIL import Image gif_image = Image.open('example.gif') jpeg_image = gif_image.convert('RGB') jpeg_image.save('example.jpg')

Tistory

유니티 C# 문자열 자르기 Substring, Split, Replace, IndexOf, Trim

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..

Tistory

유니티 C# 팩토리얼 factorial 간단 사용법

코드 작성 using UnityEngine; public class MathFunctions : MonoBehaviour { public int Factorial(int num) { if (num == 0) { return 1; } else { return num * Factorial(num - 1); } } }

Tistory

유니티 C# 플레이어를 추적하는 적 코드 간단 구현 Unity

코드 작성 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; } }

Tistory

유니티 오류 ArgumentNullException : Object Graph cannot be null.

ArgumentNullException: Object Graph cannot be null. 해결법 증상 콘솔창에 해당 에러로그가 무한정 생성됨 파일을 클릭했는데 인스펙터 창에 내용이 표시되지 않을 경우 해결법 프로젝트를 먼저 끄고 프로젝트 최상단 폴더 안에 있는 .sln 파일을 모두 지워준 후 다시 프로젝트를 켠다.

Tistory

유니티 C# 간단한 룰렛 시스템 만들기 예시 구현 Unity Roulette System

코드 작성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); } } ..

Tistory

유니티 C# 2D 물리 점프 간단 구현 Unity Rigidbody2D Jump

코드 작성 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..

Tistory

유니티 C# 특정 값을 제외한 랜덤 값 구하기 Unity Random Value Generator

코드 작성 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; } }

Tistory

유니티 C# 두 점 사이의 각도 구하기 간단 구현 Unity Vector2 Angle

코드 작성 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..

Tistory

유니티 C# 옵저버 패턴 간단 구현 Unity Observer

옵저버 패턴 객체 간에 일대다 종속 관계를 정의하여 한 객체의 상태 변경이 다른 객체에 자동으로 통지되는 패턴. 게임 내에서 이벤트 시스템 또는 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 ..

Tistory

유니티 C# 특정 요소를 기준으로 리스트 정렬하기 Unity List Orderby, OrderByDescending

숫자 정렬 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 }, new MyObject() { EnumValue = MyEnum.First, S..

Tistory

유니티 C# 블루투스 통신 간단 구현하기 Unity Bluetooth

코드 작성 using UnityEngine; using System.Collections; using System.IO.Ports; public class BluetoothController : MonoBehaviour { public string deviceName = "MyBluetoothDevice"; public int baudRate = 9600; private SerialPort serialPort; void Start() { string[] ports = SerialPort.GetPortNames(); foreach (string port in ports) { if (port.Contains("Bluetooth") && port.Contains(deviceName)) { serialPort ..

Tistory

유니티 C# 포톤 회전값 지연보상 간단 구현 Photon

코드 작성 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting) { stream.SendNext(transform.rotation); } else { Quaternion rotation = (Quaternion)stream.ReceiveNext(); float lag = Mathf.Abs((float)(PhotonNetwork.Time - info.timestamp)); transform.rotation = Quaternion.Lerp(transform.rotation, rotation, lag); } }

Tistory

Flutter 플러터 Progress bar 진행바 간단 구현 LinearProgressIndicator

코드 예시 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) { _progressValue = 0.0; } }); } @override Widget ..

Tistory

윈도우10 자주 사용하는 단축키 모음 간단 설명

Windows 키 : 시작 메뉴를 열거나 닫습니다. Windows 키 + A : 관리 센터를 엽니다. Windows 키 + D : 바탕 화면을 표시하거나 숨깁니다. Windows 키 + E : 파일 탐색기를 엽니다. Windows 키 + I : 설정을 엽니다. Windows 키 + L : PC를 잠그거나 계정을 전환합니다. Windows 키 + P : 프레젠테이션 표시 모드를 선택합니다. Windows 키 + R : 실행 대화 상자를 엽니다. Windows 키 + S : 검색 표시줄을 엽니다. Windows 키 + Tab : 작업 보기를 열고 가상 데스크톱 간에 전환합니다. Ctrl + C : 선택한 텍스트 또는 항목을 클립보드에 복사합니다. Ctrl + V : 클립보드의 내용을 붙여넣습니다. Ctrl ..

Tistory

유니티 C# 포톤 동적 오브젝트 생성 후 동기화 Photon Instantiate

유니티에서 제공하는 Instantiate가 아닌 포톤에서 제공하는 PhotonNetwork.Instantiate로 생성한뒤 Photon Transform View 또는 Photon Animator View 를 달아주게 되면 자동으로 동기화가 이루어집니다. 생성할 Prefab의 위치는 Resource 폴더 안에 있어야합니다. 코드 예시 using UnityEngine; using Photon.Pun; public class MyScript : MonoBehaviourPunCallbacks { public GameObject prefab; void Start() { PhotonNetwork.Instantiate(prefab.name, transform.position, transform.rotation, 0..

Tistory

유니티 C# 포톤 매치메이킹 만들기 방 입장조건 걸기 Photon Matching Room

입장조건이 있는 방 만들기 void JoinOrCreateRoom() { RoomOptions roomOption = new RoomOptions(); roomOption.MaxPlayers = 2; roomOption.CustomRoomPropertiesForLobby = new string[] { "difficulty" }; roomOption.CustomRoomProperties = new Hashtable() { { "difficulty", "easy" } }; PhotonNetwork.JoinOrCreateRoom("room name", roomOption, null); } 조건에 맞는 방 참여하기 public void JoinRandomRoom() { Hashtable roomPropertie..

Tistory

유니티 C# 자이로센서 간단 구현하기

코드 작성 void Update() { if (SystemInfo.supportsGyroscope) { Gyroscope gyro = Input.gyro; gyro.enabled = true; transform.rotation = gyro.attitude; } }

Tistory

유니티 C# SerializeField 간단 사용법

private 속성을 inspector에서 접근 가능하게 해줍니다. 코드 작성 using UnityEngine; using System; [Serializable] public class MyClass { [SerializeField] private int myPrivateInt; [SerializeField] private string myPrivateString; public MyClass(int myPrivateInt, string myPrivateString) { this.myPrivateInt = myPrivateInt; this.myPrivateString = myPrivateString; } }

Tistory

플러터 Flutter if else문 간단 구현법

코드 예시 int num = 0; if (num > 0) { print("0보다 큽니다."); } else if (num < 0) { print("0보다 작습니다."); } else { print("0입니다."); } 참고할만한 글

Tistory

유니티 C# 삼항 연산자 간단 구현 - Ternary operator

삼항 연산자 A = 조건문 ? : 참일때 : 거짓일때 예시 코드 using UnityEngine; public class TernaryOperatorExample : MonoBehaviour { private int health = 70; void Start() { // 만약 health가 50보다 크면 "건강한 상태"를 출력하고, // 그렇지 않으면 "위험한 상태"를 출력합니다. string healthStatus = (health > 50) ? "건강한 상태" : "위험한 상태"; Debug.Log(healthStatus); } } 예시 코드 2 using UnityEngine; public class TernaryOperatorExample : MonoBehaviour { private bool i..

Tistory

플러터 Flutter For문 Switch문 간단 구현

For문 for (int i = 0; i < 10; i++) { print("현재 값은 $i"); } Switch문 int grade = 80; switch (grade) { case 90: print("Grade is A"); break; case 80: print("Grade is B"); break; case 70: print("Grade is C"); break; default: print("Grade is not A, B, or C"); break; }

Tistory

유니티 에디터 단축키 간단 사용법 Unity Editor

일반 Ctrl + N: 새 씬을 만듭니다. Ctrl + O : 기존 씬을 엽니다. Ctrl + Shift + S: 현재 씬을 저장합니다. Ctrl + S: 열려 있는 모든 씬을 저장합니다. Ctrl + Shift + P: 재생 모드 창을 엽니다. Ctrl + P: 게임 보기를 전체 화면 모드와 창 모드로 전환합니다. Ctrl + Shift + B: 프로젝트를 빌드합니다. Ctrl + Shift + A: 선택한 게임 개체에 새 구성 요소를 추가합니다. Ctrl + Shift + Z: 마지막 작업을 취소합니다. Ctrl + Y: 마지막 작업을 다시 실행합니다. 씬 W : 이동 도구를 선택합니다. E : 회전 도구를 선택합니다. R : 크기 조정 도구를 선택합니다. Q : 사각형 도구를 선택합니다. F : 선..

Tistory

유니티 C# RectTransform width height 간단 수정법

전체 수정 rectTransform.sizeDelta = new Vector2(width, height); Width 수정 private void SetWidth(float width) { rectTransform.sizeDelta = new Vector2(width, rectTransform.sizeDelta.y); } Height 수정 private void SetHeight(float height) { rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, height); }

Tistory

유니티 C# 반올림, 올림, 내림, 소수점 2자리 버리기 간단 구현

유니티 C# 반올림, 올림, 내림, 소수점 2자리 버리기 간단 구현 반올림 Roundfloat myFloat = 3.6f;int myInt = Mathf.RoundToInt(myFloat);Debug.Log(myInt); // 출력: 4 반올림 Ceilfloat myFloat = 3.2f;int myInt = Mathf.CeilToInt(myFloat);Debug.Log(myInt); // 출력: 4 내림 Floorfloat myFloat = 3.8f;int myInt = Mathf.FloorToInt(myFloat);Debug.Log(myInt); // 출력: 3 소수점 전부 버리기float myFloat = 3.14159f;int myInt = Mathf.FloorToInt(myFloat);Debug..

Tistory

유니티 안드로이드 APK 빌드 오류 튕김, 강제 종료 간단 해결법

예상 원인 목록빌드는 성공적으로 되나 스마트폰에서 APK 빌드 후 테스트 하면 유니티 로고까지는 나오는 데 그 후 검은 화면이 나오면서 0.1초만에 튕기는 현상기본 해결 도구1. Assets > Play Services Resolver > Android Resolver > Force Resolve 실행 2. 유니티 에디터에서 제공하는 안드로이드 로그캣을 통해서 살펴보기 3. Assets > Plugins > Android > AndroidManifest.xml파일 안에 내가 사용하지 않는 에셋에 이름이 적혀있거나 오타가 한 글자라도 있는지 확인하기해결 방법원본 AndroidManifest.xml 파일 교체해보기 ..

Tistory

파이썬 python 랜덤 함수 random 간단 구현

1에서 100 사이의 임의의 정수 생성 import random print(random.randint(1, 100)) 0과 1 사이의 임의 부동 소수점 생성 print(random.random()) 범위(예: 2에서 5 사이) 내에서 임의의 부동 소수점 생성 print(random.uniform(2, 5)) 목록에서 임의의 요소 선택 list = [1, 2, 3, 4, 5] print(random.choice(list))

Tistory

Visual Studio Code (VSCode) 유용한 단축키 간단 사용법

일반 Ctrl + Shift + P : 명령 또는 설정을 검색할 수 있는 명령 팔레트를 엽니다. Ctrl + Shift + N : 새 창을 엽니다. Ctrl + N : 새 파일을 만듭니다. Ctrl + O : 기존 파일을 엽니다. Ctrl + S : 현재 파일을 저장합니다. Ctrl + Shift + S : 열려 있는 모든 파일을 저장합니다. Ctrl + F : 검색 표시줄을 엽니다. Ctrl + G : 특정 줄 번호로 이동합니다. Ctrl + Shift + F : 검색 및 바꾸기 표시줄을 엽니다. Ctrl + ` : 통합 터미널을 토글합니다. 편집 Ctrl + X : 선택한 텍스트를 잘라냅니다. Ctrl + C : 선택한 텍스트를 복사합니다. Ctrl + V : 복사하거나 잘라낸 텍스트를 붙..

Tistory

파이썬 python 반올림, 올림 ,내림 round ceil 간단 구현

반올림 (round) import math number = 3.14159 rounded_number = round(number) print(rounded_number) # 출력: 3 올림 (ceil) import math number = 3.14159 rounded_up = math.ceil(number) print(rounded_up) # 출력: 4 내림 (floor) import math number = 3.14159 rounded_down = math.floor(number) print(rounded_down) # 출력: 3 버림 import math number = 3.14159 rounded_towards_zero = math.copysign(math.floor(abs(number)), numb..

Tistory

파이썬 python 자료구조 힙 heapq 간단 구현

최소 힙으로 변환 import heapq # 목록을 최소 힙으로 변환 my_list = [4, 2, 1, 3, 5] heapq.heapify(my_list) print(my_list) # 출력: [1, 2, 3, 4, 5] 힙에 요소 삽입 # 힙에 요소 삽입 heapq.heappush(my_list, 0) print(my_list) # 출력: [0, 2, 1, 4, 5, 3] 힙에서 가장 작은 요소 팝 # 힙에서 가장 작은 요소 팝 smallest = heapq.heappop(my_list) print(smallest) # 출력: 0 print(my_list) # 출력: [1, 2, 3, 4, 5] 힙에서 가장 작은 요소 찾기 # 힙에서 가장 작은 요소 찾기 smallest = my_list[0] pri..

Tistory

파이썬 python enum 타입 간단 사용법

코드 예시 import enum class DaysOfWeek(enum.Enum): MONDAY = 1 TUESDAY = 2 WEDNESDAY = 3 THURSDAY = 4 FRIDAY = 5 SATURDAY = 6 SUNDAY = 7 print(DaysOfWeek.MONDAY) # 출력: DaysOfWeek.MONDAY print(DaysOfWeek(1)) # 출력: DaysOfWeek. 월요일 # 열거형 값 반복 for day in DaysOfWeek: print(day) # 출력: # DaysOfWeek.MONDAY # DaysOfWeek.TUESDAY # DaysOfWeek.WEDNESDAY # DaysOfWeek.THURSDAY # DaysOfWeek.FRIDAY # DaysOfWeek.SATU..

Tistory

파이썬 python 타이머 간단 구현 Timer

코드 작성 import time print("Timer starting...") start_time = time.time() remaining = 10 while remaining > 0: print("{} seconds remaining".format(int(remaining))) time.sleep(1) remaining = 10 - (time.time() - start_time) print("Time's up!")

Tistory

파이썬 python CSV 파일 저장 불러오기 Read, Write 간단 구현

CSV 저장하기 import csv rows = [["Name", "Age", "City"], ["John", 30, "New York"], ["Jane", 25, "London"], ["Jim", 35, "Paris"]] with open("people.csv", "w", newline="") as file: writer = csv.writer(file) writer.writerows(rows) CSV 불러오기 import csv with open("people.csv", "r") as file: reader = csv.reader(file) for row in reader: print(row)

Tistory

플러터 Flutter ToDo List 구현하기

코드 작성 import 'dart:async'; import 'package:flutter/material.dart'; class ToDoListPage extends StatefulWidget { const ToDoListPage({Key? key}) : super(key: key); @override State createState() => _ToDoListPageState(); } class _ToDoListPageState extends State { final _todoController = TextEditingController(); List _todoList = []; void _addTodo() { setState(() { _todoList.add(_todoController.text); ..

Tistory

플러터 Flutter 메모장 구현하기 Notepad

코드 작성 import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; import 'dart:io'; class Notepad extends StatefulWidget { @override _NotepadState createState() => _NotepadState(); } class _NotepadState extends State { TextEditingController _textController = TextEditingController(); String _filePath = ''; @override void initState() { super.initState(); _loadFile();..

Tistory

유니티 C# 메모장 간단 구현 Unity NotePad

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Notepad : MonoBehaviour { public InputField inputField; public Text outputText; private List notes = new List(); public void AddNote() { string input = inputField.text; notes.Add(input); inputField.text = ""; UpdateNotes(); } public void UpdateNotes() { string output = ""; fore..

Tistory

파이썬 python switch문 간단 구현

Python에는 다른 프로그래밍 언어와 같은 내장 switch 문이 없습니다. 대신 if...elif...else 문을 사용하여 동일한 결과를 얻을 수 있습니다. 코드 예시 def get_day_of_week(day_number): if day_number == 0: return "Sunday" elif day_number == 1: return "Monday" elif day_number == 2: return "Tuesday" elif day_number == 3: return "Wednesday" elif day_number == 4: return "Thursday" elif day_number == 5: return "Friday" elif day_number == 6: return "Saturd..

Tistory

유니티 C# 플레이어 추적하는 Monster AI 간단 구현

코드 작성using UnityEngine;public class MonsterTracking : MonoBehaviour{ public Transform player; public float speed = 5f; public float range = 10f; void Update() { float distance = Vector3.Distance(transform.position, player.position); if (distance  다른 방식using UnityEngine;using UnityEngine.AI;public class MonsterAI : MonoBehaviour{ // NavMeshAgent를 위한 변수 private N..

Tistory

유니티 C# 자료구조 큐 Queue 간단 사용법

코드 예시 using System.Collections.Generic; public class MyQueue { private Queue _queue = new Queue(); public void Enqueue(int item) //큐 넣기 { _queue.Enqueue(item); } public int Dequeue() //큐 빼기 (처음으로 들어간 데이터가 나옴) { return _queue.Dequeue(); } public int Peek() //맨 앞에 데이터 가져오기 { return _queue.Peek(); } public int Count //큐 길이 가져오기 { get { return _queue.Count; } } } 다른 곳에서 사용하기 MyQueue queue = new MyQu..

Tistory

유니티 C# 자료구조 리스트 List 간단 사용법

코드 예시 using System.Collections.Generic; public class MyList { private List _list = new List(); public void Add(int item) //추가하기 { _list.Add(item); } public void RemoveAt(int index) //index 번째 리스트 제거 { _list.RemoveAt(index); } public int GetAt(int index) //index 번째 리스트 가져오기 { return _list[index]; } public int Count //List 길이 { get { return _list.Count; } } } 다른 곳에서 사용하기 MyList list = new MyList()..

Tistory

유니티 C# 자료구조 스택 Stack 간단 사용법

코드 예시 using System.Collections.Generic; public class StackExample { private Stack stack; public StackExample() { stack = new Stack(); } public void Push(int value) //삽입 { stack.Push(value); } public int Pop() //마지막에 넣은 것이 먼저 나옴(후입선출) { if (stack.Count > 0) { return stack.Pop(); } return -1; } public int Peek() //가장 위에 있는 항목 반환 { if (stack.Count > 0) { return stack.Peek(); } return -1; } }

Tistory

유니티 C# 클릭하면 점수증가 시스템 간단 구현 (클리커 게임)

코드 작성using UnityEngine;using UnityEngine.UI;public class ScoreController : MonoBehaviour{ public Text scoreText; private int score = 0; void Start() { UpdateScore(); } public void IncreaseScore() //점수 증가 버튼 { score += 1; UpdateScore(); } void UpdateScore() //현재 점수 표시 { scoreText.text = "현재 점수 : " + score; }}  간단한 방치형 클리커 게임 만들기 유니티 C# ..

Tistory

유니티 C# 화면 씬(Scene) 전환하기 간단 구현

코드 작성 using UnityEngine; using UnityEngine.SceneManagement; public class SceneSwitcher : MonoBehaviour { public void SwitchScene(string sceneName) { SceneManager.LoadScene(sceneName); } }

Tistory

유니티 C# 총알 발사하기 간단 구현 bullet Shot - 슈팅게임

코드 작성 using UnityEngine; public class BulletFiring : MonoBehaviour { public GameObject bulletPrefab; public Transform bulletSpawn; public float bulletSpeed = 20f; public float fireRate = 0.5f; private float nextFire; void Update() { // 0.5초 간격으로 총알을 발사 할 수 있음 if (Input.GetKeyDown(KeyCode.Space) && Time.time > nextFire) { nextFire = Time.time + fireRate; Fire(); } } void Fire() { // 총알 프리팹 생성 Gam..

Tistory

유니티 C# 캐릭터 발자국 소리 간단 구현

코드 작성 using UnityEngine; public class PlayerMovement : MonoBehaviour { public AudioClip walkingSound; private AudioSource audioSource; private bool isWalking; void Start() { audioSource = GetComponent(); } void Update() { if (isWalking) { if (!audioSource.isPlaying) { audioSource.PlayOneShot(walkingSound); } } } void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("바닥..

Tistory

유니티 C# 마우스로 3D 오브젝트 클릭 간단 구현 Mouse Ray cast

코드 작성레이 캐스트를 활용합니다using UnityEngine;public class TouchEvent : MonoBehaviour { void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { Debug.Log("터치된 오브젝트: " + hit.transform.name); } ..

Tistory

유니티 C# 노치 대응하기 SafeArea 에셋 추천

유니티 에셋스토어 다운로드 https://assetstore.unity.com/packages/tools/gui/safe-area-helper-130488?locale=ko-KR Safe Area Helper | GUI 도구 | Unity Asset Store Use the Safe Area Helper from Crystal Pug on your next project. Find this GUI tool & more on the Unity Asset Store. assetstore.unity.com

Tistory

유니티 C# 중복 생성 방지 간단 구현 DontDestroyOnLoad

코드 작성 using UnityEngine; public class DuplicatePrevention : MonoBehaviour { private static bool hasInstance = false; void Awake() { if (hasInstance) { // 이미 인스턴스가 존재하므로 이 인스턴스를 파괴합니다. Destroy(gameObject); } else { // 이 인스턴스가 유일하다는 것을 표시합니다. hasInstance = true; // 다른 씬으로 이동할 때 파괴되지 않도록 설정합니다. DontDestroyOnLoad(gameObject); } } }

Tistory

Flutter 플러터 URL 주소 열기 간단 구현 url launcher

패키지 설치 url_launcher | Flutter Package Flutter plugin for launching a URL. Supports web, phone, SMS, and email schemes. pub.dev 터미널 설치 flutter pub add url_launcher android / app / src / main / AndroidManifest.xml Flutter 플러터 백 버튼 무시하기 WillPopScope 코드 예시 Widget build(BuildContext context) { return WillPopScope( onWillPop: () async => false, child: Scaffold(), ); } parksh3641.tistory.com Flutter 플러..

Tistory

유니티 Xcode 수출 규정 관련 문서가 누락됨 해결법 Info.plist 수정

유니티 Xcode 수출 규정 관련 문서가 누락됨 해결법 Xcode에서 수정할때 App Users Non-Exempt Enctyption : No Info.plist를 직접 수정할때 ITSAppUsesNonExemptEncryption

Tistory

Flutter 플러터 타이머 간단 구현 Timer

Flutter 플러터 타이머 간단 구현 코드 작성 import 'dart:async'; import 'package:flutter/material.dart'; class TimerPage extends StatefulWidget { const TimerPage({Key? key}) : super(key: key); @override State createState() => _TimerPageState(); } class _TimerPageState extends State { int _seconds = 0; bool _isRunning = false; late Timer _timer; void _startTimer() { _isRunning = true; _timer = Timer.periodic(Dur..

Tistory

유니티 C# 플레이어 Hp바 간단 구현하기

코드 작성 using UnityEngine; using UnityEngine.UI; public class Player : MonoBehaviour { public int health = 3; public Image[] healthImages; public void TakeDamage() //공격하기 { health -= 1; healthImages[health].gameObject.SetActive(false); Debug.Log("Player's health: " + health); } } 다른 쪽에서 플레이어 공격할때 Player player = new Player(); player.TakeDamage(); 유니티 기본 UI Slider를 사용하여 구현하기 using UnityEngine; usin..

Tistory

Flutter 플러터 랜덤 숫자 간단 사용법 Random

코드 예시 import 'dart:math'; import 'package:flutter/material.dart'; class ExamplePage extends StatefulWidget { const ExamplePage({Key? key}) : super(key: key); @override State createState() => _ExamplePageState(); } class _ExamplePageState extends State { int number = Random().nextInt(100); // 0 ~ 99 랜덤 Widget build(BuildContext context) { return Scaffold(); } }

Tistory

Flutter 플러터 백 버튼 무시하기 WillPopScope

코드 예시 Widget build(BuildContext context) { return WillPopScope( onWillPop: () async => false, child: Scaffold(), ); }

Tistory

Flutter 플러터 화면 전환 애니메이션 삭제 간단 사용법 Navigator Animation

코드 작성 Widget build(BuildContext context) { return Scaffold( body: Center( child: ElevatedButton( child: Text( "메인 화면 이동", ), onPressed: () { Navigator.push( context, PageRouteBuilder( pageBuilder: (BuildContext context, Animation animation1, Animation animation2) { return MyApp(); //변경 필요 }, transitionDuration: Duration.zero, reverseTransitionDuration: Duration.zero, ), ); }, ), )); } } 참고할만한 글 ..

Tistory

Flutter 플러터 다이얼로그 Dialog 대화 상자 간단 사용법

ShowDialog barrierDismissible : 바깥 영역 터치시 닫을지 여부 title : 제목 center : 내용 actions : 버튼 코드 예시 Widget build(BuildContext context) { return Scaffold( body: Center( child: ElevatedButton( child: Text( "다이얼로그 열기", ), onPressed: () { showDialog( context: context, barrierDismissible: true, //바깥 영역 터치시 닫을지 여부 결정 builder: ((context) { return AlertDialog( title: Text("제목"), content: Text("내용"), actions: [ C..

Tistory

Flutter 플러터 설정 화면 UI 간단 구현 setting ui

패키지 정보 settings_ui | Flutter Package Create native settings for Flutter app in minutes. Use single interfaces to build pub.dev 패키지 설치 flutter pub add settings_ui 코드 예시 import 'package:settings_ui/settings_ui.dart'; import 'package:flutter/material.dart'; bool vibration = false; class ExamplePage extends StatefulWidget { const ExamplePage({Key? key}) : super(key: key); @override State createState..

Tistory

Flutter 플러터 진동 간단 사용법 vibration

패키지 정보 vibration | Flutter Package A plugin for handling Vibration API on iOS, Android, and web. pub.dev 터미널 설치 flutter pub add vibration 코드 작성 import 'package:vibration/vibration.dart'; void OnVibration() { Vibration.vibrate(duration: 1000); //1000 = 1초 }

Tistory

Flutter 플러터 앱 상태 확인하기 AppLifecycleState

예시 코드 import 'package:flutter/material.dart'; class ExamplePage extends StatefulWidget { const ExamplePage({Key? key}) : super(key: key); @override State createState() => _ExamplePageState(); } class _ExamplePageState extends State with WidgetsBindingObserver { @override void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.resumed: print("앱이 표시되고 사용자..

Tistory

Flutter 플러터 Appbar 간단 사용법

Appbar centerTitle : 텍스트 가운데 정렬 여부 automaticallyImplyLeading : 뒤로가기 버튼 제거 여부 elevation : 그림자 제거 backgroundColor : 배경 색 title : 제목 leading : 왼쪽 아이콘 버튼 actions : 오른쪽 아이콘 버튼 예시 코드 Widget build(BuildContext context) { return Scaffold( appBar: AppBar( centerTitle: true, automaticallyImplyLeading: true, elevation: 0, backgroundColor: Colors.white, title: Text("제목"), leading: IconButton( icon: Icon(Ico..

Tistory

Flutter 플러터 Text 크기 변경, 정렬, 색깔 변경 간단 사용법

Text textAlign : 정렬 여부 fontSize : 폰트 크기 fontWeight : 폰트 효과 color : 폰트 색깔 예시 코드 Widget build(BuildContext context) { return Scaffold( body: Center( child: Text( "안녕하세요", textAlign: TextAlign.center, style: TextStyle( fontSize: 26, fontWeight: FontWeight.bold, color: Colors.black ), )), ); }

Tistory

Flutter 플러터 화면 전환 Navigator.push 간단 사용법

코드 예시 Widget build(BuildContext context) { return Scaffold( body: Center( child: ElevatedButton( child: Text( "메인 화면 이동", ), onPressed: () { Navigator.push( context, MaterialPageRoute(builder: (context) => MyApp()), ); }, ), )); } }

Tistory

Flutter 플러터 스낵바 SnackBar 간단 사용법

코드 예시 import 'package:flutter/material.dart'; class ExamplePage extends StatefulWidget { const ExamplePage({Key? key}) : super(key: key); @override State createState() => _ExamplePageState(); } class _ExamplePageState extends State { Widget build(BuildContext context) { return Scaffold( body: Center( child: ElevatedButton( child: Text( "스낵 바 열기", ), onPressed: () { OpenSnackBar(context); }, ), )..

Tistory

유니티 C# UI 효과 깜빡이기 간단 구현 SpriteRenderer

코드 작성 캐릭터 피격 후 무적 시간 애니메이션으로 사용할 수 있습니다. using System.Collections; using System.Collections.Generic; using UnityEngine; public class Flicker : MonoBehaviour { private SpriteRenderer spriteRenderer; public float delay = 0.5f; //딜레이 public int repeat = 4; //반복 횟수 int value = 0; private void Awake() { spriteRenderer = GetComponent(); } public void Hit() { value = repeat; StartCoroutine(FlickerCorou..

Tistory

유니티 C# 일정거리 범위 안에 목표물 체크 Vector3.Distance

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public Transform target; float dist; void Update() { dist = Vector3.Distance(target.transform.position, transform.position); if(dist < 0.1f) { Debug.Log("타겟이 범위안에 있습니다."); } } }

Tistory

유니티 C# 물리 AddForce 간단 사용법

코드 작성using UnityEngine;public class Example : MonoBehaviour{ // Rigidbody 컴포넌트 Rigidbody rb; // 힘의 크기를 조절하는 변수 public float forceAmount = 10.0f; void Start() { // Rigidbody 컴포넌트 가져오기 rb = GetComponent(); } void Update() { // "스페이스바" 키를 누르면 힘을 적용 if (Input.GetKeyDown(KeyCode.Space)) { // Rigidbody에 지속적인 힘을 가함 rb.A..

Tistory

Flutter 플러터 배경 음악 실행 간단 구현 assets audio player

패키지 정보 assets_audio_player | Flutter Package Play music/audio stored in assets files directly from Flutter & Network, Radio, LiveStream, Local files. Compatible with Android, iOS, web and macOS. pub.dev 터미널 설치 flutter pub add assets_audio_player pubspec.yaml 설정 flutter: assets: - assets/audios/ 코드 작성 import 'package:assets_audio_player/assets_audio_player.dart'; import 'package:flutter/material...

Tistory

유니티 C# 카메라 목표지점까지 부드럽게 이동 Camera Vector3.SmoothDamp

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; public class MoveCamera : MonoBehaviour { public Transform targetPosition; public float smoothTime = 0.3f; private Vector3 velocity = Vector3.zero; public bool isActive = false; private void Start() { isActive = true; } private void Update() { if (isActive) { Camera.main.transform.position = Vector3.SmoothDamp(C..

Tistory

유니티 C# 캐릭터 3인칭 카메라 따라가기 Follow Camera

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; public class FollowCamera : MonoBehaviour { public GameObject target; public float offsetX = 0.0f; public float offsetY = 0.0f; public float offsetZ = 0.0f; Vector3 targetPos; void FixedUpdate() { targetPos = new Vector3(target.transform.position.x + offsetX,target.transform.position.y + offsetY,target.transform..

Tistory

유니티 C# 카메라 이동범위 제한 Camera Mathf.Clamp

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; public class CameraController : MonoBehaviour { public float offsetX = 10; public float offsetY = 10; public float offsetZ = 10; void LateUpdate() { transform.position = new Vector3( Mathf.Clamp(Camera.main.transform.position.x, -offsetX, offsetX), Mathf.Clamp(Camera.main.transform.position.y, -offsetY, offsetY)..

Tistory

유니티 C# 라인 따라가기 Follow Line

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; public class FollowLine : MonoBehaviour { public Transform[] Points; public IEnumerator GetPathEnumerator() { if (Points == null || Points.Length < 1) yield break; var direction = 1; var index = 0; while (true) { yield return Points[index]; if (index = Points.Length - 1) direction = -1; index = index + direction..

Tistory

유니티 C# 포톤 씬 로드하기 Photon Scene Load

코드 작성 using System; using System.Collections; using UnityEngine; using Photon.Pun; using Photon.Realtime; public class NetworkManager : MonoBehaviourPunCallbacks { private void LoadScene() { PhotonNetwork.LoadLevel("Scene Name"); } }

Tistory

유니티 C# 포톤 코루틴 간단 사용 Photon Coroution

코드 작성 using System; using System.Collections; using UnityEngine; using Photon.Pun; using Photon.Realtime; using UnityEngine.UI; public class NetworkManager : MonoBehaviourPunCallbacks { int hp = 100; public Text hpText; public PhotonView PV; private void Start() { StartTimer(); } void StartTimer() { if(PhotonNetwork.IsMasterClient) { hp = 100; StartCoroutine(TimerCoroution()); } } IEnumerator Ti..

Tistory

Flutter 플러터 개발 환경 설치 VSCode, Github , Android Studio

플러터 Flutter 설치 https://docs.flutter.dev/get-started/install Install Install Flutter and get started. Downloads available for Windows, macOS, Linux, and Chrome OS operating systems. docs.flutter.dev Visual Stuido Code 설치 https://code.visualstudio.com/ Visual Studio Code - Code Editing. Redefined Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and ..

Tistory

유니티 C# 텍스트 코드로 색깔 간단 변경법 Text Color

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { public Text nickNameText; void Start() { nickNameText.text = "" + "닉네임" + ""; //파란색으로 변경 nickNameText.text = "" + "닉네임" + ""; //초록색으로 변경 } }

Tistory

유니티 C# 포톤 변수 동기화 Photon RPC

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using Photon.Realtime; using UnityEngine.UI; public class NetworkManager : MonoBehaviourPunCallbacks { int towerHp = 100; bool isRaining = false; public PhotonView PV; void AttackTower() { PV.RPC("HitTower", RpcTarget.All); //방 전체 사람들에게 타워 체력 -10 PV.RPC("HitTower", RpcTarget.All, 10); PV.RPC("H..

Tistory

유니티 C# 포톤 커스텀 프로퍼티 간단 사용법 Photon Custom Property

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using Photon.Realtime; using UnityEngine.UI; using Hashtable = ExitGames.Client.Photon.Hashtable; public class NetworkManager : MonoBehaviourPunCallbacks { public override void OnJoinedRoom() { statusText.text = "방에 참가하였습니다."; if (PhotonNetwork.IsMasterClient) { PhotonNetwork.CurrentRoom.SetCus..

Tistory

유니티 C# 포톤 소유권 제어하기 Photon Ownership

코드 작성 전 주의사항 스크립트가 달린 오브젝트의 PhotonView에서 OwnershipSphere 옵션이 TakeOver로 설정되어 있어야합니다. "Fixed" 는 게임오브젝트를 생성한 것이 지속적으로 소유자로 유지 되는 것입니다. "Takeover" 다른 클라이언트가 현재 오너로 부터 소유권을 가져갈 수 있도록 합니다. "Request" 현재 오너에게 소유권을 요청 할 수 있으나 거절 될 수 있는 것 입니다. 코드 작성 using System; using System.Collections; using UnityEngine; using Photon.Pun; using Photon.Realtime; public class Player : MonoBehaviourPunCallbacks { public P..

Tistory

유니티 C# 포톤 타이머 간단 구현 Photon Timer

코드 작성 using System; using System.Collections; using UnityEngine; using Photon.Pun; using Photon.Realtime; using UnityEngine.UI; public class NetworkManager : MonoBehaviourPunCallbacks { int time = 0; public Text timerText; public PhotonView PV; private void Start() { StartTimer(); } void StartTimer() { if(PhotonNetwork.IsMasterClient) { time = 60; StartCoroutine(TimerCoroution()); } } IEnumerato..

Tistory

유니티 C# 포톤 서버 접속하기 간단 구현 Photon Server

포톤 서버 접근 순서 서버 접속 로비 접속 방 만들기 방 만들고 참가하기 방 떠나기 코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using Photon.Realtime; using UnityEngine.UI; public class NetworkManager : MonoBehaviourPunCallbacks { void Awake() { Connect(); } public void Connect() { Debug.Log("서버에 접속중입니다."); PhotonNetwork.AutomaticallySyncScene = true; PhotonNetwork.ConnectU..

Tistory

유니티 C# 포톤 방 설정하기 Photon RoomOptions

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using Photon.Realtime; using UnityEngine.UI; public class NetworkManager : MonoBehaviourPunCallbacks { public void CreateRoom() { PhotonNetwork.LocalPlayer.NickName = "닉네임 설정"; RoomOptions roomOption = new RoomOptions(); roomOption.MaxPlayers = 4; //최대 인원수 설정 roomOption.IsOpen = true; //방이 열려있는..

Tistory

유니티 C# 포톤 방 참가 퇴장 알림 간단 구현 Photon RPC

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using Photon.Realtime; using UnityEngine.UI; public class NetworkManager : MonoBehaviourPunCallbacks { public Text notionText; public PhotonView PV; private void Awake() { PV = GetComponent(); } public override void OnPlayerEnteredRoom(Player newPlayer) { PV.RPC("NotionRPC", RpcTarget.All, newP..

Tistory

유니티 C# String Enum 타입 간단 변환

코드 작성 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public enum MoneyType { Gold = 0, Crystal } public class ExampleEnum : MonoBehaviour { void Start() { MoneyType moneyType = (MoneyType)Enum.Parse(typeof(MoneyType), "Gold"); } }

Tistory

유니티 C# 구글 애드몹 배너 광고 간단 구현 Google Admob 8.7.0

유니티용 구글 Admob SDK 설치 Releases · googleads/googleads-mobile-unityOfficial Unity Plugin for the Google Mobile Ads SDK - googleads/googleads-mobile-unitygithub.com구글 Admob 설정   Google AdMob: 모바일 앱 수익 창출인앱 광고를 사용하여 모바일 앱에서 더 많은 수익을 창출하고, 사용이 간편한 도구를 통해 유용한 분석 정보를 얻고 앱을 성장시켜 보세요.admob.google.com 구글 Admob 홈페이지  배너 광고  |  Unity  |  Google for DevelopersGoogle 모바일 광고 Unity 플러그인 버전 5.4.0 이하에서는 서비스가 종료되어 ..

Tistory

유니티 C# 구글 애드몹 전면 광고 간단 구현 Google Admob 8.7.0

유니티용 구글 Admob SDK 설치 Releases · googleads/googleads-mobile-unityOfficial Unity Plugin for the Google Mobile Ads SDK - googleads/googleads-mobile-unitygithub.com 구글 Admob 설정 Google AdMob: 모바일 앱 수익 창출인앱 광고를 사용하여 모바일 앱에서 더 많은 수익을 창출하고, 사용이 간편한 도구를 통해 유용한 분석 정보를 얻고 앱을 성장시켜 보세요.admob.google.com 구글 Admob 홈페이지 전면 광고  |  Unity  |  Google for DevelopersGoogle 모바일 광고 Unity 플러그인 버전 5.4.0 이하에서는 서비스가 종료되어 광고..

Tistory

유니티 C# 포톤 설치 Photon 실시간 멀티 구현

Photon Pun 2+ 멀티 게임을 위한 Asset https://assetstore.unity.com/packages/tools/network/photon-pun-2-120838 Photon PUN 2+ | 네트워크 | Unity Asset Store Get the Photon PUN 2+ package from Photon Engine and speed up your game development process. Find this & other 네트워크 options on the Unity Asset Store. assetstore.unity.com Photon Pun 2+ 공식 한국어 홈페이지 https://www.photonengine.com/ko-KR/ 글로벌 크로스 플랫폼 실시간 게임 개발 ..

Tistory

유니티 C# UniRX 타이머 간단 구현 Timer

코드 작성 using System.Collections; using System.Collections.Generic; using UniRx; using UnityEngine; using UnityEngine.UI; public class TimerUniRX : MonoBehaviour { public Text timerText; private int timerIndex = 0; private void Start() { Observable.Timer(System.TimeSpan.FromSeconds(1)) .Repeat() .Subscribe(_ => UpdateTimer()); } void UpdateTimer() { timerIndex++; timerText.text = timerIndex.ToStri..

Tistory

유니티 C# UniRX 코루틴 Coroution 간단 사용법

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UniRx; public class CoroutionUniRX : MonoBehaviour { private void Start() { Observable.FromCoroutine(ExampleCoroution, false) .Subscribe(_ => Debug.Log("Exit")); } IEnumerator ExampleCoroution() { yield return new WaitForSeconds(1); Debug.Log("Coroution Exit"); } } 참고할만한 글 유니티 C# UniRX 타이머 간단 구현 Timer 코드 작..

Tistory

유니티 C# 마우스 좌표 Mouse Position 간단 구하기

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class MousePosition : MonoBehaviour { private void Start() { } void Update() { if (Input.GetMouseButtonDown(0)) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -Camera.main.transform.position.z)); Debug.Log(mousePos.ToStri..

Tistory

유니티 C# Enum Count 길이 간단 구하기

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; public enum MoneyType { Gold = 0, Crystal } public class ExampleEnum : MonoBehaviour { public MoneyType moneyType = MoneyType.Gold; void GetEnumCount() { int count = System.Enum.GetValues(typeof(MoneyType)).Length; } }

Tistory

유니티 UniRX (Reactive Extensions for Unity) 다운로드

유니티 UniRX (Reactive Extensions for Unity) 다운로드 UniRx - Reactive Extensions for Unity | 기능 통합 | Unity Asset Store Use the UniRx - Reactive Extensions for Unity from neuecc on your next project. Find this integration tool & more on the Unity Asset Store. assetstore.unity.com

Tistory

유니티 C# UniRX 더블 클릭 Double Click 간단 구현

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UniRx; using UniRx.Triggers; using System; public class DoubleClickUniRX : MonoBehaviour { public Text text; void Start() { var clickStream = this.UpdateAsObservable() .Where(_ => Input.GetMouseButtonDown(0)); clickStream.Buffer(clickStream.Throttle(TimeSpan.FromMilliseconds(200))) .W..

Tistory

유니티 C# UniRX 버튼 클릭 Button Click 간단 구현

코드 작성 using System.Collections; using System.Collections.Generic; using UniRx; using UnityEngine; using UnityEngine.UI; public class ButtonClickUniRX : MonoBehaviour { public Button button; public Text text; private void Start() { button.onClick .AsObservable() .Subscribe(_ => { text.text = "Clicked"; }); } } 참고할만한 글

Tistory

유니티 C# UniRX ObservableWWW 간단 사용법

코드 작성 using System.Collections; using System.Collections.Generic; using UniRx; using UnityEngine; using UnityEngine.UI; public class ExampleUniRX : MonoBehaviour { private void Start() { var parallel = Observable.WhenAll( ObservableWWW.Get("http://google.com/"), ObservableWWW.Get("http://bing.com/"), ObservableWWW.Get("http://unity3d.com")); parallel.Subscribe(xs => { Debug.Log(xs[0].Substring(0..

Tistory

유니티 C# 베터리 잔량 가져오기 Battery 간단 사용법

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Example : MonoBehaviour { private void Start() { float number = SystemInfo.batteryLevel; // 베터리 충전량 가져오기 (0 ~ 1); Debug.Log(SystemInfo.batteryLevel); switch(SystemInfo.batteryStatus) //베터리 상태 가져오기 { case BatteryStatus.Unknown: Debug.Log("충전 상태를 알 수 없음"); break; case BatteryStat..

Tistory

유니티 C# 가변 해상도 대응 Android , IOS 간단 구현

코드 작성 using System.Collections; using System.Collections.Generic; using UnityEngine; public class CameraResolution : MonoBehaviour { private void Start() { SetResolution(); } public void SetResolution() { int setWidth = 1080; int setHeight = 1920; int deviceWidth = Screen.width; int deviceHeight = Screen.height; Screen.SetResolution(setWidth, (int)(((float)deviceHeight / deviceWidth) * setWidth)..

1 2 3 4 5