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
a1e60091
Commit
a1e60091
authored
5 years ago
by
17김현학
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding Path UI (use dummy image)
parent
525b88d4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
284 additions
and
102 deletions
+284
-102
.collabignore
.collabignore
+33
-0
PathUI.prefab
Assets/Prefabs/PathUI.prefab
+76
-0
PathUI.prefab.meta
Assets/Prefabs/PathUI.prefab.meta
+7
-0
PathRenderer.cs
Assets/Scripts/PathRenderer.cs
+113
-102
UIManager.cs
Assets/Scripts/UIManager.cs
+44
-0
UIManager.cs.meta
Assets/Scripts/UIManager.cs.meta
+11
-0
No files found.
.collabignore
0 → 100644
View file @
a1e60091
# ===========================
# Default Collab Ignore Rules
# ===========================
# OS Generated
# ============
.DS_Store
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
[Tt]humbs.db
[Dd]esktop.ini
# Visual Studio / MonoDevelop generated
# =====================================
[Ee]xported[Oo]bj/
*.userprefs
*.csproj
*.pidb
*.suo
*.sln
*.user
*.unityproj
*.booproj
# Unity generated
# ===============
[Oo]bj/
[Bb]uild
sysinfo.txt
*.stackdump
This diff is collapsed.
Click to expand it.
Assets/Prefabs/PathUI.prefab
0 → 100644
View file @
a1e60091
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!1
&6021508400235234101
GameObject
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
6021508400235234100
}
-
component
:
{
fileID
:
6021508400235234098
}
-
component
:
{
fileID
:
6021508400235234099
}
m_Layer
:
5
m_Name
:
PathUI
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!224
&6021508400235234100
RectTransform
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
6021508400235234101
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
0
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
:
0
}
m_SizeDelta
:
{
x
:
5
,
y
:
5
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
---
!u!222
&6021508400235234098
CanvasRenderer
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
6021508400235234101
}
m_CullTransparentMesh
:
0
---
!u!114
&6021508400235234099
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
6021508400235234101
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
-765806418
,
guid
:
f70555f144d8491a825f0804e09c671c
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
m_Material
:
{
fileID
:
0
}
m_Color
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
0.392
}
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
This diff is collapsed.
Click to expand it.
Assets/Prefabs/PathUI.prefab.meta
0 → 100644
View file @
a1e60091
fileFormatVersion: 2
guid: db6831d28b87b2745b9eff23a7e565c8
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
Click to expand it.
Assets/Scripts/PathRenderer.cs
View file @
a1e60091
using
System.Collections
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine
;
using
System.Linq
;
using
System.Linq
;
using
System
;
using
UnityEngine.UI
;
using
System
;
public
class
PathRenderer
:
MonoBehaviour
{
public
class
PathRenderer
:
MonoBehaviour
[
SerializeField
]
{
Square
square
;
[
SerializeField
]
[
SerializeField
]
Square
square
;
GameObject
PathColliderPrefab
;
[
SerializeField
]
GameObject
PathColliderPrefab
;
LineRenderer
_pathRenderer
;
float
_originalPathColliderY
;
public
GameObject
canvas
;
// Start is called before the first frame update
public
GameObject
pathUIPrefab
;
void
Start
()
{
LineRenderer
_pathRenderer
;
_originalPathColliderY
=
PathColliderPrefab
.
transform
.
localScale
.
y
;
float
_originalPathColliderY
;
// Start is called before the first frame update
_pathRenderer
=
GetComponent
<
LineRenderer
>();
void
Start
()
_ResetPaths
();
{
}
_originalPathColliderY
=
PathColliderPrefab
.
transform
.
localScale
.
y
;
// Update is called once per frame
_pathRenderer
=
GetComponent
<
LineRenderer
>();
void
Update
()
_ResetPaths
();
{
}
if
(
Input
.
GetMouseButtonDown
(
1
))
{
// Update is called once per frame
RaycastHit
hit
;
void
Update
()
var
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
{
if
(
Input
.
GetMouseButtonDown
(
1
))
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
{
{
RaycastHit
hit
;
if
(
Input
.
GetKey
(
KeyCode
.
LeftShift
))
var
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
{
_DrawMorePath
(
hit
.
point
);
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
}
{
else
if
(
Input
.
GetKey
(
KeyCode
.
LeftShift
))
{
{
_DrawOnePath
(
hit
.
point
);
_DrawMorePath
(
hit
.
point
);
}
}
}
else
}
{
_DrawOnePath
(
hit
.
point
);
if
(
Input
.
GetMouseButtonDown
(
0
))
}
{
}
RaycastHit
hit
;
}
var
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
}
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
private
void
_DrawOnePath
(
Vector3
point
)
{
{
Debug
.
Log
(
hit
.
collider
.
gameObject
.
name
);
_ResetPaths
();
}
square
.
pathList
[
0
]
=
transform
.
position
;
}
square
.
pathList
[
1
]
=
point
;
}
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
_InstantiatePathCollider
(
0
);
private
void
_DrawOnePath
(
Vector3
point
)
_InstantiatePathUI
(
0
,
point
/
2
);
{
}
_ResetPaths
();
square
.
pathList
[
0
]
=
transform
.
position
;
private
void
_ResetPaths
()
square
.
pathList
[
1
]
=
point
;
{
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
_pathRenderer
.
positionCount
=
2
;
_InstantiatePathCollider
(
0
);
square
.
pathList
.
Clear
();
}
square
.
pathList
.
Add
(
transform
.
position
);
square
.
pathList
.
Add
(
new
Vector3
(
0
,
0
,
0
));
private
void
_ResetPaths
()
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
{
for
(
int
i
=
0
;
i
<
transform
.
childCount
;
i
++)
_pathRenderer
.
positionCount
=
2
;
{
square
.
pathList
.
Clear
();
Destroy
(
transform
.
GetChild
(
i
).
gameObject
);
square
.
pathList
.
Add
(
transform
.
position
);
string
str
=
"PathUI-"
+
i
;
square
.
pathList
.
Add
(
new
Vector3
(
0
,
0
,
0
));
GameObject
t
=
canvas
.
transform
.
FindChild
(
str
).
gameObject
;
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
Destroy
(
t
);
for
(
int
i
=
0
;
i
<
transform
.
childCount
;
i
++)
}
Destroy
(
transform
.
GetChild
(
i
).
gameObject
);
}
}
private
void
_DrawMorePath
(
Vector3
point
)
private
void
_DrawMorePath
(
Vector3
point
)
{
{
square
.
pathList
.
Add
(
point
);
square
.
pathList
.
Add
(
point
);
_pathRenderer
.
positionCount
=
square
.
pathList
.
Count
();
_pathRenderer
.
positionCount
=
square
.
pathList
.
Count
();
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
_InstantiatePathCollider
(
square
.
pathList
.
Count
()
-
2
);
_InstantiatePathCollider
(
square
.
pathList
.
Count
()
-
2
);
_InstantiatePathUI
(
square
.
pathList
.
Count
()
-
2
,
(
point
+
square
.
pathList
[
square
.
pathList
.
Count
()
-
2
])/
2
);
}
}
private
void
_InstantiatePathCollider
(
int
n
)
private
void
_InstantiatePathCollider
(
int
n
)
{
{
var
_pathCollider
=
Instantiate
(
PathColliderPrefab
,
transform
);
var
_pathCollider
=
Instantiate
(
PathColliderPrefab
,
transform
);
_pathCollider
.
name
=
"PathCollider-"
+
n
;
_pathCollider
.
name
=
"PathCollider-"
+
n
;
_pathCollider
.
transform
.
localScale
=
new
Vector3
(
2
,
_originalPathColliderY
,
0
);
_pathCollider
.
tag
=
"path"
;
_pathCollider
.
transform
.
eulerAngles
=
new
Vector3
(
0
,
0
,
_pathCollider
.
transform
.
localScale
=
new
Vector3
(
2
,
_originalPathColliderY
,
0
);
(
float
)
Constants
.
RadianToDegree
(
Mathf
.
PI
/
2
+
_pathCollider
.
transform
.
eulerAngles
=
new
Vector3
(
0
,
0
,
Mathf
.
Atan
(
float
)
Constants
.
RadianToDegree
(
Mathf
.
PI
/
2
+
(
square
.
GetTangent
(
Mathf
.
Atan
square
.
GetNthPath
(
n
)))));
(
square
.
GetTangent
(
square
.
GetNthPath
(
n
)))));
float
_newY
=
square
.
GetNthPath
(
n
).
magnitude
;
_pathCollider
.
transform
.
localScale
=
new
Vector3
(
2
,
_newY
*
_originalPathColliderY
,
0
);
float
_newY
=
square
.
GetNthPath
(
n
).
magnitude
;
_pathCollider
.
transform
.
localScale
=
new
Vector3
(
2
,
_newY
*
_originalPathColliderY
,
0
);
_pathCollider
.
transform
.
position
=
(
square
.
pathList
[
n
]
+
square
.
pathList
[
n
+
1
])
/
2
;
}
_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
);
}
}
This diff is collapsed.
Click to expand it.
Assets/Scripts/UIManager.cs
0 → 100644
View file @
a1e60091
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
UIManager
:
MonoBehaviour
{
public
GameObject
canvas
;
// Start is called before the first frame update
void
Start
()
{
}
// Update is called once per frame
void
Update
()
{
if
(
Input
.
GetMouseButtonDown
(
0
))
{
RaycastHit
hit
;
var
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
{
var
obj
=
hit
.
collider
.
gameObject
;
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
)
{
t
.
SetActive
(
false
);
}
else
{
t
.
SetActive
(
true
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Assets/Scripts/UIManager.cs.meta
0 → 100644
View file @
a1e60091
fileFormatVersion: 2
guid: 1f0e97ee5297ee342a4167b4fc9896dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
Click to expand it.
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