카드보드 SDK 다운로드


https://developers.google.com/vr/unity/get-started-android

 

안드로이드 SDK 설치

https://developer.android.com/studio/index.html


프로젝트 생성후 Import 방법
Assets -> Import Package -> Custom Pakcage 선택
다운받은 카드보드 SDK 내에 있는 GoogleVRForUnity.unitypackage 선택하여 import


프로젝트 빌드 방법
File -> Build Setting 선택
Android 플렛폼 선택후 좌측하단 'Switch Platform' 클릭

좌측 하단 Player Setting 클릭 -> Other Settings 탭에서 패키지 이름 설정 ex) com.example.VRUnityDemo
Minimum API Level은 최소 API19(킷켓) 으로 설정하면 됨(그 이상도 상관없음)
Resolution and Presentation 메뉴에서 Landscape Left 체크 후 Build하면 됨


유니티 공식사이트의 메뉴얼

http://docs.unity3d.com/kr/current/Manual/VRDevices-Oculus.html

 

오큘러스 리프트 프로그램 설치

https://www.oculus.com/en-us/setup/


오큘러스 개발 관련 SDK,패키지






'프로그래밍 > Unity' 카테고리의 다른 글

(유니티)PC - 웹캠 이용하는 심플 코드  (0) 2018.03.21
(Unity) 구글 카드보드 환경구축  (0) 2016.07.09
Mission Demolition Prototype  (0) 2016.07.09
Apple Picker Prototype  (0) 2016.07.09
유니티 VR 관련 책  (0) 2016.07.09

 



Apple Picker Prototype A (2).zip


자바에서는 데이터 은닉을 위한 처리를 setXXX,getXXX라는 이름의 메소드를 이용하여 처리하였지만 C#에선 접근자를 통해 제어할 수 있다. 
get 접근자 : 메서드의 본문과 비슷하며 속성 형식의 값을 반환해야 함. return 또는 throw 문으로 끝나는 형식이여야 함. get 접근자 내에서 값을 제어하는 것은 권장하지 않음.
set 접근자 : 반환 형식이 void인 메서드와 비슷함. 해당 형식이 속성의 형식과 같은 value라는 암시적 매개 변수를 사용.

사용의 예
1
2
3
4
5
6
7
8
9
10
11
12
    private int m_iType;
    public int m_Type
    {
        get
        {
            return m_iType;
        }
        set
        {
            m_iType = value;
        }
    }


http://book.naver.com/bookdb/book_detail.nhn?bid=10628161


 


DinnerParty.zip



Form1.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
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace DinnerParty
{
    public partial class Form1 : Form
    {
        DinnerParty dinnerParty;
        public Form1()
        {
            InitializeComponent();
            dinnerParty = new DinnerParty((int)numericUpDown1.Value,checkBox1.Checked,
checkBox2.Checked);
 
            DisplayDinnerPartyCost();
        }
 
        private void DisplayDinnerPartyCost()
        {
            decimal Cost = dinnerParty.Cost;
            label3.Text = Cost.ToString("c");
        }
 
        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            dinnerParty.NumberOfPeople = (int)numericUpDown1.Value;
            DisplayDinnerPartyCost();
        }
 
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            dinnerParty.FancyDecorations = checkBox1.Checked;
            DisplayDinnerPartyCost();
        }
 
        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            dinnerParty.HealthyOption = checkBox2.Checked;
            DisplayDinnerPartyCost();
        }
    }
}
 
cs


DinnerParty.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
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace DinnerParty
{
    
    class DinnerParty
    {
        public int NumberOfPeople { get; set; }
        public bool FancyDecorations { get; set; }
        public bool HealthyOption { get; set; }
 
        public decimal CostOfDecorations = 0;
        public const int CostOfFoodPerPerson = 25;
        public DinnerParty(int number,bool healthy,bool fancyDeco)
        {
            NumberOfPeople = number;
            FancyDecorations = fancyDeco;
            HealthyOption = healthy;
        }
        public decimal setHealthyOption()
        {
            decimal costOfbeverage;
            if (HealthyOption)
            {
                costOfbeverage = 5.00M;
            }
            else
            {
                costOfbeverage = 20.00M;
            }
            return costOfbeverage;
        }
 
        private decimal CalculateCostOfDecorations()
        {
            decimal costOfDeco;
            if (FancyDecorations)
            {
                costOfDeco = (NumberOfPeople * 15.00M) + 50M;
            }
            else
            {
                costOfDeco = (NumberOfPeople * 7.50M) + 30M;
            }
            return costOfDeco;
        }
 
        public decimal Cost
        {
            get{
                decimal total = CalculateCostOfDecorations();
                total += ((setHealthyOption() + CostOfFoodPerPerson) * NumberOfPeople);
                if(HealthyOption)
                {
                    total *= .95M;
                }
                return total;
            }
 
        }
    }
}


'프로그래밍 > C#' 카테고리의 다른 글

c#기반의 네트워크 통신 예제 소스 모음  (0) 2019.08.03
(C#) get, set 접근자  (0) 2016.07.09
(C#) Head First - 캡슐화  (0) 2016.07.09
(C#) head first - MessageBox 사용  (0) 2016.07.09
(C#) Head First - 경마  (0) 2016.07.09
 

Form1.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
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace Cow_calculator
{
    public partial class Form1 : Form
    {
        Farmer farmer;
        public Form1()
        {
            InitializeComponent();
            farmer = new Farmer(15,30);
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            Console.WriteLine("I need " + farmer.BagsOfFeed + " bags of feed for "
 + farmer.NumberOfCows + " cows");
        }
 
        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            farmer.NumberOfCows = (int)numericUpDown1.Value;
        }
    }
}
 
cs

Farmer.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
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Cow_calculator
{
    class Farmer
    {
        public int BagsOfFeed { get; private set; }
        private int feedMultiplier;
        public int FeedMultiplier { get { return feedMultiplier; } }
 
        private int numberOfCows;
        public int NumberOfCows
        {
            get
            {
                return numberOfCows;
            }
            set
            {
                numberOfCows = value;
                BagsOfFeed = numberOfCows * FeedMultiplier;
            }
        }
 
        public Farmer(int number,int mult)
        {
            feedMultiplier = mult;
            NumberOfCows = number;
        }
    }
}


'프로그래밍 > C#' 카테고리의 다른 글

(C#) get, set 접근자  (0) 2016.07.09
(C#) Head First - 캡슐화 PartyPlaner  (0) 2016.07.09
(C#) head first - MessageBox 사용  (0) 2016.07.09
(C#) Head First - 경마  (0) 2016.07.09
(C#) WPF로 만든 심플 게임  (1) 2016.07.09


WindowsFormsApplication1.zip



Form1.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.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            int len = Talker.BlahBlahBlah(textBox1.Text, (int)numericUpDown1.Value);
            MessageBox.Show("The message length is " + len);
        }
    }
}
 
cs


Talker.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
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    class Talker
    {
        public static int BlahBlahBlah(string thingToSay, int numberOfTimes)
        {
            string finalString = "";
            for (int count = 0; count < numberOfTimes; count++)
            {
                finalString += thingToSay + "\n";
            }
            MessageBox.Show(finalString);
            return finalString.Length;
        }
    }
}
 


'프로그래밍 > C#' 카테고리의 다른 글

(C#) Head First - 캡슐화 PartyPlaner  (0) 2016.07.09
(C#) Head First - 캡슐화  (0) 2016.07.09
(C#) Head First - 경마  (0) 2016.07.09
(C#) WPF로 만든 심플 게임  (1) 2016.07.09
(C#) 엑세스 수식자, 예외처리  (0) 2016.07.09

 

Head First - 경마를 변형한 프로그램



Bet.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace SnailRaceSimulator
{
    public class Bet
    {
        public int m_iAmount, m_iSnail;
        public Guy Bettor;
 
        public Bet(int _amount, int _Snail, Guy _bettor)
        {
            m_iAmount = _amount;
            m_iSnail = _Snail;
            Bettor = _bettor;
        }
 
        public string GetDescription()
        {
            string description = "";
 
            if (m_iAmount > 0)
            {
                description = String.Format(Bettor.m_strName + " bets " + m_iAmount + " on Snail #" + m_iSnail);
            }
            else
            {
                description = String.Format(Bettor.m_strName + " hasn't placed any bets");
            }
            return description;
        }
 
        public int PayOut(int Winner)
        {
            if (m_iSnail == Winner)
            {
                return m_iAmount;
            }
            return -m_iAmount;
        }
    }
}
 
 
cs


Guy.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
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace SnailRaceSimulator
{
    public class Guy
    {
        public string m_strName;
        public Bet bet;
        public int m_iCash;
 
        public RadioButton MyRadioButton;
        public Label MyLabel;
 
        public Guy(string _Name, Bet _Bet, int _Cash, RadioButton _RadioButton, Label _Label)
        {
            m_strName = _Name;
            bet = _Bet;
            m_iCash = _Cash;
            MyRadioButton = _RadioButton;
            MyLabel = _Label;
        }
 
        public void UpdateLabels()
        {
            if (bet == null)
            {
                MyLabel.Text = String.Format(m_strName + " hasn't placed any bets");
            }
            else
            {
                MyLabel.Text = bet.GetDescription();
            }
            MyRadioButton.Text = m_strName + " has " + m_iCash + " bucks";
        }
 
        public void ClearBet()
        {
            bet.m_iAmount = 0;
        }
 
        public bool PlaceBet(int Amount, int Snail)
        {
            if (Amount <= m_iCash)
            {
                bet = new Bet(Amount, Snail, this);
                return true;
            }
            else
            {
                MessageBox.Show(m_strName + "은 돈이 모자릅니다.");
            }
            return false;
        }
 
        public void Collect(int iWinner)
        {
            m_iCash += bet.PayOut(iWinner);
        }
    }
}
 
cs


Snail.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
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
 
namespace SnailRaceSimulator
{
    public class Snail
    {
        public int m_iStartingPosition, m_iRacetrackLength, m_iLocation = 0;
        public PictureBox MyPictureBox = null;
 
        public bool Run(int _iDistance)
        {
            MoveMyPictureBox(_iDistance);
            m_iLocation += _iDistance;
            if (m_iLocation >= (m_iRacetrackLength - m_iStartingPosition))
            {
                return true;
            }
            return false;
        }
 
        public void TakeStartingPosition()
        {
            MoveMyPictureBox(-m_iLocation);
            m_iLocation = 0;
        }
 
        public void MoveMyPictureBox(int distance)
        {
            Point p = MyPictureBox.Location;
            p.X += distance;
            MyPictureBox.Location = p;
        }
    }
}
 
cs


Form1.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace SnailRaceSimulator
{
    public partial class Form1 : Form
    {
        Snail[] dogs = new Snail[4];
        Guy[] guys = new Guy[3];
        int m_iWinningSnail;
        Random random = new Random();
 
        public Form1()
        {
            InitializeComponent();
            SetupRaceTrack();
        }
 
        private void SetupRaceTrack()
        {
            MinimumBet.Text = string.Format("Minimum bet " + BetAmount.Minimum);
 
            int startingPosition = Snail1.Right - racetrack.Left;
            int raceTrackLength = racetrack.Size.Width;
 
            dogs[0= new Snail() { MyPictureBox = Snail1, m_iRacetrackLength = raceTrackLength, m_iStartingPosition = startingPosition };
            dogs[1= new Snail() { MyPictureBox = Snail2, m_iRacetrackLength = raceTrackLength, m_iStartingPosition = startingPosition };
            dogs[2= new Snail() { MyPictureBox = Snail3, m_iRacetrackLength = raceTrackLength, m_iStartingPosition = startingPosition };
            dogs[3= new Snail() { MyPictureBox = Snail4, m_iRacetrackLength = raceTrackLength, m_iStartingPosition = startingPosition };
 
            guys[0= new Guy("Joe"null50, joeButton, joeBet);
            guys[1= new Guy("Bob"null75, bobButton, bobBet);
            guys[2= new Guy("Al"null45, alButton, alBet);
 
            for (int i = 0; i < guys.Length; i++)
                guys[i].UpdateLabels();
        }
 
        private void joeButton_CheckedChanged(object sender, EventArgs e)
        {
            SetBettorNameTextLabel("Joe");
        }
 
        private void bobButton_CheckedChanged(object sender, EventArgs e)
        {
            SetBettorNameTextLabel("Bob");
        }
 
        private void alButton_CheckedChanged(object sender, EventArgs e)
        {
            SetBettorNameTextLabel("Al");
        }
 
        private void SetBettorNameTextLabel(string strName)
        {
            BettorName.Text = strName;
        }
 
        private void Bets_Click(object sender, EventArgs e)
        {
            int GuyNumber = 0;
 
            if (joeButton.Checked)
            {
                GuyNumber = 0;
            }
            else if (bobButton.Checked)
            {
                GuyNumber = 1;
            }
            else if (alButton.Checked)
            {
                GuyNumber = 2;
            }
 
            guys[GuyNumber].PlaceBet((int)BetAmount.Value, (int)SnailNumber.Value);
            guys[GuyNumber].UpdateLabels();
        }
 
        private void race_Click(object sender, EventArgs e)
        {
            m_iWinningSnail = 0;
            race.Enabled = false;
            Bets.Enabled = false;
            timer1.Start();
 
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            SetBettorNameTextLabel("Joe");
        }
 
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            for (int i = 0; i < dogs.Length; i++)
            {
                int iTemp = random.Next(-13);
                if (iTemp + dogs[i].m_iLocation < 0)
                    iTemp = random.Next(02);
                if (dogs[i].Run(iTemp))
                {
                    timer1.Stop();
                    m_iWinningSnail = i + 1;
                    MessageBox.Show("Snail " + m_iWinningSnail + "# won the race!");
                    for (int j = 0; j < guys.Length; j++)
                    {
                        if (guys[j].bet != null)
                        {
                            guys[j].Collect(m_iWinningSnail);
                            guys[j].bet = null;
                            guys[j].UpdateLabels();
                        }
                    }
                    for (int j = 0; j < dogs.Length; j++)
                        dogs[j].TakeStartingPosition();
 
                    race.Enabled = true;
                    Bets.Enabled = true;
                    break;
                }
 
            }
        }
 
        private void Form1_Load_1(object sender, EventArgs e)
        {
            SetBettorNameTextLabel("Joe");
        }
    }
}
 
cs





'프로그래밍 > C#' 카테고리의 다른 글

(C#) Head First - 캡슐화 PartyPlaner  (0) 2016.07.09
(C#) Head First - 캡슐화  (0) 2016.07.09
(C#) head first - MessageBox 사용  (0) 2016.07.09
(C#) WPF로 만든 심플 게임  (1) 2016.07.09
(C#) 엑세스 수식자, 예외처리  (0) 2016.07.09

+ Recent posts