'전체 글'에 해당되는 글 1803건

  1. 2019.03.07 C# 컴파일 그리고 il2cpp
  2. 2019.03.07 JsonUtility
  3. 2019.03.04 [UI] 스킬목록 최종
  4. 2019.03.04 마케팅을 할 줄 모르는 인디게임 개발자들
  5. 2019.02.28 Proxy Pattern (구조패턴 : 프록시패턴)
  6. 2019.02.25 팀 프로젝트 서비스

C# 컴파일 그리고 il2cpp

Unity3D 2019. 3. 7. 01:50
반응형

https://blogs.unity3d.com/kr/2015/09/22/kr-csharp-compile-il2cpp/


원문 : https://blogs.unity3d.com/2015/05/06/an-introduction-to-ilcpp-internals/


반응형

'Unity3D' 카테고리의 다른 글

Orthographic size  (0) 2019.04.17
How Unity Supports Cross Platform Feature  (0) 2019.03.20
JsonUtility  (0) 2019.03.07
Unity의 회전 및 오리엔테이션  (0) 2019.02.20
Unity와 Firebase 실시간 데이터베이스 + 구글로그인  (0) 2019.02.12
:

JsonUtility

Unity3D 2019. 3. 7. 01:31
반응형

https://docs.unity3d.com/kr/current/Manual/JSONSerialization.html

https://answers.unity.com/questions/1123326/jsonutility-array-not-supported.html



벤치마크 테스트에서는 JsonUtility가 인기 .NET JSON 솔루션에 비해(일부 솔루션보다 기능이 더 적기는 하지만) 훨씬 빠른 것으로 나타났습니다.


지원되는 타입

API는 MonoBehaviour 서브클래스, ScriptableObject 서브 클래스, 또는 [Serializable] 속성이 있는 일반 클래스/구조체를 지원합니다. 사용자가 전달하는 오브젝트는 스탠다드 Unity 시리얼라이저에 공급되어 처리되므로, 인스펙터에서 적용되는 규칙과 제한이 동일하게 적용됩니다. 즉 필드만 직렬화되고 Dictionary<> 같은 타입은 지원되지 않습니다.

예를 들어 프리미티브 타입 또는 배열 등 다른 타입을 API에 직접 전달하는 기능은 현재 지원되지 않습니다. 지금은 이러한 타입을 일종의 class 또는 struct에 래핑해야 합니다.

에디터에만 EditorJsonUtility라는 병렬 API가 있습니다. API는 UnityEngine.Object에서 파생된 타입을 JSON과 상호 직렬화하기 위해 사용할 수 있습니다. 그러면 오브젝트의 YAML 표현과 동일한 데이터가 포함된 JSON이 생성됩니다.


문자열 인용부호 넣기 

https://docs.microsoft.com/ko-kr/dotnet/framework/winforms/controls/how-to-put-quotation-marks-in-a-string-windows-forms

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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
[Serializable]
public class CharacterData
{
    public int id;
    public string name;
    public string res_name;
    public string sprite_name;
}
 
public class JsonUtilityHelper
{
    public static T[] FromJson<T>(string json)
    {
        string newJson = "{ \"array\": " + json + "}";
        Debug.Log(newJson);
        Wrapper<T> wrapper = JsonUtility.FromJson<Wrapper<T>>(newJson);
        return wrapper.array;
    }
 
    public static string ToJson<T>(T[] array)
    {
        Wrapper<T> wrapper = new Wrapper<T>();
        wrapper.array = array;
        return JsonUtility.ToJson(wrapper);
    }
 
    [Serializable]
    private class Wrapper<T>
    {
        public T[] array;
    }
}
 
public class App : MonoBehaviour
{
    public TextAsset ta;
 
    // Start is called before the first frame update
    void Start()
    {
        var arrCharacterData = JsonUtilityHelper.FromJson<CharacterData>(ta.text);
        foreach (var data in arrCharacterData)
        {
            Debug.LogFormat("{0} {1}", data.id, data.name);
        }
 
        var json = JsonUtilityHelper.ToJson(arrCharacterData);
        Debug.Log(json);
 
    }
 
    // Update is called once per frame
    void Update()
    {
        
    }
}
 
cs





public class CharacterData
{
    public int id;
    public string name;
    public string res_name;
    public string sprite_name;
}


[Serializable] 하지 않는다면?


