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

  1. 2019.12.18 2019_12_18 UI:(2)
  2. 2019.12.18 2019_12_18 UI
  3. 2019.11.13 2019-11-13 Unity 버튼을 눌러 캐릭터 생성/메서드
  4. 2019.11.07 2019-11-07 Unity
  5. 2019.10.24 메서드 연습^^ 14
  6. 2019.10.15 1546 평균
  7. 2019.10.15 2577 숫자의 개수
  8. 2019.10.14 UI Panel 이미지
  9. 2019.09.30 2739 구구단
  10. 2019.09.28 10817 세수

2019_12_18 UI:(2)

Unity/실습 2019. 12. 18. 18:57
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
 
public class TestApp : MonoBehaviour
 
{
    public Button btn1;
    public Button btn2;
    public Image image;
    public TestUISelectedInfo testinfo;
    public Inventory inventory;
    void Start()
    {
        var path=Resources.Load<TextAsset>("Text/Item_data");
        var json=JsonConvert.DeserializeObject<ItemInfo[]>(path.text);
        Dictionary<int,ItemInfo> dicInfoData = new Dictionary<int,ItemInfo>();
        foreach(var data in json)
        {
            dicInfoData.Add(data.id, data);
        }
 
 
        btn1.onClick.AddListener(() => {
            image.gameObject.SetActive(true);
            UserInfo info = new UserInfo("리룡린"35100);
            this.testinfo.InIt(info);
        });
        btn2.onClick.AddListener(() =>
        {
            image.gameObject.SetActive(false);
            
        });
 
    }
 
}
 
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
 
public class TestUISelectedInfo : MonoBehaviour
{
    // Start is called before the first frame update
    public Text text1;
    public Text text2;
    public Text text3;
    public Text text4;
    void Start()
    {
        
    }
    public void InIt(UserInfo info)
    {
        text1.text = info.username;
    }
}
 
 
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
 
public class UserInfo
{
    public string username;
    public int level;
    public int attack;
    public int hp;
 
    public UserInfo(string name,int level,int attack,int hp)
    {
        this.username = name;
        this.level = level;
        this.attack = attack;
        this.hp = hp;
    }
    void Start()
    {
        
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 

'Unity > 실습' 카테고리의 다른 글

2019_12_18 UI  (0) 2019.12.18
2019-11-13 Unity 버튼을 눌러 캐릭터 생성/메서드  (0) 2019.11.13
2019-11-07 Unity  (0) 2019.11.07

2019_12_18 UI

Unity/실습 2019. 12. 18. 18:51

ItemInfo.cs
0.00MB
UIPopUp.cs
0.00MB
App.cs
0.00MB

 

DataBase.cs
0.00MB

 

item_data.json
0.00MB
Inventory.cs
0.00MB
SampleScene.unity
0.31MB

'Unity > 실습' 카테고리의 다른 글

2019_12_18 UI:(2)  (0) 2019.12.18
2019-11-13 Unity 버튼을 눌러 캐릭터 생성/메서드  (0) 2019.11.13
2019-11-07 Unity  (0) 2019.11.07

2019-11-13 Unity 버튼을 눌러 캐릭터 생성/메서드

Unity/실습 2019. 11. 13. 14:47
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum eCharacterName
{
    none,
    ch_01_01,
    ch_02_01
}
public class App : MonoBehaviour
{
    public eCharacterName eCharacter;
 
    public Button btn;
    private Dictionary<string, GameObject> dicLoadedPrefab;
    void Awake()
    {
        this.dicLoadedPrefab = new Dictionary<string, GameObject>();
        
    }
 
    void Start()
    {
        this.InIt();
        Debug.Log("인잇 호출");
        btn.onClick.AddListener(() =>
        {
            Debug.Log("Create Hero");
            this.CreateCharacter();
        });
 
    }
    public void InIt()
    {
        var prefab1 = Resources.Load<GameObject>("Prefabs/ch_01_01");
        var prefab2 = Resources.Load<GameObject>("Prefabs/ch_02_01");
        this.dicLoadedPrefab.Add("ch_01_01",prefab1);
        this.dicLoadedPrefab.Add("ch_02_01",prefab2);
    }
    public void CreateCharacter()
    {
        if (eCharacter == eCharacterName.none)
        {
            Debug.Log("이름을 설정해주세여");
            return;
        }
        var prefab = this.dicLoadedPrefab[this.eCharacter.ToString()];
        var model = Instantiate<GameObject>(prefab);
        GameObject heroGo = new GameObject("Hero");
        var hero = heroGo.AddComponent<Hero>();
        hero.SetModel(model);
    }
   
 
 
    // Update is called once per frame
    void Update()
    {
        
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Hero : MonoBehaviour
{
    // Start is called before the first frame update
    public GameObject model;
    void Start()
    {
        
    }
    public void SetModel(GameObject model)
    {
        if (this.model != null)
        {
            Object.Destroy(this.model);
        }
 
        this.model = model;
        this.model.transform.SetParent(this.transform, false);
        this.model.transform.localPosition = Vector3.zero;
    }
 
    // Update is called once per frame
    void Update()
    {
        
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

'Unity > 실습' 카테고리의 다른 글

2019_12_18 UI:(2)  (0) 2019.12.18
2019_12_18 UI  (0) 2019.12.18
2019-11-07 Unity  (0) 2019.11.07

2019-11-07 Unity

Unity/실습 2019. 11. 7. 17:51

  1. using System.Collections;

  2. using System.Collections.Generic;

  3. using Newtonsoft.Json;

  4. using UnityEngine;

  5.  

  6. public class App : MonoBehaviour

  7. {

  8.     private Hero hero;

  9.     // Start is called before the first frame update

  10.     void Start()

  11.     {

  12.         //텍스트 리소스를 로드한다

  13.         TextAsset asset = Resources.Load<TextAsset>("Data/Character_Data");

  14.         //캐릭터데이터를 만들고 테이블과 똑같이 세팅;

  15.         //캐릭터데이터에 리소스를 역직렬화

  16.         CharacterData[] arrCharacterData=JsonConvert.DeserializeObject<CharacterData[]>(asset.text);

  17.         //딕셔너리 key와 밸류(캐릭터데이터)를 생성한다

  18.         Dictionary<int, CharacterData> dicCharacterData = new Dictionary<int, CharacterData>();

  19.         //반복문으로 데이터를 확인한다

  20.         foreach(var data in arrCharacterData)

  21.         {

  22.             Debug.LogFormat("{0} {1} {2} {3} {4}", data.id, data.name, data.prefab_name, data.hp, data.damage);

  23.             //딕셔너리 데이터id,데이터를 생성한다

  24.             dicCharacterData.Add(data.id, data);

  25.         }

  26.         //검색한 아이디를 변수에 담는다.

  27.         var characterData1 = dicCharacterData[1000];

  28.         var characterData2 = dicCharacterData[2000];

  29.         //인포 클래스를 만들고 바뀔수있는 값을 클래스에 저장

  30.         CharacterInfo info = new CharacterInfo(characterData1.id, characterData1.hp, characterData1.damage);

  31.         CharacterInfo info2 = new CharacterInfo(characterData2.id, characterData2.hp, characterData2.damage);

  32.         //모델을 게임오브젝트 타입으로 불러온다.(리소스로드)

  33.         string path = string.Format("Model/{0}", characterData1.prefab_name);

  34.         var model = Resources.Load<GameObject>(path);

  35.  

  36.         string path2 = string.Format("Model/{0}", characterData2.prefab_name);

  37.         var model2 = Resources.Load<GameObject>(path2);

  38.         //모델을 인스턴스화한뒤 변수에 담는다(prefab)

  39.         var prefab = Instantiate(model);

  40.         var prefab2 = Instantiate(model2);

  41.         //게임오브젝트를 생성하고 이름을 정해준다

  42.         GameObject heroGo = new GameObject(characterData1.name);

  43.         GameObject heroGo2 = new GameObject(characterData2.name);

  44.         //프리팹의 부모설정,좌표지정

  45.         prefab.transform.SetParent(heroGo.transform);

  46.         prefab.transform.localPosition = Vector3.zero;

  47.  

  48.         prefab2.transform.SetParent(heroGo2.transform);

  49.         prefab2.transform.localPosition = Vector3.zero;

  50.         //게임오브젝트에 클래스를 컴포넌트해준다

  51.         var hero = heroGo.AddComponent<Hero>();

  52.         var hero2 = heroGo2.AddComponent<Hero>();

  53.         //변수에 모델,정보,좌표를 정해준다.

  54.         hero.InIt(model,info,Vector3.zero);

  55.         hero2.InIt(model2, info2, new Vector3(1, 0, 1));

  56.  

  57.  

  58.     }

  59.  

  60.     // Update is called once per frame

  61.     void Update()

  62.     {

  63.        

  64.     }

  65. }

  1. using System.Collections;

  2. using System.Collections.Generic;

  3. using UnityEngine;

  4.  

  5. public class CharacterData

  6. {

  7.     public int id;

  8.     public string name;

  9.     public string prefab_name;

  10.     public int hp;

  11.     public int damage;

  12. }

  1. using System.Collections;

  2. using System.Collections.Generic;

  3. using UnityEngine;

  4.  

  5. public class CharacterInfo

  6. {

  7.     public int id;

  8.     public int hp;

  9.     public int damage;

  10.     public CharacterInfo(int id,int hp,int damage)

  11.     {

  12.         this.id = id;

  13.         this.hp = hp;

  14.         this.damage = damage;

  15.     }

  16. }

  1. using System.Collections;

  2. using System.Collections.Generic;

  3. using UnityEngine;

  4.  

  5. public class Hero : MonoBehaviour

  6. {

  7.     private GameObject model;

  8.     private CharacterInfo info;

  9.     // Start is called before the first frame update

  10.     void Start()

  11.     {

  12.        

  13.     }

  14.  

  15.     // Update is called once per frame

  16.     void Update()

  17.     {

  18.  

  19.     }

  20.     public void InIt(GameObject model,CharacterInfo info,Vector3 post)

  21.     {

  22.         this.info = info;

  23.         this.model = model;

  24.         this.transform.position = post;

  25.     }

  26. }

'Unity > 실습' 카테고리의 다른 글

2019_12_18 UI:(2)  (0) 2019.12.18
2019_12_18 UI  (0) 2019.12.18
2019-11-13 Unity 버튼을 눌러 캐릭터 생성/메서드  (0) 2019.11.13

메서드 연습^^

Console/과제 2019. 10. 24. 17:00

1546 평균

Console/Algorithm 2019. 10. 15. 21:44
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int[] arr = new int[n];
            var input = Console.ReadLine();
            var arr2 = input.Split(' ');
            int m = 0;
            for (int i = 0; i < arr2.Length; i++)
            {
                arr[i] = int.Parse(arr2[i]);
                if (arr[i] > m)
                {
                    m = arr[i];
                }
            }
            float b = 0;
            for (int j = 0; j < arr2.Length; j++)
            {
               var c = (float)arr[j] /(float) m * 100;
                b = b + c;
            }
            Console.WriteLine(b / (float)n);
        }
 
    }
 
}
 
 
 
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

'Console > Algorithm' 카테고리의 다른 글

2577 숫자의 개수  (0) 2019.10.15
2739 구구단  (0) 2019.09.30
10817 세수  (0) 2019.09.28
2753 윤년  (0) 2019.09.27
1330 두 수 비교하기  (0) 2019.09.27

2577 숫자의 개수

Console/Algorithm 2019. 10. 15. 21:44
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = a * b * c;
            string e = Convert.ToString(d);
            int[] count = new int[10];
            int[] f = new int[e.Length];
            for (int i = 0; i < e.Length; i++)
            {
                f[i] = int.Parse(e[i].ToString());
            }
            for (int j = 0; j < count.Length; j++)
            {
                for (int k = 0; k < e.Length; k++)
                {
                    if (f[k] == j)
                    {
                        count[j]++;
                    }
                }
            }
            for (int l = 0; l < count.Length; l++)
            {
                Console.WriteLine(count[l]);
            }
        }
 
    }
 
}
 
 
 
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

'Console > Algorithm' 카테고리의 다른 글

1546 평균  (0) 2019.10.15
2739 구구단  (0) 2019.09.30
10817 세수  (0) 2019.09.28
2753 윤년  (0) 2019.09.27
1330 두 수 비교하기  (0) 2019.09.27

UI Panel 이미지

Console/실습 2019. 10. 14. 15:23

'Console > 실습' 카테고리의 다른 글

swich 문(9)  (0) 2019.09.26
swich 문(8)  (0) 2019.09.26
swich 문(7)  (0) 2019.09.26
swich 문(6)  (0) 2019.09.26
swich 문(5)  (0) 2019.09.26

2739 구구단

Console/Algorithm 2019. 9. 30. 08:57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                int a = int.Parse(Console.ReadLine());
                for(int b = 1; b < 10; b++)
                {
                    Console.WriteLine($"{ a} * { b} = {a*b}");
                }
            }
        }
    }
        
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

'Console > Algorithm' 카테고리의 다른 글

1546 평균  (0) 2019.10.15
2577 숫자의 개수  (0) 2019.10.15
10817 세수  (0) 2019.09.28
2753 윤년  (0) 2019.09.27
1330 두 수 비교하기  (0) 2019.09.27

10817 세수

Console/Algorithm 2019. 9. 28. 16:35

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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] arr = input.Split(' ');
            int a = int.Parse(arr[0]);
            int b = int.Parse(arr[1]);
            int c = int.Parse(arr[2]);
            if (a > b)
            {
                if (a > c)
                {
                    if (b > c)
                    {
                        Console.WriteLine(b);
                    }
                    else
                    {
                        Console.WriteLine(c);
                    }
                }
                else
                {
                    Console.WriteLine(a);
                }
            }
            else
            {
                if (a > c)
                {
                    Console.WriteLine(a);
                }
                else
                {
                    if(b>c)
                    {
                        Console.WriteLine(c);
                    }
                    else
                    {
                        Console.WriteLine(b);
                    }
                }
            }
        }
 
    }
 
}
 
 
 
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

'Console > Algorithm' 카테고리의 다른 글

2577 숫자의 개수  (0) 2019.10.15
2739 구구단  (0) 2019.09.30
2753 윤년  (0) 2019.09.27
1330 두 수 비교하기  (0) 2019.09.27
9498 시험성적  (0) 2019.09.27