2020년 4월 28일 화요일

C# 배열 붙이기



Array.Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length);
Array.Copy(a,ai,b,bi,a.Length);
A를 B로 복사한다. a의 ai번지부터 a.Length까지를 b의 bi 번지부터 복사한다.


2020년 4월 20일 월요일

작업 중간에 pull 받기 위한 순서

작업 중간에 pull 받기 위한 순서


1. 현재 상태를 stash에 저장한다.

git stash

2. 원격 저장소 데이터를 로컬에 pull 받는다

git pull

3. stash에 저장되어 있는 변경사항을 로컬에 다시 가져온다

git stash pop


주의!!. 다음에 push할때 stash pop 했는지 꼭 확인해야한다. 아니면 stash에 저장된 사항은 원격 저장소에 push 할 수 없다

~~ 시간날때 브런치를 이용해서 하는걸 실험해보자~.

git add . 은 untrackedfile까지 모두 추적함

git add -u 옵션을 사용하면 untrackedfile은 commit 목록에 올리지 않는다
























Regex.Split 메서드를 이용해 분할한다.

var text = "Word, Excel ,PowerPoint , Outlook,OneNote";
var pattern = @"\s*,\s*";
string[] substrings = Regex.Split(text, pattern);
foreach(var match in substrings)
{
Debug.Log(match);
}

@"\s*,\s*" 는 ','나 ' ,'나 ', '같은 문자열과 일치한다.
이 코드를 실행한 결과는 다음과 같다

Word
Excel
PowerPoint
Outlook
OneNote

2020년 4월 17일 금요일

remote: HTTP Basic: Access denied

계정정보입력할때 잘못 입력하면 나옴
이때는 관리자 권한으로 아래 명령을 실행한다.
git config --system --unset credential.helper
를 실행하면 된다

2020년 4월 12일 일요일

Event를 호출시에는 null 연산자를 사용해라

public void RaiseUpdates()
{
  counter++;
  Updated?.Invoke(this, counter);
}

이 코드는 null 조건 연산자(?.)를 사용하여 안전하게 이벤트 핸들러를 호출한다.!

2020년 4월 9일 목요일

Universal Joint 동작(개별객체)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TriggerRoll : MonoBehaviour
{
    public Transform target;
    public bool x = false, y = false, z = false;
    public float speed = 20f;
    public bool isReverse = false;
    private bool isRun = false;
    public float prevRot;
    private int dir = 1;
    void Update()
    {
        if (UnityEditor.TransformUtils.GetInspectorRotation(target.transform).z != prevRot)
        {
            isRun = true;

            if (prevRot < UnityEditor.TransformUtils.GetInspectorRotation(target.transform).z)
            {
                dir = 1;
            }
            else
                dir = -1;

            prevRot = UnityEditor.TransformUtils.GetInspectorRotation(target.transform).z;
        }
        else
            isRun = false;

        if (isRun)
        {
            if (!isReverse)
            {
                transform.Rotate(x ? 6f*dir * speed * Time.deltaTime : 0f,
                                 y ? 6f * dir * speed * Time.deltaTime : 0f,
                                 z ? 6f * dir * speed * Time.deltaTime : 0f);
            }
            else
            {
                transform.Rotate(x ? 6f * dir * speed * Time.deltaTime * -1 : 0f,
                                 y ? 6f * dir * speed * Time.deltaTime * -1 : 0f,
                                 z ? 6f * dir * speed * Time.deltaTime * -1 : 0f);
            }
        }
    }
}

Unity Inspector의 rotation 값 그대로 사용하기

UnityEditor.TransformUtils.GetInspectorRotation(target.transform).x
UnityEditor.TransformUtils.GetInspectorRotation(target.transform).y
UnityEditor.TransformUtils.GetInspectorRotation(target.transform).z

주의 빌드시에는 사용불가

git rejected error(feat. cherry-pick)

 문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...