NullReferenceException: Object reference not set to an instance of an object

App.Start () (at Assets/App.cs:48)

Serialization은 개체를 저장하거나 메모리, 데이터베이스 또는 파일로 전송하기 위해 개체를 바이트 스트림으로 변환하는 프로세스입니다. 주 목적은 필요할 때 다시 만들 수 있도록 개체의 상태를 저장하는 것입니다. 역 프로세스를 deserialization이라고 합니다.

Serialization 작동 방법

이 그림에서는 serialization의 전체 프로세스를 보여 줍니다.

Serialization 그래픽

개체는 스트림으로 serialize되어 데이터 뿐만 아니라 버전, 문화권 및 어셈블리 이름과 같은 개체 형식에 대한 정보를 운반합니다. 해당 스트림에서 데이터베이스, 파일 또는 메모리에 저장될 수 있습니다. (이하 생략)



https://docs.microsoft.com/ko-kr/dotnet/csharp/programming-guide/concepts/serialization/





반응형
:

[UI] 스킬목록 최종

Project 2019. 3. 4. 13:55
반응형

스킬 목록 최종 





반응형

'Project' 카테고리의 다른 글

시스템 재구성  (0) 2019.06.06
공주를 구해줘 시스템 개선  (0) 2019.06.05
[UI] 스킬목록  (0) 2019.02.25
스킬시스템  (0) 2019.02.21
아이템 구조  (0) 2019.02.18
:

마케팅을 할 줄 모르는 인디게임 개발자들

Marketing 2019. 3. 4. 12:07
반응형

https://blog.naver.com/goodmoon13/221201970418

반응형
:

Proxy Pattern (구조패턴 : 프록시패턴)

Design Patterns 2019. 2. 28. 11:43
반응형
디자인패턴이란?

소프트웨어 디자인에서 특정 문맥에서 공통적으로 발생하는 문제에 대해 재사용 가능한 해결책 

소프트웨어 설계에서 특정 맥락에 자주발생하는 고질적 문제들이 발생했을때 재사용할수 있는 방법 

GoF디자인패턴 
3가지 구조(생성, 행위, 구조)

Proxy Pattern (프록시 패턴 / 구조패턴)

액션을 취하는 객체의 대리자 역활을 한다.
1. 객체를 생성가능.
2. 액세스 권한
3. 메모리를 절약


카메라 Projection , order in layer는 상관없음 

Perspective + Physics.Raycast :  O
Orthographic + Physics.Raycast :   O


Perspective + Physics2D.Raycast : X
Orthographic + Physics2D.Raycast :  O

Perspective + Physics2D.GetIntersection : X
Orthographic + Physics2D.GetIntersection  :  O

Perspective , Physics2D : 예측 가능한대로 실행되지 않음 ??, 왜???






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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.StyleSheets;
using UnityEngine;
 
public class GameEnums
{
    public enum eZergUnitType
    {
        NONE = -1,
        DRONE,
    }
}
 
public class App : MonoBehaviour
{
    private Cocoon cocoon;
    private Hatchery hatchery;
    private  List<IZerg> zergUnits = new List<IZerg>();
 
    
    public static App Instance;
 
    void Awake()
    {
        App.Instance = this;
 
        EventDispatcher.GetInstance().AddEventListener("CreateDroneEvent", EventDispatcher.GetInstance().TestEventHandler, (sender, e) =>
        {
            Debug.Log("<color=red>1</color>");
            var args = e as Cocoon.CocoonEventArgs;
            this.zergUnits.Add(args.drone);
            Debug.LogFormat("{0} / 200"this.zergUnits.Count);
        });
 
        EventDispatcher.GetInstance().AddEventListener("DroneDieEvent", EventDispatcher.GetInstance().TestEventHandler, (sender, e) =>
        {
            Debug.Log("<color=red>APP: DroneDieEvent</color>");
        });
 
    }
 
    void Start()
    {
 
        //해처리 생성
        var hatcheryPrefab = Resources.Load<GameObject>("hatchery");
        var hatcheryGo = Instantiate(hatcheryPrefab);
        hatchery = hatcheryGo.GetComponent<Hatchery>();
        hatchery.Init();
 
 
       
    }
 
    void OnGUI()
    {
        if (GUILayout.Button("킬 드론", GUILayout.Width(100), GUILayout.Height(60)))
        {
            var dron = zergUnits[0as Drone;
            dron.Die();
        }
    }
 
    void Update()
    {
        //마우스클릭 했을때 Ray발사 
        if (Input.GetMouseButtonUp(0))
        {
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            Debug.DrawRay(ray.origin, ray.direction * 1000, Color.red, 10);
            //충돌검사 
            //var hit = Physics2D.Raycast(ray.origin, ray.direction, 1000);
            //var arrHit = Physics2D.GetRayIntersectionAll(ray, 100);
            //var hit = Physics2D.GetRayIntersection(ray, 1000);
            var hit = Physics2D.Raycast(ray.origin, ray.direction, 1000);
 
            //foreach (var hit in arrHit)
            //{
            //    Debug.Log(hit.collider.tag);
            //}
            if (hit)
            {
                //충돌 되었다면 
                if (hit.collider.tag == "Larva")
                {
                    Debug.LogFormat("{0}, {1}", hit.collider.tag, hit.collider.gameObject.GetHashCode());
                    this.cocoon = hatchery.GetCocoon(hit.collider.gameObject.GetHashCode());
                    Debug.LogFormat("cocoon: {0}"this.cocoon);
                }
            }
        }
 
 
        if (Input.GetKeyUp(KeyCode.D))
        {
            if (this.cocoon != null)
            {
                var dron = this.cocoon.CreateUnit(GameEnums.eZergUnitType.DRONE);
                dron.Move(new Vector3(1,1,1));
            }
        }
    }
}
 
cs



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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Hatchery : MonoBehaviour
{
    private Vector3[] cocoonsInitPosList = {
        new Vector3(-2.63f, -2.34f, 0),
        new Vector3(-0.14f, -2.77f, 0),
        new Vector3(2.18f, -2.02f, 0),
    };
 
    void Awake()
    {
        //인스턴스화 직후 호출됨 
    }
 
    void Start()
    {
        //인스터스화 직후 업데이트 전 
    }
 
    void OnEnable()
    {
        //오브젝트 활성화 직후 
    }
 
    //해처리 초기화 메서드 
    public void Init()
    {
        EventDispatcher.GetInstance().AddEventListener("DroneDieEvent", EventDispatcher.GetInstance().TestEventHandler, (sender, e) =>
        {
            Debug.Log("<color=red>Hatchery: DroneDieEvent</color>");
        });
 
        EventDispatcher.GetInstance().AddEventListener("CreateDroneEvent", EventDispatcher.GetInstance().TestEventHandler, (sender, e) =>
        {
            Debug.Log("<color=red>2</color>");
            var cocoonEventArgs = e as Cocoon.CocoonEventArgs;
            if (this.dicCocoon.ContainsKey(cocoonEventArgs.hashCode))
            {
                this.dicCocoon.Remove(cocoonEventArgs.hashCode);
                Debug.LogFormat("라바 수: {0}"this.dicCocoon.Count);
            }
        });
 
 
        //라바를 생성 
        for (int i = 0; i < 3; i++)
        {
            var cocoon = new Cocoon();
            cocoon.model.transform.position = this.cocoonsInitPosList[i];
            Debug.LogFormat("{0}, {1}", cocoon.model.GetHashCode(), cocoon);
            this.dicCocoon.Add(cocoon.model.GetHashCode(), cocoon);
        }
 
        var creepPrefab = Resources.Load<GameObject>("creep");
        var creepGo = GameObject.Instantiate(creepPrefab);
        Debug.Log("creep이 생성되었습니다.");
 
        
    }
 
    private Dictionary<int, Cocoon> dicCocoon = new Dictionary<int, Cocoon>();
 
    public Cocoon GetCocoon(int hashCode)
    {
        return this.dicCocoon[hashCode];
    }
}
 
cs




1
2
3
4
5
6
7
8
9
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public interface IZerg
{
    void Move(Vector3 pos);
}
 
cs



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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
 
//프록시 클래스 
public class Cocoon : IZerg
{
    public class CocoonEventArgs:EventArgs
    {
        public int hashCode;
        public IZerg drone;
        public CocoonEventArgs(int hashCode, IZerg drone)
        {
            this.hashCode = hashCode;
            this.drone = drone;
        }
    }
 
    
 
    public GameObject model;
    
 
 
