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
2f6995ff
Commit
2f6995ff
authored
Nov 06, 2020
by
Fonseka W.M.D.R
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete GizmoTranslateScript.cs
parent
a0a050af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
155 deletions
+0
-155
IT17160926/Measure/Assets/Scripts/GizmoAdjustment Scripts/GizmoTranslateScript.cs
...s/Scripts/GizmoAdjustment Scripts/GizmoTranslateScript.cs
+0
-155
No files found.
IT17160926/Measure/Assets/Scripts/GizmoAdjustment Scripts/GizmoTranslateScript.cs
deleted
100644 → 0
View file @
a0a050af
using
UnityEngine
;
using
System.Collections
;
/*script to handle the functionality of the Translate Gizmo ( move the gizmo
and the target object along the axis the user is dragging towards) */
public
class
GizmoTranslateScript
:
MonoBehaviour
{
//X axis of gizmo
public
GameObject
xAxisObject
;
//Y axis of gizmo
public
GameObject
yAxisObject
;
//Z axis of gizmo
public
GameObject
zAxisObject
;
//Target for translation
public
GameObject
translateTarget
;
//Array of detector scripts stored as [x, y, z]
private
GizmoClickDetection
[]
detectors
;
[
SerializeField
]
float
distanceMultiplier
=
0.8f
;
//On wake up
public
void
Awake
()
{
//Get the click detection scripts
detectors
=
new
GizmoClickDetection
[
3
];
detectors
[
0
]
=
xAxisObject
.
GetComponent
<
GizmoClickDetection
>();
detectors
[
1
]
=
yAxisObject
.
GetComponent
<
GizmoClickDetection
>();
detectors
[
2
]
=
zAxisObject
.
GetComponent
<
GizmoClickDetection
>();
//Set the same position for the target and the gizmo
transform
.
position
=
translateTarget
.
transform
.
position
;
}
///Once per frame
public
void
Update
()
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
if
(
Input
.
GetMouseButton
(
0
)
&&
detectors
[
i
].
pressing
)
{
//Get the distance from the camera to the target (used as a scaling factor in translate)
float
distance
=
Vector3
.
Distance
(
Camera
.
main
.
transform
.
position
,
translateTarget
.
transform
.
position
);
distance
=
distance
*
distanceMultiplier
;
//Will store translate values
Vector3
offset
=
Vector3
.
zero
;
switch
(
i
)
{
//X Axis
case
0
:
{
//If user is pressing the plane, move along Y and Z, else move along X
Debug
.
Log
(
"X Axis, case 0, switch: "
+
i
);
if
(
detectors
[
i
].
pressingPlane
)
{
Debug
.
Log
(
"Inside x axis if"
);
float
deltaY
=
Input
.
GetAxis
(
"Mouse Y"
)
*
(
Time
.
deltaTime
*
distance
);
offset
=
Vector3
.
up
*
deltaY
;
offset
=
new
Vector3
(
0.0f
,
offset
.
y
,
0.0f
);
translateTarget
.
transform
.
Translate
(
offset
);
float
deltaZ
=
Input
.
GetAxis
(
"Mouse X"
)
*
(
Time
.
deltaTime
*
distance
);
offset
=
Vector3
.
forward
*
deltaZ
;
offset
=
new
Vector3
(
0.0f
,
0.0f
,
offset
.
z
);
translateTarget
.
transform
.
Translate
(
offset
);
}
else
{
Debug
.
Log
(
"Inside x axis else"
);
float
delta
=
Input
.
GetAxis
(
"Mouse X"
)
*
(
Time
.
deltaTime
*
distance
);
offset
=
Vector3
.
left
*
delta
;
offset
=
new
Vector3
(
offset
.
x
,
0.0f
,
0.0f
);
translateTarget
.
transform
.
Translate
(
offset
);
}
}
break
;
//Y Axis
case
1
:
{
//If user is pressing the plane, move along X and Z, else just move along X
Debug
.
Log
(
"Y Axis, case 1, switch: "
+
i
);
if
(
detectors
[
i
].
pressingPlane
)
{
Debug
.
Log
(
"Inside y axis if"
);
float
deltaX
=
Input
.
GetAxis
(
"Mouse X"
)
*
(
Time
.
deltaTime
*
distance
);
offset
=
Vector3
.
left
*
deltaX
;
offset
=
new
Vector3
(
offset
.
x
,
0.0f
,
0.0f
);
translateTarget
.
transform
.
Translate
(
offset
);
float
deltaZ
=
Input
.
GetAxis
(
"Mouse Y"
)
*
(
Time
.
deltaTime
*
distance
);
offset
=
Vector3
.
forward
*
deltaZ
;
offset
=
new
Vector3
(
0.0f
,
0.0f
,
-
offset
.
z
);
translateTarget
.
transform
.
Translate
(
offset
);
}
else
{
Debug
.
Log
(
"Inside y axis else"
);
float
delta
=
Input
.
GetAxis
(
"Mouse Y"
)
*
(
Time
.
deltaTime
*
distance
);
offset
=
Vector3
.
up
*
delta
;
offset
=
new
Vector3
(
0.0f
,
offset
.
y
,
0.0f
);
translateTarget
.
transform
.
Translate
(
offset
);
}
}
break
;
//Z Axis
case
2
:
{
//If user is pressing the plane, move along X and Y, else just move along Z
Debug
.
Log
(
"Z Axis, case 2, switch: "
+
i
);
if
(
detectors
[
i
].
pressingPlane
)
{
Debug
.
Log
(
"Inside z axis if"
);
float
deltaX
=
Input
.
GetAxis
(
"Mouse X"
)
*
(
Time
.
deltaTime
*
distance
);
offset
=
Vector3
.
left
*
deltaX
;
offset
=
new
Vector3
(
offset
.
x
,
0.0f
,
0.0f
);
translateTarget
.
transform
.
Translate
(
offset
);
float
deltaY
=
Input
.
GetAxis
(
"Mouse Y"
)
*
(
Time
.
deltaTime
*
distance
);
offset
=
Vector3
.
up
*
deltaY
;
offset
=
new
Vector3
(
0.0f
,
offset
.
y
,
0.0f
);
translateTarget
.
transform
.
Translate
(
offset
);
}
else
{
Debug
.
Log
(
"Inside z axis else"
);
float
delta
=
Input
.
GetAxis
(
"Mouse X"
)
*
(
Time
.
deltaTime
*
distance
);
offset
=
Vector3
.
forward
*
delta
;
offset
=
new
Vector3
(
0.0f
,
0.0f
,
offset
.
z
);
translateTarget
.
transform
.
Translate
(
offset
);
}
}
break
;
}
//Move the gizmo to match the target position
transform
.
position
=
translateTarget
.
transform
.
position
;
break
;
}
}
}
}
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