Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-065
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020-065
2020-065
Commits
cf822e60
Commit
cf822e60
authored
Jul 03, 2020
by
Abeykoon Mudiyanselage Anjana Chankya Bandara Abeykoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete basicspawner.cs
parent
fa1d3c01
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
87 deletions
+0
-87
IT17025904/Assets/basicspawner.cs
IT17025904/Assets/basicspawner.cs
+0
-87
No files found.
IT17025904/Assets/basicspawner.cs
deleted
100644 → 0
View file @
fa1d3c01
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.XR.ARFoundation
;
using
UnityEngine.Experimental.XR
;
using
System
;
public
class
basicspawner
:
MonoBehaviour
{
public
GameObject
targetimg
;
private
GameObject
modeltoplace
;
private
ARSessionOrigin
arOrigin
;
private
ARRaycastManager
rayCAst
;
private
Pose
placepose
;
private
bool
hitvalid
=
false
;
// Start is called before the first frame update
void
Start
()
{
arOrigin
=
FindObjectOfType
<
ARSessionOrigin
>();
rayCAst
=
FindObjectOfType
<
ARRaycastManager
>();
}
// Update is called once per frame
void
Update
()
{
updateplacepose
();
Updatetarget
();
if
(
hitvalid
&&
Input
.
touchCount
>
0
&&
Input
.
GetTouch
(
0
).
phase
==
TouchPhase
.
Began
)
{
placemodel
();
}
}
private
void
placemodel
()
{
if
(
variables
.
objtype
==
1
)
{
modeltoplace
=
Resources
.
Load
(
"1"
)
as
GameObject
;
Instantiate
(
modeltoplace
,
placepose
.
position
,
placepose
.
rotation
);
}
if
(
variables
.
objtype
==
2
)
{
modeltoplace
=
Resources
.
Load
(
"2"
)
as
GameObject
;
Instantiate
(
modeltoplace
,
placepose
.
position
,
placepose
.
rotation
);
}
if
(
variables
.
objtype
==
3
)
{
modeltoplace
=
Resources
.
Load
(
"3"
)
as
GameObject
;
Instantiate
(
modeltoplace
,
placepose
.
position
,
placepose
.
rotation
);
}
}
private
void
Updatetarget
()
{
if
(
hitvalid
)
{
targetimg
.
SetActive
(
true
);
targetimg
.
transform
.
SetPositionAndRotation
(
placepose
.
position
,
placepose
.
rotation
);
}
else
{
targetimg
.
SetActive
(
false
);
}
}
private
void
updateplacepose
()
{
var
screencenter
=
Camera
.
current
.
ViewportToScreenPoint
(
new
Vector3
(
0.5f
,
0.5f
));
var
hits
=
new
List
<
ARRaycastHit
>();
rayCAst
.
Raycast
(
screencenter
,
hits
,
UnityEngine
.
XR
.
ARSubsystems
.
TrackableType
.
Planes
);
hitvalid
=
hits
.
Count
>
0
;
if
(
hitvalid
)
{
placepose
=
hits
[
0
].
pose
;
var
camforward
=
Camera
.
current
.
transform
.
forward
;
var
camrot
=
new
Vector3
(
camforward
.
x
,
0
,
camforward
.
z
).
normalized
;
placepose
.
rotation
=
Quaternion
.
LookRotation
(
camrot
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment