Lecture 5: Finish the Game &

Deploying to iOS and Android

for Google Cardboard
Dr. Kobkrit Viriyayudhakorn

iApp Technology Limited

kobkrit@iapp.co.th
ITS488 (Digital Content Creation with Unity - Game and VR Programming)
Show Score on GameOver Scene
• When you change the
scene. All useful game
objects are gone.

• Make ScoreCount
survive the next scene.

• Add
DontDestroyOnLoad(g
ameObject); in the
Start Method.
ScoreCount Keep Creatings 

When User Press "Play Again?"
Solve by ScoreAbsorber
• Create a new ScoreAbsorber GameObject in Scene #3 (Gameover scene)

• Create a new C# Script ScoreAbsorber.cs

• Drag the ScoreAbsorber.cs to associated with GameObject

• Write down the following code.
ScoreAbsorber.cs
Exercise 1: Display Score on GameOver
• Create a new GameOverScoreDisplay C# file.

• Create a new Text item.

• Associate between GameOverScoreDisplay and Text.

• Find the ScoreAbsorber and update the text.
Importing the Asset Model
1. Download Asset Model

at https://www.dropbox.com/s/
q9xup1axi5m8lm8/Asset-Pack.zip?
dl=0We gonna import the asset model from Joongly.

http://joongly.com/index.php?route=product/product&product_id=62
Importing Package
2. Assets > Import Package > Custom Package...

Choose "ShootHoopKit.unitypackage"
3. Make sure that select everything

and then select "Import"
4. Now you get Assets of the "ShootHoopKit"
Add Ringboard into the Scene
1. Drag and Drop "RingBoard" 2. Make it position correctly by using

"Move", "Rotate", "Scale"
Exercise 2: Build Level from Assets.
• Duplicate the RingBoard Prefab for another 2 board

• Position them correctly around your scene.

• Remove the unnecessary block.

• Replace the ball that gets shot.
1. Duplicate the RingBoard Prefab for another 2 board.

Position them correctly around your scene.

And play.
2. Drag and drop the Ball prefab to "Ball Launcher"
And "Play"



**Adjust Ball Speed to make it playable**
Adding the Trigger
1. Remove all unused Target blocks

Select Them > Delete
2. Right click at the Ringboard and create empty.
1. Rename it as "Trigger", Move it at the hole of the Backboard, and Add Box Collider
2. Check "IsTrigger" 3. Add the new C# file

"GoalTrigger"
4. Drag and drop

code to
the Trigger.
Have the following code...
Exercise 3
• Play button, to test the game.

• Duplicate it to multiple backboard

• Make the score to increase become public and adjustable in Unity.
Google Cardboard

Deployment
We need the newest version of Unity
• Install the newest setup of the following files

• Unity-2017.2.0f3.pkg

• UnitySetup-iOS-Support-for-Editor-2017.2.0f3.pkg

• UnitySetup-Android-Support-for-Editor-2017.2.0f3.pkg

• Android-Studio-IDE-171.4408382-mac.dmg

• Xcode 9.1
Download the Previous Lecture Code
http://github.com/kobkrit/VR_basketball
Build Unity for iOS
• Install Unity iOS Build Support

• Reopen the Unity & Switch Platform

• Xcode

• Use the following Apple Developer ID

• Username: kobkrit@gmail.com

• Password: SIITsiit1
Install iOS Build Support
1. Open File > Build Settings > iOS >

Click on "Open Download Page"
2. It will download the package.
3. Follow the install instruction. After completed,
Restart the unity again.
4. Select iOS > Tap Switch Platform
5. It will take a while
6. Press Build and Run,

It will prompt you for enter the iOS project directory.

You can select any folder.
7. If you encounter the API update Required

Press "I Made a Backup. Go Ahead!"
8. This will take a while... 9. When it is finished, the Xcode will show up.

Go to tab "General" > Select "Unity-iPhone".
In Signing and Team Selection Box, Click at "None"

and then "Add an Account..."
10. Write down your apple id’s username and password

• Use the following Apple Developer ID

• Username: kobkrit@gmail.com

• Password: SIITsiit1
11. You will see the above error, make change on the 

Bundle identifier to "com.kobkrit.{your-student-id}

Example: com.kobkrit.4722791763

and then press "Tab" 



You will see as below.
12. Redo it again for "Unity-iPhone Tests Target"

Select a Team
13. Plug-in your iPhone to machine.