    public Cocoon()
    {
        //생성자 
        Debug.Log("Cocoon이 생성되었습니다.");
        var larvaPrefab = Resources.Load<GameObject>("larva");
        this.model = GameObject.Instantiate(larvaPrefab);
    }
 
    //override IZerg method
    public void Move(Vector3 pos)
    {
        throw new System.NotImplementedException();
    }
 
    public IZerg CreateUnit(GameEnums.eZergUnitType unitType)
    {
        IZerg unit = null;
 
        switch (unitType)
        {
            case GameEnums.eZergUnitType.DRONE:
            {
                unit = new Drone(this.model.transform.position);
 
                this.OnCreateDroneEvent(new CocoonEventArgs(this.model.GetHashCode(), unit));
 
                GameObject.Destroy(this.model);
 
                
            }
            break;
        }
 
        return unit;
    }
 
    private void OnCreateDroneEvent(CocoonEventArgs args)
    {
        EventDispatcher.GetInstance().DispatchEvent("CreateDroneEvent", args);
    }
 
}
 
cs





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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Drone : IZerg
{
    public GameObject model;
 
    public Drone(Vector3 initPos)
    {
        //생성자 
        var prefab = Resources.Load<GameObject>("drone");
        this.model = GameObject.Instantiate(prefab);
        this.model.transform.position = initPos;
    }
 
    public void Move(Vector3 pos)
    {
        Debug.LogFormat("{0}로 이동했습니다.", pos);
    }
 
    public void Die()
    {
        EventDispatcher.GetInstance().DispatchEvent("DroneDieEvent", EventArgs.Empty);
    }
}
 
cs



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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.CompilerServices;
using UnityEngine;
using static Cocoon;
 
public class EventDispatcher
{
    private static EventDispatcher Instance;
    public EventHandler<EventArgs> TestEventHandler;
 
    public EventDispatcher()
    {
        if (EventDispatcher.Instance != null)
        {
            throw new Exception("싱글톤 클래스입니다.");
        }
    }
 
    public static EventDispatcher GetInstance()
    {
        if(EventDispatcher.Instance == null)
            EventDispatcher.Instance = new EventDispatcher();
 
        return EventDispatcher.Instance;
    }
 
    public Dictionary<string, EventHandler<EventArgs>> dicEventHandler = new Dictionary<string, EventHandler<EventArgs>>();
 
    //이벤트 핸들러 등록 
    public void AddEventListener(string eventName, EventHandler<EventArgs> handler, EventHandler<EventArgs> executeHandler) 
    {
        if (!dicEventHandler.ContainsKey(eventName))
        {
            dicEventHandler.Add(eventName, handler);
            dicEventHandler[eventName] = handler;
            Debug.LogFormat("이벤트 핸들러 등록", handler);
        }
 
        dicEventHandler[eventName] += executeHandler;
    }
 
    //이벤트 발송 
    public void DispatchEvent(string eventName, EventArgs e)
    {
        var handler = dicEventHandler[eventName];
        handler.Invoke(EventDispatcher.GetInstance(), e);
    }
}
 
cs




반응형

'Design Patterns ' 카테고리의 다른 글

State Pattern  (0) 2021.10.18
[Design Pattern] abstract factory pattern  (0) 2020.11.09
Decorator Pattern 실전  (0) 2011.10.10
Decorator Pattern 워밍업  (0) 2011.10.10
Observer Pattern in Java Convert to AS3  (0) 2011.10.09
:

팀 프로젝트 서비스

카테고리 없음 2019. 2. 25. 16:06
반응형

인천 더조은 아카데미 

게임 프로그래밍 개발자 양성과정 1기 

학생들과 115일간 함께 만들어 서비스한 4개의 팀프로젝트 

2019년 02월 25일 서비스 하다.


팀 : 노란콩 (YellowBean)

프로젝트 : BeansWars (빈즈워즈)

https://play.google.com/store/apps/details?id=com.YellowBean.BeansWars




팀 : 레몬큐브 

프로젝트 : Spin Road (스핀로드)

https://play.google.com/store/apps/details?id=com.lemoncube.spinroad




팀 : 제너레이터

프로젝트 : TastyCastle 

https://play.google.com/store/apps/details?id=com.Generator.AppCsm





팀: 개구리밥 (FrogFood)

프로젝트 : DearTear

https://play.google.com/store/apps/details?id=com.FF.DT








반응형
: