Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
curvedflats
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Flatland
curvedflats
Commits
ada94d32
Commit
ada94d32
authored
Aug 10, 2019
by
17김현학
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PathUI is placed at destination of patH
parent
9159b7bc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
13 deletions
+20
-13
Test.unity
Assets/Scenes/Test.unity
+5
-5
UIManager.cs
Assets/Scripts/UIManager.cs
+15
-8
No files found.
Assets/Scenes/Test.unity
View file @
ada94d32
...
...
@@ -3076,8 +3076,8 @@ RectTransform:
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0.5
,
y
:
0.5
}
m_AnchorMax
:
{
x
:
0.5
,
y
:
0.5
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
4
2
}
m_SizeDelta
:
{
x
:
86.75
,
y
:
30
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
4
1.199997
}
m_SizeDelta
:
{
x
:
100.26
,
y
:
30
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
---
!u!114
&1335777782
MonoBehaviour
:
...
...
@@ -3195,9 +3195,9 @@ RectTransform:
m_Father
:
{
fileID
:
1193230061
}
m_RootOrder
:
6
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMax
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
164
,
y
:
105
}
m_AnchorMin
:
{
x
:
0
.5
,
y
:
0.5
}
m_AnchorMax
:
{
x
:
0
.5
,
y
:
0.5
}
m_AnchoredPosition
:
{
x
:
-156.13002
,
y
:
-66.28998
}
m_SizeDelta
:
{
x
:
312.26
,
y
:
132.57999
}
m_Pivot
:
{
x
:
0
,
y
:
0
}
---
!u!1
&1661408487
...
...
Assets/Scripts/UIManager.cs
View file @
ada94d32
...
...
@@ -24,6 +24,7 @@ public class UIManager : MonoBehaviour
private
int
prevSelectPathNum
=
-
1
;
private
Text
pathName
;
private
Vector3
middlePoint
;
private
Vector3
canvasSize
;
// Start is called before the first frame update
void
Start
()
...
...
@@ -31,6 +32,7 @@ public class UIManager : MonoBehaviour
_pathUI
.
SetActive
(
false
);
pathName
=
_pathUI
.
transform
.
Find
(
"Name"
).
GetComponent
<
Text
>();
middlePoint
=
_pathUI
.
transform
.
position
;
canvasSize
=
new
Vector3
(
Screen
.
width
,
Screen
.
height
,
0
);
}
// Update is called once per frame
...
...
@@ -63,15 +65,20 @@ public class UIManager : MonoBehaviour
if
(
pathNum
!=
prevSelectPathNum
)
{
pathName
.
text
=
obj
.
name
;
//_pathUI.transform.position = middlePoint;
var
tmp
=
Camera
.
main
.
WorldToScreenPoint
(
hit1
.
point
);
float
width
=
Screen
.
width
*
_pathUI
.
GetComponent
<
RectTransform
>().
anchorMin
.
x
;
float
height
=
Screen
.
height
*
_pathUI
.
GetComponent
<
RectTransform
>().
anchorMin
.
y
;
var
mouseClickPosition
=
tmp
-
canvasSize
*
0.5f
+
middlePoint
;
_pathUI
.
GetComponent
<
RectTransform
>().
anchoredPosition
=
new
Vector2
(
tmp
.
x
-
width
,
tmp
.
y
-
height
);
// see for reference: https://sushanta1991.blogspot.com/2016/04/how-to-move-unity-ui-using-mouse.html
// Also try using Camera.WorldtoViewportPoint() and Camera.WorldtoScreenPoint() to convert world coordinates to
// normalized viewport (x,y) or pixel coordinates)
var
hitVector1
=
mouseClickPosition
-
middlePoint
;
hitVector1
.
z
=
0
;
var
hitVector2
=
new
Vector3
(
hit2
.
point
.
x
,
hit2
.
point
.
z
,
0.0f
);
Debug
.
Log
(
hitVector1
+
"test"
);
Debug
.
Log
(
hitVector2
+
"test"
);
var
k
=
hitVector1
.
magnitude
/
hitVector2
.
magnitude
;
Debug
.
Log
(
k
+
"test"
);
var
v
=
square
.
GetDestPoint
(
pathNum
)
-
hitVector2
;
v
.
z
=
0
;
_pathUI
.
transform
.
position
=
mouseClickPosition
+
k
*
v
;
_pathUI
.
SetActive
(
true
);
prevSelectPathNum
=
pathNum
;
}
...
...
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