Select it as the target.

And press "Play" button
Enabling VR
1. Open File > Build Settings > iOS >

Click on "Player Setting"
2. At the XR Settings, Check at the Virtual Reality Supported

Then press +, Choose "Cardboard"
3. Press "Build And Run" again.
4. Re-assign Developer Team in Xcode,

and Re-enter App Identifier.

Hit "Play" Button.
Build Unity for Android
• Install Unity Android Build Support

• Install Android Studio

• Download & Install Android SDK

• Enable USB Debugging on Android Device

• Connect Android Device to the SDK

• Config Android SDK Path in Unity
Install Android Studio
To install Android Studio on your
Mac, proceed as follows:
1.Launch the Android Studio
DMG file.
2.Drag and drop Android Studio
into the Applications folder,
then launch Android Studio.
3.Select whether you want to
import previous Android
Studio settings, then
click OK.
4.The Android Studio Setup
Wizard guides you though the
rest of the setup, which
includes downloading
Android SDK components
that are required for
development.
That's it! The following video
shows each step of the
recommended setup procedure.
Enable Android USB Debugger
Settings > About Phone > Build number > Tap it 7 times to become developer
Enable Android USB Debugger #2
Settings > Developer Options > USB Debugging
Install Unity Android Build Support
1. Open File > Build Settings > Android

Click on "Open Download Page"
2. It will download the package.
3. Follow the install instruction. After completed,
Restart the unity again.
4. Plug in the Android phone to machine via USB cable.

Press "Player Settings..."
5. Look at the right, At the Other Settings > Identification,

Make change the Package Name to

com.Kobkrit.BasketBall



Change Target API Level to Android 7.1

Minimum API Level to Android 6.0

6. Select Android 

Change Build System -> Gradle (New)
Enable Development Build

Press Build And Run
7. Save the Android Project to any location you like.
8. It will take a while..
Unity Google VR Cardboard Deployment on iOS and Android

Unity Google VR Cardboard Deployment on iOS and Android

  • 1.
    Lecture 5: Finishthe Game &
 Deploying to iOS and Android
 for Google Cardboard Dr. Kobkrit Viriyayudhakorn iApp Technology Limited kobkrit@iapp.co.th ITS488 (Digital Content Creation with Unity - Game and VR Programming)
  • 2.
    Show Score onGameOver Scene • When you change the scene. All useful game objects are gone. • Make ScoreCount survive the next scene. • Add DontDestroyOnLoad(g ameObject); in the Start Method.
  • 3.
    ScoreCount Keep Creatings
 When User Press "Play Again?"
  • 4.
    Solve by ScoreAbsorber •Create a new ScoreAbsorber GameObject in Scene #3 (Gameover scene) • Create a new C# Script ScoreAbsorber.cs • Drag the ScoreAbsorber.cs to associated with GameObject • Write down the following code.
  • 5.
  • 6.
    Exercise 1: DisplayScore on GameOver • Create a new GameOverScoreDisplay C# file. • Create a new Text item. • Associate between GameOverScoreDisplay and Text. • Find the ScoreAbsorber and update the text.
  • 8.
    Importing the AssetModel 1. Download Asset Model
 at https://www.dropbox.com/s/ q9xup1axi5m8lm8/Asset-Pack.zip? dl=0We gonna import the asset model from Joongly.
 http://joongly.com/index.php?route=product/product&product_id=62
  • 9.
    Importing Package 2. Assets> Import Package > Custom Package...
 Choose "ShootHoopKit.unitypackage" 3. Make sure that select everything
 and then select "Import" 4. Now you get Assets of the "ShootHoopKit"
  • 10.
    Add Ringboard intothe Scene 1. Drag and Drop "RingBoard" 2. Make it position correctly by using
 "Move", "Rotate", "Scale"
  • 11.
    Exercise 2: BuildLevel from Assets. • Duplicate the RingBoard Prefab for another 2 board • Position them correctly around your scene. • Remove the unnecessary block. • Replace the ball that gets shot.
  • 12.
    1. Duplicate theRingBoard Prefab for another 2 board.
 Position them correctly around your scene.
 And play. 2. Drag and drop the Ball prefab to "Ball Launcher" And "Play"
 
 **Adjust Ball Speed to make it playable**
  • 13.
    Adding the Trigger 1.Remove all unused Target blocks
 Select Them > Delete 2. Right click at the Ringboard and create empty.
  • 14.
    1. Rename itas "Trigger", Move it at the hole of the Backboard, and Add Box Collider 2. Check "IsTrigger" 3. Add the new C# file
 "GoalTrigger" 4. Drag and drop
 code to the Trigger.
  • 15.
  • 16.
    Exercise 3 • Playbutton, to test the game. • Duplicate it to multiple backboard • Make the score to increase become public and adjustable in Unity.
  • 17.
  • 18.
    We need thenewest version of Unity • Install the newest setup of the following files • Unity-2017.2.0f3.pkg • UnitySetup-iOS-Support-for-Editor-2017.2.0f3.pkg • UnitySetup-Android-Support-for-Editor-2017.2.0f3.pkg • Android-Studio-IDE-171.4408382-mac.dmg • Xcode 9.1
  • 19.
    Download the PreviousLecture Code http://github.com/kobkrit/VR_basketball
  • 20.
    Build Unity foriOS • Install Unity iOS Build Support • Reopen the Unity & Switch Platform • Xcode • Use the following Apple Developer ID • Username: kobkrit@gmail.com • Password: SIITsiit1
  • 21.
    Install iOS BuildSupport 1. Open File > Build Settings > iOS >
 Click on "Open Download Page" 2. It will download the package. 3. Follow the install instruction. After completed, Restart the unity again.
  • 22.
    4. Select iOS> Tap Switch Platform 5. It will take a while 6. Press Build and Run,
 It will prompt you for enter the iOS project directory.
 You can select any folder.
  • 23.
    7. If youencounter the API update Required
 Press "I Made a Backup. Go Ahead!" 8. This will take a while... 9. When it is finished, the Xcode will show up.
 Go to tab "General" > Select "Unity-iPhone". In Signing and Team Selection Box, Click at "None"
 and then "Add an Account..."
  • 24.
    10. Write downyour apple id’s username and password
 • Use the following Apple Developer ID • Username: kobkrit@gmail.com • Password: SIITsiit1 11. You will see the above error, make change on the 
 Bundle identifier to "com.kobkrit.{your-student-id}
 Example: com.kobkrit.4722791763
 and then press "Tab" 
 
 You will see as below.
  • 25.
    12. Redo itagain for "Unity-iPhone Tests Target"
 Select a Team 13. Plug-in your iPhone to machine.
 Select it as the target.
 And press "Play" button
  • 26.
    Enabling VR 1. OpenFile > Build Settings > iOS >
 Click on "Player Setting" 2. At the XR Settings, Check at the Virtual Reality Supported
 Then press +, Choose "Cardboard"
  • 27.
    3. Press "BuildAnd Run" again. 4. Re-assign Developer Team in Xcode,
 and Re-enter App Identifier.
 Hit "Play" Button.
  • 28.
    Build Unity forAndroid • Install Unity Android Build Support • Install Android Studio • Download & Install Android SDK • Enable USB Debugging on Android Device • Connect Android Device to the SDK • Config Android SDK Path in Unity
  • 29.
    Install Android Studio Toinstall Android Studio on your Mac, proceed as follows: 1.Launch the Android Studio DMG file. 2.Drag and drop Android Studio into the Applications folder, then launch Android Studio. 3.Select whether you want to import previous Android Studio settings, then click OK. 4.The Android Studio Setup Wizard guides you though the rest of the setup, which includes downloading Android SDK components that are required for development. That's it! The following video shows each step of the recommended setup procedure.
  • 30.
    Enable Android USBDebugger Settings > About Phone > Build number > Tap it 7 times to become developer
  • 31.
    Enable Android USBDebugger #2 Settings > Developer Options > USB Debugging
  • 32.
    Install Unity AndroidBuild Support 1. Open File > Build Settings > Android
 Click on "Open Download Page" 2. It will download the package. 3. Follow the install instruction. After completed, Restart the unity again.
  • 33.
    4. Plug inthe Android phone to machine via USB cable.
 Press "Player Settings..." 5. Look at the right, At the Other Settings > Identification,
 Make change the Package Name to
 com.Kobkrit.BasketBall
 
 Change Target API Level to Android 7.1
 Minimum API Level to Android 6.0

  • 34.
    6. Select Android
 Change Build System -> Gradle (New) Enable Development Build
 Press Build And Run 7. Save the Android Project to any location you like. 8. It will take a while..