SlideShare a Scribd company logo
PRESENTER
Enrico BARACAGLIA
WORKSHOP #3
Beginners
Introduction to
VR with Unity3D
29 AUGUST 2018
ORGANIZED BY
ESO, Chile
SUPERVISOR
Frédéric VOGT
Overview
1. Create User Interface (UI)
2. Set up VR scene with
SteamVR
3. Handle HTC Vive controller
inputs
4. Guided practical session
a. Transform.Rotate VR
b. Transform.Translate VR
2
Canvas UI
https://docs.unity3d.com/Manual/UICa
nvas.html
Create User
Interface
3
Insert User Interface (UI)
STEPS:
1) UI > Canvas
2) Modify Canvas RectTransform
3) Canvas > Create Panel
4) Canvas > Create 1st Toggle
5) Canvas > Create 2nd Toggle
Create User
Interface
4
Insert User Interface (UI)
STEPS:
1) UI > Canvas
2) Modify Canvas RectTransform
3) Canvas > Create Panel
4) Canvas > Create 1st Toggle
5) Canvas > Create 2nd Toggle
Toggle UI
https://docs.unity3d.com/ScriptRefere
nce/UI.Toggle.html
Create User
Interface
5
5) Create Empty > Add Component > Toggle Group
6) Add : using UnityEngine.UI;
7) Add : if (myToggle.isOn) { //function };
Toggle Group UI
https://docs.unity3d.com/Manual/scrip
t-ToggleGroup.html
Insert User Interface (UI)
Set up VR
scene with
SteamVR
(new scene)
629/08/18 | enricobaracaglia@gmail.com
STEPS:
1) Download and Import SteamVR
2) Import the prefab [CameraRig] and [SteamVR] from
the SteamVR folder
3) Delete the Main Camera from
the Hierarchy because it will
interfere with the [CameraRig]
and its embedded camera.
4) Ready to press play and see
the world in VR!
Note: you need the VR headset for it to
work properly
729/08/18 | enricobaracaglia@gmail.com
Handle HTC
Vive
controller
inputs
Each controller has the following inputs:
829/08/18 | enricobaracaglia@gmail.com
Handle HTC
Vive
controller
inputs
We can access these inputs by following these steps:
// Create a reference to the object being tracked. In this case, a
controller.
private SteamVR_TrackedObject trackedObj;
// Create a Device property to provide easy access to the controller.
It uses the tracked object’s index to return the controller’s input.
private SteamVR_Controller.Device Controller
{
get { return SteamVR_Controller.Input((int)trackedObj.index) ;}
}
1) Create a new C# script called VR_MoveObject
2) Add the following right above the Update()
method:
HTC Vive tutorial for Unity
https://www.raywenderlich.com/792-
htc-vive-tutorial-for-unity
929/08/18 | enricobaracaglia@gmail.com
Handle HTC
Vive
controller
inputs
We can access these inputs by following these steps:
void Awake()
{
trackedObj = GetComponent<SteamVR_TrackedObject>();
}
3) Add the following method right above Update():
1029/08/18 | enricobaracaglia@gmail.com
Handle HTC
Vive
controller
inputs
if (Controller.GetAxis() != Vector2.zero)
{
controller_axis = Controller.GetAxis();
}
else { controller_axis = new Vector2(0, 0); }
4) Now, you have access to the controller and you can
easily read out the input. Add the following inside
the Update() method:
5) Add the variable controller_axis before the
Awake( ) method
public Vector2 controller_axis;
1129/08/18 | enricobaracaglia@gmail.com
Handle HTC
Vive
controller
inputs
The code at this stage should be:
1229/08/18 | enricobaracaglia@gmail.com
Rotate cube
in VR
6) Create a Cube in the scene
7) Now we add some variables to make the cube
rotate in space
//ROTATE
public float rotationalSpeed;
public float rotateHorizonta;
public float rotateVertica;
public GameObject myObject;
8) And we write the function RotateObj() below Update()
public void RotateObj()
{
myObject.transform.Rotate(Vector3.up, controller_axis.x *
rotationalSpeed, Space.World);
}
1329/08/18 | enricobaracaglia@gmail.com
Rotate cube
in VR
9) Insert the RotateObj() function inside Update()
// Update is called once per frame
void Update()
{
if (Controller.GetAxis() != Vector2.zero)
{
controller_axis = Controller.GetAxis();
RotateObj();
}
else { controller_axis = new Vector2(0, 0); }
}
1429/08/18 | enricobaracaglia@gmail.com
Rotate cube
in VR
How can we make the cube rotate
with respect to another axis?
1529/08/18 | enricobaracaglia@gmail.com
Rotate cube
in VR
Does the RotateObj() function take
into account the position of the
user?
Summary
16
In this workshop you learned how to:
✓ Create and interact with a User Interface (UI)
in Unity
✓ Set up a VR scene with SteamVR
✓ Handle some HTC Vive controller inputs
29/08/18 | enricobaracaglia@gmail.com
“
Thanks for listening.
Any questions?
1723/07/18 | enricobaracaglia@gmail.com https://www.linkedin.com/in/enrico-baracaglia-978789100/

More Related Content

Similar to VR Workshop #3

Tutorial ranorex
Tutorial ranorexTutorial ranorex
Tutorial ranorex
radikalzen
 
Virtual Reality - Usability Testing
Virtual Reality - Usability TestingVirtual Reality - Usability Testing
Virtual Reality - Usability Testing
Aziz Khilawala
 
Deploy With Codefresh to Kubernetes in 3 steps
Deploy With Codefresh to Kubernetes in 3 stepsDeploy With Codefresh to Kubernetes in 3 steps
Deploy With Codefresh to Kubernetes in 3 steps
Jenny Passi
 
Programming Without Coding Technology (PWCT) - Editbox control
Programming Without Coding Technology (PWCT) - Editbox controlProgramming Without Coding Technology (PWCT) - Editbox control
Programming Without Coding Technology (PWCT) - Editbox control
Mahmoud Samir Fayed
 
Programming Without Coding Technology (PWCT) - Slider control
Programming Without Coding Technology (PWCT) - Slider controlProgramming Without Coding Technology (PWCT) - Slider control
Programming Without Coding Technology (PWCT) - Slider control
Mahmoud Samir Fayed
 
Programming Without Coding Technology (PWCT) - Animatebox control
Programming Without Coding Technology (PWCT) - Animatebox controlProgramming Without Coding Technology (PWCT) - Animatebox control
Programming Without Coding Technology (PWCT) - Animatebox control
Mahmoud Samir Fayed
 
20200312 楊芝青律師-如何選擇適合的授權書取得權利
20200312 楊芝青律師-如何選擇適合的授權書取得權利20200312 楊芝青律師-如何選擇適合的授權書取得權利
20200312 楊芝青律師-如何選擇適合的授權書取得權利
Jamie C. Yang
 
Programming Without Coding Technology (PWCT) - Checkbox control
Programming Without Coding Technology (PWCT) - Checkbox controlProgramming Without Coding Technology (PWCT) - Checkbox control
Programming Without Coding Technology (PWCT) - Checkbox control
Mahmoud Samir Fayed
 
Is it time to migrate to Vue 3?
Is it time to migrate to Vue 3?Is it time to migrate to Vue 3?
Is it time to migrate to Vue 3?
Denny Biasiolli
 
Programming Without Coding Technology (PWCT) - Hyperlink control
Programming Without Coding Technology (PWCT) - Hyperlink controlProgramming Without Coding Technology (PWCT) - Hyperlink control
Programming Without Coding Technology (PWCT) - Hyperlink control
Mahmoud Samir Fayed
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - Beginners
Ambarish Hazarnis
 
Programming Without Coding Technology (PWCT) - Grid control
Programming Without Coding Technology (PWCT) - Grid controlProgramming Without Coding Technology (PWCT) - Grid control
Programming Without Coding Technology (PWCT) - Grid control
Mahmoud Samir Fayed
 
iOS Development (Part 3) - Additional GUI Components
iOS Development (Part 3) - Additional GUI ComponentsiOS Development (Part 3) - Additional GUI Components
iOS Development (Part 3) - Additional GUI Components
Asim Rais Siddiqui
 
Steps how to create active x using visual studio 2008
Steps how to create active x using visual studio 2008Steps how to create active x using visual studio 2008
Steps how to create active x using visual studio 2008
Yudep Apoi
 
Augmented reality in web rtc browser
Augmented reality in web rtc browserAugmented reality in web rtc browser
Augmented reality in web rtc browser
ALTANAI BISHT
 
VR Workshop #2
VR Workshop #2VR Workshop #2
VR Workshop #2
Enrico Baracaglia
 
The War is Over, and JavaScript has won: Living Under the JS Regime
The War is Over, and JavaScript has won: Living Under the JS RegimeThe War is Over, and JavaScript has won: Living Under the JS Regime
The War is Over, and JavaScript has won: Living Under the JS Regime
matthoneycutt
 
WebRTC Standards & Implementation Q&A - All about browser interoperability
WebRTC Standards & Implementation Q&A - All about browser interoperabilityWebRTC Standards & Implementation Q&A - All about browser interoperability
WebRTC Standards & Implementation Q&A - All about browser interoperability
Amir Zmora
 
