툴/유니티 82

유니티 Webgl 실행시 웹브라우저의 URL주소 받기

Webgl로 빌드해서, 웹브라우저에서 실행했을때, 지금 Webgl을 실행하고 있는 URL주소 받는 방법 https://docs.unity3d.com/ScriptReference/Application-absoluteURL.html Unity - Scripting API: Application.absoluteURL Description The URL of the document. For WebGL, this a web URL. For Android, iOS, or Universal Windows Platform (UWP) this is a deep link URL. (Read Only) WebGL: The URL of the document as shown in a browser's address bar. ..

툴/유니티 2021.08.16

[C#] float값을 Remap하기(숫자값을 리맵,맵핑 하기)

'특정한 최솟값과 최대값을 범위로 가지는 수'의 최솟값과 최대값을 변경했을때 범위의 비율에 맞춰 값을 계산하는 것을 Remap이라고 표현한다. ex) 만약 0~30의 범위안에 '20'이라는 숫자는 범위를 (-15) ~ 40 사이로 변경하면 약 21.666이 된다. 이처럼 범위를 변경하되 비율에 맞게 값을 재계산한다. 작업을 하다가 게임내의 시간의 변화를 기록할 float자료형인 변수 GameTime을 만들었고, 최솟값과 최대값이 0~24사이의 값을 가지는 변수로 사용했다. (코드내에서 GameTime이라는 변수는 0~24사이의 값만 가지게되어있음) 그리고 GameTime이 0에서 24까지 변화함에 따라 게임내의 조명의 밝기가 0에서 100까지 커지게 만들고자 했다. 그래서 아래와 같이 remap이라는 함..

툴/유니티 2021.08.13

[C#] 유니티 웹에 있는 데이터 가져오기

https://docs.unity3d.com/kr/530/ScriptReference/WWW.html Unity - 스크립팅 API: WWW URL의 컨텐츠를 받아오기위한 작은 유틸리티 모듈을 나타냅니다. 새 WWW 오브젝트를 반환하는 WWW(url)를 호출해서, 백그라운드에서 다운로드를 시작할 수 있습니다. /isDone/속성을 검사해서 다운로 docs.unity3d.com 'WWW'라는 스크립팅 API를 사용한다. 지금 작업하면서 웹서버에 있는 텍스트 파일을 읽어오는 기능이 필요해서 사용한 코드다. using System.Collections; using System.Collections.Generic; using UnityEngine; public class Server : MonoBehaviour..

툴/유니티 2021.08.11

[C#] 유니티 마우스 후킹, 마우스 제어하기

유니티에서 마우스 후킹, 마우스 제어하기 using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Runtime.InteropServices; public class Hook : MonoBehaviour { [DllImport("user32.dll")] static extern void mouse_event(uint dwFlags, uint dx, uint dy, int dwData, int dwExtraInfo); private const uint MOUSEEVENTF_LEFTDOWN = 0x0002; private const uint MOUSEEVENTF_LEFTUP = 0x0004; priva..

툴/유니티 2021.08.02

[C#]유니티 TXT로 저장 및 읽기

유니티 TXT로 저장 및 읽기 using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; public class TXT_Info : MonoBehaviour { string A; //TXT의 정보를 담을 변수 void TXT_Save() { System.IO.File.WriteAllText("C:/Example/memo.txt", "txt파일에 적힐 내용"); } void TXT_Load() { A = System.IO.File.ReadAllText("C:/Example/memo.txt"); // 텍스트 파일 내용 불러오기 } } 많고 복잡한 데이터 처리를 하기에는 좋은 방법은 아니지만, 미디..

툴/유니티 2021.08.02

[C#] 유니티 렌더텍스쳐 이미지로 저장

유니티에서 렌더텍스쳐 이미지로 저장 using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; public class Shutter : MonoBehaviour { public RenderTexture DrawTexture; //PNG저장할 타겟 렌더 텍스쳐 void RenderTextureSave() { RenderTexture.active = DrawTexture; var texture2D = new Texture2D(DrawTexture.width, DrawTexture.height); texture2D.ReadPixels(new Rect(0, 0, DrawTexture.width, Dr..

툴/유니티 2021.08.02

[C#] 유니티에서 FTP로 파일 전송 및 파일 다운로드

유니티에서 FTP로 파일 전송 및 파일 다운로드 using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using System.Net; public class FTPTesttt : MonoBehaviour { void Start() { //업로드 코드 WebClient wc = new WebClient(); wc.Credentials = new NetworkCredential("아이디", "비밀번호"); wc.UploadFile("ftp://example.com/img.png", "D:/example/img.png"); // 괄호안 첫번째는 업로드시킬 웹 주소, 두번째는 업로드할 파일의 로컬 주..

툴/유니티 2021.08.02

유니티에서 타프로그램 창 화면 가져오기

https://github.com/hecomi/uWindowCapture GitHub - hecomi/uWindowCapture: This allows you to use Windows Graphics Capture / PrintWindow / BitBlt in Windows to capture mul This allows you to use Windows Graphics Capture / PrintWindow / BitBlt in Windows to capture multiple windows individually and easily use them as Texture2D in Unity. - GitHub - hecomi/uWindowCaptur... github.com 윈도우에서 작업표시줄에 표시되..

툴/유니티 2021.08.02

[C#]유니티 JSON 데이터 받아오기

유니티에서 Json 데이터 받기 using System.Collections; using System.Collections.Generic; using UnityEngine; [System.Serializable] public class JsonData { public int A; public string B; } public class JsonReceiver : MonoBehaviour { public static JsonData data1; WWW www; string T; public string url = "Json데이터 받아올 URL주소"; void Start() { InvokeRepeating("CoroutineLoad", 0, 1f); //Json데이터 반복해서 업데이트 } void Updat..

툴/유니티 2021.08.02