'깃허브' 카테고리의 다른 글
connect to github popup error (0) | 2021.06.29 |
---|---|
GitHub Desktop 사용법 (0) | 2021.06.28 |
the following files are over 100mb github (0) | 2021.06.28 |
connect to github popup error (0) | 2021.06.29 |
---|---|
GitHub Desktop 사용법 (0) | 2021.06.28 |
the following files are over 100mb github (0) | 2021.06.28 |
홈페이지에서 생성후 끌고오는방법
주의할점
폴더구조를 저렇게 해야한다
깃헙 데스크톱에서 생성하는 방법
가급적 생성전에 동일한 프로젝트 명으로 해당 위치에 유니티 프로젝트를 만들자
test는 프로젝트 폴더명이고
testgit은 프로젝트들이 담기는 깃폴더명이다
만약 윈폼이라면 이걸 쓴다
푸쉬를 누르면 파일이 올라간다
그 외-
이것도 깔면 유니티 내에서 업데이트 내역이 보여서 개편해진다 (필수는 아님)
-LFS같은 기능을 쓰려면 Git을 별도로 설치해야 한다 (링크참조)
https://wmmu.tistory.com/entry/Git-%EC%84%A4%EC%B9%98%EB%B0%A9%EB%B2%95
머지충돌이 자꾸나면 프로젝트 세팅이 저렇게 되어있는지 확인하자
최신버전은 저게 기본값이다
connect to github popup error (0) | 2021.06.29 |
---|---|
GitHub 유저 초대 (0) | 2021.06.28 |
the following files are over 100mb github (0) | 2021.06.28 |
깃 LFS붙이기
용량이 너무 커서 안 된단다.
LFS로 별도 등록을 해 주어야 한다
cmd를 열어주자
git lfs install
git lfs track "*.so"
.so파일이 100mb넘은거라서 .so를 쳐줬다
입맛에 맞게 바꾸자
이제 커밋하면 된다
----------------------------------------------------------------------------------
언트랙 하려면
git lfs untrack "*.so"
----------------------------------------------------------------------------------
단일파일 지정시
git lfs track 경로
얼마전에 LFS요금 나왔더라 ㅠ 단일파일지정으로 꼭 필요한거만 해주자
connect to github popup error (0) | 2021.06.29 |
---|---|
GitHub 유저 초대 (0) | 2021.06.28 |
GitHub Desktop 사용법 (0) | 2021.06.28 |
드래그 체크
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class CustomInteface : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public GameObject ui;
// Start is called before the first frame update
void Start()
{
}
public void OnBeginDrag(PointerEventData data)
{
}
public void OnDrag(PointerEventData data)
{
}
public void OnEndDrag(PointerEventData data)
{
var zPos = transform.position.z;
var pos = Camera.main.ScreenToWorldPoint(data.position);
pos.z = zPos;
var pressPos = Camera.main.ScreenToWorldPoint(data.pressPosition);
pressPos.z = zPos;
ui.transform.position = pos;
}
// Update is called once per frame
void Update()
{
}
}
아이템 드래그
if (Vector2.Distance(eventData.pressPosition,eventData.position)>300)
{
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(GetComponent<RectTransform>(), eventData.position, eventData.pressEventCamera, out var worldPoint))
{
transform.position = worldPoint;
}
}
else
{
transform.position = eventData.pressPosition;
}
유니티 좌표계산 모음 (0) | 2021.07.01 |
---|---|
유니티 기즈모 (Gizmo) 관련코드 (0) | 2021.06.15 |
유니티 안드로이드 빌드관련 스크립트 (0) | 2021.06.10 |
void Start()
{
}
void OnGUI()
{
}
/*
void OnLevelWasLoaded()
{
//씬이동시 발생(레거시 코드)
}
*/
void Update()
{
//매프레임 발생
}
void OnTriggerEnter(Collider other)
{
//트리거 콜라이더 충돌시 발생
}
씬이동시 발생
void OnSceneLoaded(UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode loadSceneMode)
{
AssetUnLoad();
}
void Start()
{
UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoaded;
}
LogError 뜰때마다 pause 되는현상 수정 (0) | 2021.09.24 |
---|---|
유니티 VR 세팅관련 (0) | 2021.05.15 |
오큘러스 컴포넌트 및 프리팹 (0) | 2021.05.15 |
문자열 처리
int StringToHex(char str[])
{
return (int) strtol(str, 0, 16);
}
int StringToHex(String text)
{
return (int) strtol(text.c_str(), 0, 16);
}
void StringToHexArray(byte *byteArray,String text)
{
for(int i=0;i<text.length();i++)
{
byteArray[i]=StringToHex(text.substring(i*2,i*2+2));
}
}
String IntToHexString(int hexInt)
{
return String("0123456789ABCDEF"[hexInt/16])+String("0123456789ABCDEF"[hexInt%16]);
}
문자열 연산
//정적 문자열+정적 문자열
String text=String("text1")+String("text2");
//문자열+숫자
String text=String("text1")+number;
//문자열+캐릭터
String text=String("text1")+char;
enum (개구림)
//선언부
enum State {
Start, //다른 Enum인자명, 함수명과 동일하면 안된다
NonPlaying,
Playing
};
State state=Start;
//switch
String Message="Unknown";
switch(state)
{
case Start:
Message="Start";
break;
case NonPlaying:
Message="NonPlaying";
break;
}
//enum연산
state=(State)((int)state+1);
enum 길이
슬프게도 이것보다 더 좋은 방법을 찾을수 없었다
enum State {
Start,
NonPlaying,
Playing,
Count
};
int _max=Count;
enum class
이름 충돌 방지한답시고 더 귀찮게 만들어놨다.
유지보수하는놈은 지능 덜 떨어진게 분명함. C#좀 보고 배워야 한다
//선언부
enum class State {
Start,
NonPlaying,
Playing
};
State state=State::Start;
//switch
String Message="Unknown";
switch(state)
{
case State::Start:
Message="Start";
break;
case State::NonPlaying:
Message="NonPlaying";
break;
}
//enum연산
state=(State)((int)state+1);
enum class 길이
enum class State {
Start,
NonPlaying,
Playing,
Count
};
int _max=(int)State::Count;
//연산에 적용
state=(State)((int)state-1);
if((int)state<0)
{
state=(State)((int)State::Count-1);
}
state=(State)((int)state+1);
if(state>=State::Count)
{
state=(State)0;
}
비프, 부저 (패시브)
void HandmadeTone(int pin,int frequency,int duration)
{
#if defined(ARDUINO_AVR_UNO)
tone(pin, frequency, duration);
#else
bool pinState=HIGH;
int delayTime=(1000*1000)/(frequency*4);
for(int i=0;i<(duration*1000)/delayTime;i++)
{
pinState=!pinState;
digitalWrite(pin, pinState);
delayMicroseconds(delayTime);
}
digitalWrite(pin, LOW);
#endif
}
void Beef()
{
int pin=4;
int frequency=768;
int duration=100;
HandmadeTone(pin, frequency, duration);
}
void BeefError()
{
int pin=4;
int frequency=768*0.25;
int duration=100;
HandmadeTone(pin, frequency, duration);
delay(100);
HandmadeTone(pin, frequency, duration);
}
버튼
내부적으로 저항이 생기기 때문에 별도 저항연결이 필요없다
int pinButton=2;
void setup()
{
pinMode(pinButton, INPUT_PULLUP);
}
void loop()
{
if(!digitalRead(pinButton))
{
//실행코드
while(!digitalRead(pinButton))
{
delay(10);
}
}
}
델타타임
unsigned long currentTime=0;
unsigned long currentTimePrevious=0;
float deltaTime=0.01;
void SetDeltaTime()
{
currentTime=millis();
float deltaTimeTemp=((float)(currentTime-currentTimePrevious))/1000;
currentTimePrevious=currentTime;
if(deltaTimeTemp>0)
{
deltaTime=deltaTimeTemp;
}
}
void loop()
{
SetDeltaTime() ;
Serial.println(String(deltaTime));
}
조이스틱
int xVal=analogRead(A0);
if(xVal<128)
{
//Left
delay(400);
}
if(xVal>1024-128)
{
//Right
delay(400);
}
int yVal=analogRead(A1);
if(yVal<128)
{
//Up
delay(400);
}
if(yVal>1024-128)
{
//Down
delay(400);
}
개빡치게 중앙값이 750~800이고 조금만 움직여도 맥스값을 찍는다
C++판 nameof
#define NAMEOF(name) #name
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
int frequency=768;
Serial.print(__func__); //setup
Serial.print(NAMEOF(frequency)); //frequency
}
__func__ 가 함수명이고
NAMEOF는 define으로 선언해주어야 한다
완벽히 동일한 기능을 하는건 아니고 잘못된 값을 넣어도 잘만 컴파일 된다. IDE에서 이름확인하는데에만 쓰자
define 원래 용도가 이건데 매크로같은 용도이다.
자세한건
https://dev.to/tomoyukiaota/exploring-c-equivalent-of-cs-nameof-operator-1p8c
http://www.cplusplus.com/forum/beginner/206693/
두곳을 참조하자
EEPROM
어드레스 0~512
값 0~255
#include <EEPROM.h>
int index=0;
int indexAddress=0;
void Read()
{
index = EEPROM.read(indexAddress);
}
void Save()
{
EEPROM.write(indexAddress, index);
}
c++
아두이노 헤더 예제 (0) | 2021.07.15 |
---|---|
byte to hex (0) | 2021.02.23 |
아두이노 RC522 (RFID 13.56MHz) (0) | 2020.11.12 |
구를그림
void OnDrawGizmos()
{
Gizmos.DrawWireSphere(transform.position, radius);
}
가려지지 않는 구를 그림
void OnDrawGizmos()
{
#if UNITY_EDITOR
UnityEditor.Handles.DrawWireDisc(transform.position, transform.up, radius);
UnityEditor.Handles.DrawWireDisc(transform.position, transform.right, radius);
UnityEditor.Handles.DrawWireDisc(transform.position, transform.forward, radius);
#endif
}
원을 그림
void OnDrawGizmos()
{
UnityEditor.Handles.DrawWireDisc(transforms[i].position, fowordAngle * Vector3.up, radius);
}
텍스트 표시
#if UNITY_EDITOR
void OnDrawGizmos()
{
UnityEditor.Handles.Label(transform.position, "text");
}
#endif
폰트설정한 텍스트 표시
var guiStyle = new GUIStyle();
guiStyle.alignment = TextAnchor.MiddleCenter; //왜인지 UpperLeft로만 된다
guiStyle.fontSize = 48;
guiStyle.normal.textColor = color;
UnityEditor.Handles.Label(transform.position, "text", guiStyle);
선그리기 커스텀
void DrawLine(params Transform[] transforms)
{
transforms = System.Array.FindAll(transforms, x => x != null);
if ((transforms == null) || (transforms.Length < 2))
{
return;
}
for (int i = 0; i < transforms.Length-1; i++)
{
Gizmos.DrawLine(transforms[i].position, transforms[i+1].position);
}
}
회전가능한 Cube
static void DrawWireCubeOverlay(Vector3 center, Vector3 size, Quaternion rotation)
{
#if UNITY_EDITOR
{
var size1 = size;
var size2 = size1;
for (int x = -1; x <= 1; x += 2)
{
for (int y = -1; y <= 1; y += 2)
{
size1.x = size.x * x;
size1.y = size.y * y;
size2 = size1;
size1.z = size.z;
size2.z = -size1.z;
DrawLine(size1, size2);
}
}
for (int y = -1; y <= 1; y += 2)
{
for (int z = -1; z <= 1; z += 2)
{
size1.y = size.y * y;
size1.z = size.z * z;
size2 = size1;
size1.x = size.x;
size2.x = -size1.x;
DrawLine(size1, size2);
}
}
for (int x = -1; x <= 1; x += 2)
{
for (int z = -1; z <= 1; z += 2)
{
size1.x = size.x * x;
size1.z = size.z * z;
size2 = size1;
size1.y = size.y;
size2.y = -size1.y;
DrawLine(size1, size2);
}
}
}
void DrawLine(Vector3 size1, Vector3 size2)
{
UnityEditor.Handles.DrawLine(center + rotation * (size1 / 2), center + rotation*(size2 / 2));
}
#endif
}
캡슐을 그림
static void DrawCapsule(float radius, params Transform[] transforms)
{
transforms = System.Array.FindAll(transforms, x => x != null);
if ((transforms == null) || (transforms.Length < 2))
{
return;
}
for (int i = 1; i < transforms.Length; i++)
{
DrawCapsule(transforms[i - 1].position, transforms[i].position, radius);
}
}
static void DrawCapsule(Vector3 start, Vector3 end, float radius)
{
var fowordAngle = Quaternion.LookRotation(start - end, Vector3.up);
start += (end - start).normalized * radius;
end -= (end - start).normalized * radius;
#if UNITY_EDITOR
UnityEditor.Handles.DrawWireDisc(start, fowordAngle * Vector3.forward, radius);
UnityEditor.Handles.DrawWireArc(start, fowordAngle * Vector3.up, fowordAngle * -Vector3.right, 180, radius);
UnityEditor.Handles.DrawWireArc(start, fowordAngle * Vector3.right, fowordAngle * Vector3.up, 180, radius);
UnityEditor.Handles.DrawWireDisc(end, fowordAngle * Vector3.forward, radius);
UnityEditor.Handles.DrawWireArc(end, fowordAngle * Vector3.up, fowordAngle * Vector3.right, 180, radius);
UnityEditor.Handles.DrawWireArc(end, fowordAngle * Vector3.right, fowordAngle * -Vector3.up, 180, radius);
#endif
Vector3 upVector = fowordAngle * Vector3.up * radius;
Vector3 rightVector = fowordAngle * Vector3.right * radius;
#if UNITY_EDITOR
UnityEditor.Handles.DrawLine(start + upVector, end + upVector);
UnityEditor.Handles.DrawLine(start + rightVector, end + rightVector);
UnityEditor.Handles.DrawLine(start - upVector, end - upVector);
UnityEditor.Handles.DrawLine(start - rightVector, end - rightVector);
#endif
}
실린더를 그림
void DrawCylinder(float radius, params Transform[] transforms)
{
transforms = System.Array.FindAll(transforms, x => x != null);
if ((transforms == null) || (transforms.Length < 2))
{
return;
}
for (int i = 1; i < transforms.Length; i++)
{
DrawCylinder(transforms[i - 1].position, transforms[i].position, radius);
}
}
void DrawCylinder(Vector3 start, Vector3 end, float radius)
{
var fowordAngle = Quaternion.LookRotation(start - end, Vector3.up);
#if UNITY_EDITOR
UnityEditor.Handles.DrawWireDisc(start, fowordAngle * Vector3.forward, radius);
UnityEditor.Handles.DrawWireDisc(end, fowordAngle * Vector3.forward, radius);
#endif
Vector3 upVector = fowordAngle * Vector3.up * radius;
Vector3 rightVector = fowordAngle * Vector3.right * radius;
#if UNITY_EDITOR
UnityEditor.Handles.DrawLine(start + upVector, end + upVector);
UnityEditor.Handles.DrawLine(start + rightVector, end + rightVector);
UnityEditor.Handles.DrawLine(start - upVector, end - upVector);
UnityEditor.Handles.DrawLine(start - rightVector, end - rightVector);
#endif
}
콜라이더를 그림
void DrawColliderGizmo(Transform transform)
{
if (transform != null)
{
DrawColliderGizmo(transform.gameObject);
}
}
void DrawColliderGizmo(GameObject gameObject)
{
if (gameObject != null)
{
var sphereCollider = gameObject.GetComponent<SphereCollider>();
if (sphereCollider != null)
{
Gizmos.DrawWireSphere(transform.position, sphereCollider.radius);
}
}
}
컬러적용
Gizmos.color = Color.red;
{
Gizmos.DrawLine(cameraPosition.position, thirdPersonPoint.position);
}
Gizmos.color = Color.white;
선택된 상태에서만 기즈모를 그림
void OnDrawGizmosSelected()
{
//기즈모를 그림
}
혹은
#if UNITY_EDITOR
if (Selection.transforms.Contains(transform))
{
//기즈모를 그림
}
#endif
화살표 표시 (arrow)
#if UNITY_EDITOR
Handles.color = Handles.xAxisColor;
UnityEditor.Handles.ArrowHandleCap(0, transform.position, transform.rotation * Quaternion.Euler(0, 90, 0), size: 0.25f, EventType.Repaint);
Handles.color = Handles.yAxisColor;
UnityEditor.Handles.ArrowHandleCap(0, transform.position, transform.rotation * Quaternion.Euler(-90, 0, 0), size: 0.25f, EventType.Repaint);
Handles.color = Handles.zAxisColor;
UnityEditor.Handles.ArrowHandleCap(0, transform.position, transform.rotation, size: 0.25f, EventType.Repaint);
Handles.color = Color.white;
#endif
EditorWindow에서 그릴때
Debug 계열만 됨
void OnGUI()
{
if (armTransform != null)
{
Debug.DrawLine(armTransform.position, armTransform.position+Vector3.forward,Color.red);
}
}
void Update()
{
Repaint();
}
유니티 커스텀 인터페이스 (0) | 2021.06.24 |
---|---|
유니티 안드로이드 빌드관련 스크립트 (0) | 2021.06.10 |
유니티 오디오 관련 코드 (0) | 2021.06.01 |