Moustamera
MoustameraMoustamera
Moustamera
Bram Vandewalle
 
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
Plain Concepts
 

Similar to VR Workshop #3 (20)

Tutorial ranorex
Tutorial ranorexTutorial ranorex
Tutorial ranorex
 
Virtual Reality - Usability Testing
Virtual Reality - Usability TestingVirtual Reality - Usability Testing
Virtual Reality - Usability Testing
 
Deploy With Codefresh to Kubernetes in 3 steps
Deploy With Codefresh to Kubernetes in 3 stepsDeploy With Codefresh to Kubernetes in 3 steps
Deploy With Codefresh to Kubernetes in 3 steps
 
Programming Without Coding Technology (PWCT) - Editbox control
Programming Without Coding Technology (PWCT) - Editbox controlProgramming Without Coding Technology (PWCT) - Editbox control
Programming Without Coding Technology (PWCT) - Editbox control
 
Programming Without Coding Technology (PWCT) - Slider control
Programming Without Coding Technology (PWCT) - Slider controlProgramming Without Coding Technology (PWCT) - Slider control
Programming Without Coding Technology (PWCT) - Slider control
 
Programming Without Coding Technology (PWCT) - Animatebox control
Programming Without Coding Technology (PWCT) - Animatebox controlProgramming Without Coding Technology (PWCT) - Animatebox control
Programming Without Coding Technology (PWCT) - Animatebox control
 
20200312 楊芝青律師-如何選擇適合的授權書取得權利
20200312 楊芝青律師-如何選擇適合的授權書取得權利20200312 楊芝青律師-如何選擇適合的授權書取得權利
20200312 楊芝青律師-如何選擇適合的授權書取得權利
 
Programming Without Coding Technology (PWCT) - Checkbox control
Programming Without Coding Technology (PWCT) - Checkbox controlProgramming Without Coding Technology (PWCT) - Checkbox control
Programming Without Coding Technology (PWCT) - Checkbox control
 
Is it time to migrate to Vue 3?
Is it time to migrate to Vue 3?Is it time to migrate to Vue 3?
Is it time to migrate to Vue 3?
 
Programming Without Coding Technology (PWCT) - Hyperlink control
Programming Without Coding Technology (PWCT) - Hyperlink controlProgramming Without Coding Technology (PWCT) - Hyperlink control
Programming Without Coding Technology (PWCT) - Hyperlink control
 
Titanium Appcelerator - Beginners
Titanium Appcelerator - BeginnersTitanium Appcelerator - Beginners
Titanium Appcelerator - Beginners
 
Programming Without Coding Technology (PWCT) - Grid control
Programming Without Coding Technology (PWCT) - Grid controlProgramming Without Coding Technology (PWCT) - Grid control
Programming Without Coding Technology (PWCT) - Grid control
 
iOS Development (Part 3) - Additional GUI Components
iOS Development (Part 3) - Additional GUI ComponentsiOS Development (Part 3) - Additional GUI Components
iOS Development (Part 3) - Additional GUI Components
 
Steps how to create active x using visual studio 2008
Steps how to create active x using visual studio 2008Steps how to create active x using visual studio 2008
Steps how to create active x using visual studio 2008
 
Augmented reality in web rtc browser
Augmented reality in web rtc browserAugmented reality in web rtc browser
Augmented reality in web rtc browser
 
VR Workshop #2
VR Workshop #2VR Workshop #2
VR Workshop #2
 
The War is Over, and JavaScript has won: Living Under the JS Regime
The War is Over, and JavaScript has won: Living Under the JS RegimeThe War is Over, and JavaScript has won: Living Under the JS Regime
The War is Over, and JavaScript has won: Living Under the JS Regime
 
WebRTC Standards & Implementation Q&A - All about browser interoperability
WebRTC Standards & Implementation Q&A - All about browser interoperabilityWebRTC Standards & Implementation Q&A - All about browser interoperability
WebRTC Standards & Implementation Q&A - All about browser interoperability
 
Moustamera
MoustameraMoustamera
Moustamera
 
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
DotNet 2019 | Marcos Cobeña - Llevando Wave Engine a la web a través de WebGL...
 

Recently uploaded

LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
Ayan Halder
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 

Recently uploaded (20)

LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 

VR Workshop #3

  • 1. PRESENTER Enrico BARACAGLIA WORKSHOP #3 Beginners Introduction to VR with Unity3D 29 AUGUST 2018 ORGANIZED BY ESO, Chile SUPERVISOR Frédéric VOGT
  • 2. Overview 1. Create User Interface (UI) 2. Set up VR scene with SteamVR 3. Handle HTC Vive controller inputs 4. Guided practical session a. Transform.Rotate VR b. Transform.Translate VR 2
  • 3. Canvas UI https://docs.unity3d.com/Manual/UICa nvas.html Create User Interface 3 Insert User Interface (UI) STEPS: 1) UI > Canvas 2) Modify Canvas RectTransform 3) Canvas > Create Panel 4) Canvas > Create 1st Toggle 5) Canvas > Create 2nd Toggle
  • 4. Create User Interface 4 Insert User Interface (UI) STEPS: 1) UI > Canvas 2) Modify Canvas RectTransform 3) Canvas > Create Panel 4) Canvas > Create 1st Toggle 5) Canvas > Create 2nd Toggle Toggle UI https://docs.unity3d.com/ScriptRefere nce/UI.Toggle.html
  • 5. Create User Interface 5 5) Create Empty > Add Component > Toggle Group 6) Add : using UnityEngine.UI; 7) Add : if (myToggle.isOn) { //function }; Toggle Group UI https://docs.unity3d.com/Manual/scrip t-ToggleGroup.html Insert User Interface (UI)
  • 6. Set up VR scene with SteamVR (new scene) 629/08/18 | enricobaracaglia@gmail.com STEPS: 1) Download and Import SteamVR 2) Import the prefab [CameraRig] and [SteamVR] from the SteamVR folder 3) Delete the Main Camera from the Hierarchy because it will interfere with the [CameraRig] and its embedded camera. 4) Ready to press play and see the world in VR! Note: you need the VR headset for it to work properly
  • 7. 729/08/18 | enricobaracaglia@gmail.com Handle HTC Vive controller inputs Each controller has the following inputs:
  • 8. 829/08/18 | enricobaracaglia@gmail.com Handle HTC Vive controller inputs We can access these inputs by following these steps: // Create a reference to the object being tracked. In this case, a controller. private SteamVR_TrackedObject trackedObj; // Create a Device property to provide easy access to the controller. It uses the tracked object’s index to return the controller’s input. private SteamVR_Controller.Device Controller { get { return SteamVR_Controller.Input((int)trackedObj.index) ;} } 1) Create a new C# script called VR_MoveObject 2) Add the following right above the Update() method: HTC Vive tutorial for Unity https://www.raywenderlich.com/792- htc-vive-tutorial-for-unity
  • 9. 929/08/18 | enricobaracaglia@gmail.com Handle HTC Vive controller inputs We can access these inputs by following these steps: void Awake() { trackedObj = GetComponent<SteamVR_TrackedObject>(); } 3) Add the following method right above Update():
  • 10. 1029/08/18 | enricobaracaglia@gmail.com Handle HTC Vive controller inputs if (Controller.GetAxis() != Vector2.zero) { controller_axis = Controller.GetAxis(); } else { controller_axis = new Vector2(0, 0); } 4) Now, you have access to the controller and you can easily read out the input. Add the following inside the Update() method: 5) Add the variable controller_axis before the Awake( ) method public Vector2 controller_axis;
  • 11. 1129/08/18 | enricobaracaglia@gmail.com Handle HTC Vive controller inputs The code at this stage should be:
  • 12. 1229/08/18 | enricobaracaglia@gmail.com Rotate cube in VR 6) Create a Cube in the scene 7) Now we add some variables to make the cube rotate in space //ROTATE public float rotationalSpeed; public float rotateHorizonta; public float rotateVertica; public GameObject myObject; 8) And we write the function RotateObj() below Update() public void RotateObj() { myObject.transform.Rotate(Vector3.up, controller_axis.x * rotationalSpeed, Space.World); }
  • 13. 1329/08/18 | enricobaracaglia@gmail.com Rotate cube in VR 9) Insert the RotateObj() function inside Update() // Update is called once per frame void Update() { if (Controller.GetAxis() != Vector2.zero) { controller_axis = Controller.GetAxis(); RotateObj(); } else { controller_axis = new Vector2(0, 0); } }
  • 14. 1429/08/18 | enricobaracaglia@gmail.com Rotate cube in VR How can we make the cube rotate with respect to another axis?
  • 15. 1529/08/18 | enricobaracaglia@gmail.com Rotate cube in VR Does the RotateObj() function take into account the position of the user?
  • 16. Summary 16 In this workshop you learned how to: ✓ Create and interact with a User Interface (UI) in Unity ✓ Set up a VR scene with SteamVR ✓ Handle some HTC Vive controller inputs 29/08/18 | enricobaracaglia@gmail.com
  • 17. “ Thanks for listening. Any questions? 1723/07/18 | enricobaracaglia@gmail.com https://www.linkedin.com/in/enrico-baracaglia-978789100/