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
4c5084b2
Commit
4c5084b2
authored
Jul 21, 2019
by
17김현학
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the bug(Issue
#18
)
Add Slider(Velocity, acceleration), button, text (No coding)
parent
66191322
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1716 additions
and
100 deletions
+1716
-100
PathUI.prefab
Assets/Prefabs/PathUI.prefab
+24
-19
SampleScene.unity
Assets/Scenes/SampleScene.unity
+1653
-56
PathRenderer.cs
Assets/Scripts/PathRenderer.cs
+0
-18
Square.cs
Assets/Scripts/Square.cs
+8
-1
UIManager.cs
Assets/Scripts/UIManager.cs
+31
-6
No files found.
Assets/Prefabs/PathUI.prefab
View file @
4c5084b2
...
...
@@ -8,17 +8,17 @@ GameObject:
m_PrefabAsset
:
{
fileID
:
0
}
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
6021508400235234100
}
-
component
:
{
fileID
:
6021508400235234098
}
-
component
:
{
fileID
:
6021508400235234099
}
m_Layer
:
5
-
component
:
{
fileID
:
5014434788102240908
}
-
component
:
{
fileID
:
5427705129206684837
}
-
component
:
{
fileID
:
5981043734760163717
}
m_Layer
:
0
m_Name
:
PathUI
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!224
&
6021508400235234100
---
!u!224
&
5014434788102240908
RectTransform
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
...
...
@@ -35,9 +35,9 @@ RectTransform:
m_AnchorMin
:
{
x
:
0.5
,
y
:
0.5
}
m_AnchorMax
:
{
x
:
0.5
,
y
:
0.5
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_SizeDelta
:
{
x
:
5
,
y
:
5
}
m_SizeDelta
:
{
x
:
80.15
,
y
:
13.48
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
---
!u!222
&
6021508400235234098
---
!u!222
&
5427705129206684837
CanvasRenderer
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
...
...
@@ -45,7 +45,7 @@ CanvasRenderer:
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
6021508400235234101
}
m_CullTransparentMesh
:
0
---
!u!114
&
6021508400235234099
---
!u!114
&
5981043734760163717
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
...
...
@@ -54,23 +54,28 @@ MonoBehaviour:
m_GameObject
:
{
fileID
:
6021508400235234101
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
-765806418
,
guid
:
f70555f144d8491a825f0804e09c671c
,
type
:
3
}
m_Script
:
{
fileID
:
708705254
,
guid
:
f70555f144d8491a825f0804e09c671c
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
m_Material
:
{
fileID
:
0
}
m_Color
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
0.392
}
m_Color
:
{
r
:
0
.19607843
,
g
:
0.19607843
,
b
:
0.19607843
,
a
:
1
}
m_RaycastTarget
:
1
m_OnCullStateChanged
:
m_PersistentCalls
:
m_Calls
:
[]
m_TypeName
:
UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite
:
{
fileID
:
21300000
,
guid
:
0905f15ba4c169d478723617ce3c4ad1
,
type
:
3
}
m_Type
:
0
m_PreserveAspect
:
0
m_FillCenter
:
1
m_FillMethod
:
4
m_FillAmount
:
1
m_FillClockwise
:
1
m_FillOrigin
:
0
m_UseSpriteMesh
:
0
m_FontData
:
m_Font
:
{
fileID
:
10102
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
m_FontSize
:
6
m_FontStyle
:
0
m_BestFit
:
0
m_MinSize
:
1
m_MaxSize
:
40
m_Alignment
:
0
m_AlignByGeometry
:
0
m_RichText
:
0
m_HorizontalOverflow
:
0
m_VerticalOverflow
:
0
m_LineSpacing
:
1
m_Text
:
Assets/Scenes/SampleScene.unity
View file @
4c5084b2
This diff is collapsed.
Click to expand it.
Assets/Scripts/PathRenderer.cs
View file @
4c5084b2
...
...
@@ -12,9 +12,6 @@ public class PathRenderer : MonoBehaviour
[
SerializeField
]
GameObject
PathColliderPrefab
;
public
GameObject
canvas
;
public
GameObject
pathUIPrefab
;
LineRenderer
_pathRenderer
;
float
_originalPathColliderY
;
// Start is called before the first frame update
...
...
@@ -55,7 +52,6 @@ public class PathRenderer : MonoBehaviour
square
.
pathList
[
1
]
=
point
;
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
_InstantiatePathCollider
(
0
);
_InstantiatePathUI
(
0
,
point
/
2
);
}
private
void
_ResetPaths
()
...
...
@@ -68,9 +64,6 @@ public class PathRenderer : MonoBehaviour
for
(
int
i
=
0
;
i
<
transform
.
childCount
;
i
++)
{
Destroy
(
transform
.
GetChild
(
i
).
gameObject
);
string
str
=
"PathUI-"
+
i
;
GameObject
t
=
canvas
.
transform
.
FindChild
(
str
).
gameObject
;
Destroy
(
t
);
}
}
...
...
@@ -80,7 +73,6 @@ public class PathRenderer : MonoBehaviour
_pathRenderer
.
positionCount
=
square
.
pathList
.
Count
();
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
_InstantiatePathCollider
(
square
.
pathList
.
Count
()
-
2
);
_InstantiatePathUI
(
square
.
pathList
.
Count
()
-
2
,
(
point
+
square
.
pathList
[
square
.
pathList
.
Count
()
-
2
])/
2
);
}
private
void
_InstantiatePathCollider
(
int
n
)
...
...
@@ -100,14 +92,4 @@ public class PathRenderer : MonoBehaviour
_pathCollider
.
transform
.
position
=
(
square
.
pathList
[
n
]
+
square
.
pathList
[
n
+
1
])
/
2
;
}
private
void
_InstantiatePathUI
(
int
n
,
Vector3
point
)
{
var
_pathUI
=
Instantiate
(
pathUIPrefab
);
_pathUI
.
transform
.
SetParent
(
canvas
.
transform
);
_pathUI
.
transform
.
position
+=
point
;
_pathUI
.
name
=
"PathUI-"
+
n
;
_pathUI
.
tag
=
"pathui"
;
_pathUI
.
SetActive
(
false
);
}
}
Assets/Scripts/Square.cs
View file @
4c5084b2
...
...
@@ -7,7 +7,9 @@ using System.Linq;
public
class
Square
:
FlatLandObject
{
public
List
<
Vector3
>
pathList
=
new
List
<
Vector3
>();
public
List
<
float
>
pathVelocity
=
new
List
<
float
>();
private
float
_zPosition
=>
transform
.
position
.
z
;
private
float
PlayerVelocity
;
public
Vector3
GetNthPath
(
int
n
)
// Get a path from (n)th destination to (n+1)th destination.
{
...
...
@@ -18,4 +20,9 @@ public class Square : FlatLandObject
{
return
v
.
y
/
v
.
x
;
}
}
public
Vector3
GetMiddlePoint
(
int
st
,
int
en
)
{
return
(
pathList
[
en
]
-
pathList
[
st
])
/
2
;
}
}
\ No newline at end of file
Assets/Scripts/UIManager.cs
View file @
4c5084b2
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.UI
;
using
System
;
using
System.Linq
;
public
class
UIManager
:
MonoBehaviour
{
[
SerializeField
]
Square
square
;
public
GameObject
canvas
;
public
GameObject
pathUIPrefab
;
private
GameObject
_pathUI
;
private
int
prevSelectPathNum
=
-
1
;
// Start is called before the first frame update
void
Start
()
{
_InstantiatePathUI
();
_pathUI
.
SetActive
(
false
);
}
// Update is called once per frame
...
...
@@ -26,19 +37,33 @@ public class UIManager : MonoBehaviour
if
(
obj
.
tag
==
"path"
)
{
int
pathNum
=
int
.
Parse
(
obj
.
name
.
Substring
(
13
));
string
str
=
"PathUI-"
+
pathNum
;
GameObject
t
=
canvas
.
transform
.
FindChild
(
str
).
gameObject
;
if
(
t
.
activeSelf
==
true
)
if
(
pathNum
!=
prevSelectPathNum
)
{
t
.
SetActive
(
false
);
_pathUI
.
GetComponent
<
Text
>().
text
=
obj
.
name
;
_pathUI
.
SetActive
(
true
);
prevSelectPathNum
=
pathNum
;
}
else
{
t
.
SetActive
(
true
);
_pathUI
.
SetActive
(
false
);
prevSelectPathNum
=
-
1
;
}
}
else
{
_pathUI
.
SetActive
(
false
);
prevSelectPathNum
=
-
1
;
}
}
}
}
private
void
_InstantiatePathUI
()
{
_pathUI
=
Instantiate
(
pathUIPrefab
);
_pathUI
.
transform
.
SetParent
(
canvas
.
transform
);
_pathUI
.
name
=
"PathUI"
;
_pathUI
.
tag
=
"pathui"
;
}
}
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