2019년 6월 27일 목요일

UI unity scroll view Expand item

확장 스크롤뷰!!

대충 구조는 이런식


Content 부터 수정
※ Child Controls Size를 꼭 체크해주자




List Item
실제로 view content에 바로 쌓이는 녀석

추가
Vetical Layout Group
Content Size Fitter




Header
타이틀 같은 역할 온오프도 여기밑에 토글넣어서 처리

추가
Horizontal Layout Group
Layout Element

※ Layout Element의 preferred width 체크!!!



 토글로 ItemContent를 확장할꺼임

추가
Layout Element 


※ Layout Element 의 속성값 꼭 설정!!

실제적으로 확장될 ITEM이다! 중요!!

추가
Layout Element

※ Layout Element 값 꼭 설정!!


이런식으로 scrollView이던 어떤것이든 추가 가능 크기는 머리인 ItemContent를 따라간다!!

따로 추가할 항목은 없음!! 이상!

2019년 6월 23일 일요일

csv 가짜데이터 write

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void Init_Write()
 
    {
 
        foreach (var x in SlabCreateManager.DIC_Bad_GameObjects)
 
        {
 
            float height = SlabCreateManager.DIC_Bad_State[x.Key] * 2.5f + Random.Range(010);
 
 
 
            System.IO.File.AppendAllText(Application.dataPath + @"\Bad_height_log.csv", x.Key + "," + height.ToString() + "\n"System.Text.Encoding.UTF8);
 
        } 
 
    }
cs

2019년 6월 20일 목요일

유니티 delegate 응용(매개변수를 가진 함수 담아두기, 역 옵저버) ex) OnPostRender

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
하게된 이유
OnPostRender는 카메라 밑에 있어야만 가능함
원하는 GL들은 각각의 게임오브젝트가 들고있는상황
온포스트하는 카메라에서는
 public delegate void Draw();
    public static Draw Draws;
이런식으로 각각의 객체에서 오는 함수를 담을 delegate를 만들어놓고
각각의 오브젝트에서는
 private void Start()
    {
        Draw_GL_Line.Draws += LineDraw;
    }
public void LineDraw ()
    {
        //원하는 값을 담은 함수
        //값이 변경되더라도 적용됨 (crrentHeight,Red,currentHeight_StartPos);
        GL_Line_Draw(currentHeight, Red, currentHeight_StartPos);
    }
이런식으로 하면 카메라에서는
 Draws();
이것만 콜하면 모든 게임오브젝트에서 받은 함수를 한번에 콜 한다!
cs

unity lookat only z pos

void LookZ()
    {
        var dir = Player.position - transform.position;
        Quaternion LookAtRotation = Quaternion.LookRotation(dir);

        Quaternion LookAtRotationOnly_Y = Quaternion.Euler(transform.rotation.eulerAngles.x, LookAtRotation.eulerAngles.y, transform.rotation.eulerAngles.z);
        transform.rotation = LookAtRotationOnly_Y;
    }



2019년 6월 17일 월요일

uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library

stderr[
D:\_Project\2018NTEST\Temp\gradleOut\src\main\AndroidManifest.xml:3:3-72 Error:
uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library [:cafeSdk-4.3.0:] C:\Users\Hubiz\.gradle\caches\transforms-1\files-1.1\cafeSdk-4.3.0.aar\7982a3853eeafa35fbbcad1d21717369\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 17,
or use tools:overrideLibrary="com.naver.glink.android.sdk" to force usage (may lead to runtime failures)


직접 해당 AndroidManifest.xml 파일을 찾아가서

 android:minSdkVersion="16"에 있는 값을 적당한 값으로 수정한다

그럼 에러잡힘 ㅅㄱ~

2019년 6월 11일 화요일

소름돋는점

칼세이건 사망날짜
1996년 12월 20일

내생일
1990년 12월 20일

소름...

창백한 푸른 점 (사진을 찍은 날짜는 1990년 2월 14일이다)

1990년, 태양계를 벗어나기 직전 보이저 1호는 지구의 지령에 따라 자세를 제어, 신호 도달에 6시간이 걸리는 명왕성 근처 우주 공간에서 지구를 조준해 사진을 찍엇다.
여기에 유명한 이야기가 있다.

보이저 프로젝트에 참여한 칼 세이건은 보이저 1호의 카메라 방향을 지구 쪽으로 돌려 찍자는 제안을 했다. 칼 세이건이 이 사진을 표지로 실은 저서 '창백한 푸른 점(Pale Blue Dot)에서 말하기를, 자신도 그 머나먼 거리에서 지구를 찍는 것은 과학적 활동과 별 관련이 없다고 생각하긴 하나, 우주 속 인류의 위치를 바라볼 수 있는 좋은 기회가 될 것이라 판단해서 제안했다고 한다.NASA 측도 대체로 세이건의 의견을 지지하는 입장이었으나, 칼 세이건의 생각과는 달리 전문가들은 어마어마한 예산을 투입한 보이저 1호에게 만에 하나 태양 빛 때문에 렌즈에 손상이 가는 것을 원치는 않았고 제안은 무산되나 싶었다. 12년 가량이 지난 후 보이저 호의계획됐던 임무들이 모두 끝난다. 칼 세이건의 제안에꽤나 호의적이었던 전 우주 비행사 리처드 트룰리가 NASA의 국장이 되었고 그는 보이저 호의 카메라를 돌려지구 쪽으로 사진을 찍으라고 지시하는데,그것이 바로 아래의 사진이다. 사진을 찍은 날짜는 1990년 2월14일이다.



동그라미 속 저 작은 점이 바로 우리가 사는 지구이다. 정확히는지구만 찍은 것이 아니라 태양과 함께 지구를 포함한 태양계의 여섯 개 행성들을 촬영한 사진 중 지구 부분만 잘라낸 것이다. 이때 태양과 함께 찍었던 행성들은 금성,지구,목성,토성,천왕성,해왕성.
사진에서 지구 위를 지나가는 광선은 태양광이 아니라 보이저 1호의 카메라에 태양빛이 반사되어 생긴것으로, 우연한 효과에 불과하다.

그리고 칼 세이건은 인류에게 잊지 못할 메세지를 전한다.

참고로 그의 저서이자 역작 코스모스 리부트판에서 다시금 현대의 기술력으로 그의 아래 명언을 영상으로 빚어낸 자료가 있으니 이 영상을 먼저 보기를 추천한다.

Look again at that dot. That's here. That's home. That's us. On it everyone you love, everyone you know, everyone you ever heard of, every human being who ever was, lived out their lives. The aggregate of our joy and suffering, thousands of confident religions, ideologies, and economic doctrines, every hunter and forager, every hero and coward, every creator and destroyer of civilization, every king and peasant, every young couple in love, every mother and father, hopeful child, inventor and explorer, every teacher of morals, every corrupt politician, every "superstar," every "supreme leader," every saint and sinner in the history of our species lived there - on a mote of dust suspended in a sunbeam.

The Earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that, in glory and triumph, they could become the momentary masters of a fraction of a dot. Think of the endless cruelties visited by the inhabitants of one corner of this pixel on the scarcely distinguishable inhabitants of some other corner, how frequent their misunderstandings, how eager they are to kill one another, how fervent their hatreds.

Our posturings, our imagined self-importance, the delusion that we have some privileged position in the Universe, are challenged by this point of pale light. Our planet is a lonely speck in the great enveloping cosmic dark. In our obscurity, in all this vastness, there is no hint that help will come from elsewhere to save us from ourselves.

The Earth is the only world known so far to harbor life. There is nowhere else, at least in the near future, to which our species could migrate. Visit, yes. Settle, not yet. Like it or not, for the moment the Earth is where we make our stand.

It has been said that astronomy is a humbling and character-building experience. There is perhaps no better demonstration of the folly of human conceits than this distant image of our tiny world. To me, it underscores our responsibility to deal more kindly with one another, and to preserve and cherish the pale blue dot, the only home we've ever known.

저 점을 다시 보세요. 저것이 바로 이곳입니다. 저것이 우리의 고향입니다. 저것이 우리입니다. 우리가 사랑하는 모든 이들, 우리가 알고 들어보았을 모든 사람들, 존재했던 모든 인류가 저 곳에서 삶을 영위했습니다. 우리의 모든 즐거움과 고통이, 우리가 확신하는 모든 종교, 이념, 경제 체제가, 모든 사냥꾼과 약탈자가, 모든 영웅과 겁쟁이가, 모든 문명의 창시자와 파괴자가, 모든 왕과 농부가, 사랑에 빠진 모든 젊은 연인들이, 모든 어머니와 아버지가, 희망에 찬 모든 아이가, 모든 발명가와 탐험가가, 모든 도덕 선생님들이, 모든 부패한 정치가가, 모든 인기 연예인들이, 모든 위대한 지도자들이, 모든 성인과 죄인들이 저곳 - 태양 빛 속에 부유하는 먼지의 티끌 위에서 살았던 것입니다.

지구는 우주라는 거대한 극장의 아주 작은 무대입니다. 그 모든 장군과 황제들이 아주 잠시 동안 저 점의 일부분을 지배하려 한 탓에 흘렀던 수많은 피의 강들을 생각해 보십시오. 저 점의 한 영역의 주민들이 거의 분간할 수도 없는 다른 영역의 주민들에게 얼마나 많은 잔학 행위를 저지르는지를, 그들이 얼마나 자주 불화를 일으키고, 얼마나 간절히 서로를 죽이고 싶어 하며, 얼마나 열렬히 서로를 증오하는지를 생각해 보십시오.

우리의 만용, 우리의 자만심, 우리가 우주 속의 특별한 존재라는 착각에 대해, 저 희미하게 빛나는 점은 이의를 제기합니다. 우리 행성은 사방을 뒤덮은 어두운 우주 속의 외로운 하나의 알갱이입니다. 이 거대함 속에 묻힌 우리를 우리 자신으로부터 구해 줄 이들이 다른 곳에서 찾아올 기미는 보이지 않습니다.

아직까지 알려진 바로 지구는 생명을 품은 유일한 행성입니다. 적어도 가까운 미래에 우리 종이 이주할 수 있는 곳은 없습니다. 다른 세계를 방문할 순 있지만, 정착은 아직 불가능합니다. 좋든 싫든, 현재로선 우리가 머물 곳은 지구뿐입니다.

천문학을 공부하면 겸손해지고 인격이 함양된다는 말이 있습니다. 멀리서 찍힌 이 이미지만큼 인간의 자만이 어리석다는 걸 잘 보여 주는 건 없을 겁니다. 저 사진은 우리가 서로 친절하게 대하고, 우리가 아는 유일한 보금자리인 창백한 푸른 점을 소중히 보존하는 것이 우리의 의무임을 강조하고 있는 것입니다.

2019년 6월 6일 목요일

광부 예제(상태 패)

using UnityEngine;
using System.Collections;

public class miner : MonoBehaviour
{
    public enum State
    {
        EnterMineAndDigForNuggets,
        EnterBankAndDepositGold
    }

    public State state;

    public void Awake()
    {
        state = State.EnterMineAndDigForNuggets;

        // Start the Finite State Machine
        StartCoroutine(FSM());
    }

    IEnumerator FSM()
    {
        // Execute the current coroutine (state)
        while (true)
        {
            yield return StartCoroutine(state.ToString());
        }
    }

    IEnumerator EnterMineAndDigForNuggets()
    {
        /* This part works as the Enter function
    of the previous post (it's optional) */

        print("Entering the mine...");
        yield return null;

        /* Now we enter in the Execute part of a state
    which will be usually inside a while - yield block */

        bool dig = true;
        int digged = 0;
        while (dig)
        {
            print("Digging... " + (digged++) + " " + Time.time);
            if (digged == 2) dig = false;
            yield return new WaitForSeconds(1);
        }

        /* And finally do something before leaving
    the state (optional too) and starting a new one */

        print("Exiting the mine...");
        state = State.EnterBankAndDepositGold;
    }

    IEnumerator EnterBankAndDepositGold()
    {
        //Enter
        print("Entering the bank...");
        yield return null;

        //Execute
        bool queing = true;
        float t = Time.time;
        while (queing)
        {
            print("waiting...");
            if (Time.time - t > 5) queing = false;
            yield return new WaitForSeconds(1);
        }

        //Exit
        print("Leaving the bank a little bit richer...");
        state = State.EnterMineAndDigForNuggets;
    }
}

2019년 6월 1일 토요일

추상클래스(C#)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
예제
 
 
 
동물들은 울수 있지만 동물 그 자체는 우는 방식을 결정할 수 없다.
 
그래서 animal의 sound메서드는 본체를 가지지 않는 추상 메서드로 정의
 
동물들은 분형히 울기는 우는데 어떻게 우는지는 Animal단계에서는 정의할수 없고
 
아래 단계까지 내려가야함
 
 
 
namespace Abstract
 
{
 
    abstract class Animal
 
    {
 
        public abstract void sound();
 
    }
 
 
 
    class Dog : Animal
 
    {
 
        public override void sound()
 
        {
 
            Debug.Log("멍멍");
 
        }
 
    }
 
    class Cat : Animal
 
    {
 
        public override void sound()
 
        {
 
            Debug.Log("야옹");
 
        }
 
    }
 
 
 
    class temp : MonoBehaviour
 
    {
 
        private void Start()
 
        {
 
            Abstract.Animal A;
 
            A = new Abstract.Dog(); A.sound();
 
            A = new Abstract.Cat(); A.sound();
 
        }
 
    }
 
    
 
}
 
 
 
출처 : 가메출판사, 닷넷 프로그래밍 정복, 김상형 저
cs

git rejected error(feat. cherry-pick)

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