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
b3dc240e
Commit
b3dc240e
authored
5 years ago
by
18김민수
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a minot feature for PathRenderer to interact with mouse clicks - 1
parent
4cd68997
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
2 deletions
+155
-2
SampleScene.unity
Assets/Scenes/SampleScene.unity
+107
-1
Constants.cs
Assets/Scripts/Constants.cs
+5
-0
PathRenderer.cs
Assets/Scripts/PathRenderer.cs
+33
-1
Square.cs
Assets/Scripts/Square.cs
+10
-0
No files found.
Assets/Scenes/SampleScene.unity
View file @
b3dc240e
...
...
@@ -371,6 +371,7 @@ GameObject:
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
818789543
}
-
component
:
{
fileID
:
818789541
}
-
component
:
{
fileID
:
818789542
}
m_Layer
:
0
m_Name
:
PathRenderer
...
...
@@ -379,6 +380,20 @@ GameObject:
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!114
&818789541
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
818789540
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
8f30fcfb85a9c704291c91129b0b8f0c
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
square
:
{
fileID
:
1577789449
}
PathCollider
:
{
fileID
:
1059381751
}
---
!u!120
&818789542
LineRenderer
:
m_ObjectHideFlags
:
0
...
...
@@ -488,6 +503,98 @@ Transform:
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
2
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!1
&1059381751
GameObject
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
1059381755
}
-
component
:
{
fileID
:
1059381754
}
-
component
:
{
fileID
:
1059381753
}
-
component
:
{
fileID
:
1059381752
}
m_Layer
:
0
m_Name
:
PathCollider
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!136
&1059381752
CapsuleCollider
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1059381751
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_Enabled
:
1
m_Radius
:
0.5
m_Height
:
2
m_Direction
:
1
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!23
&1059381753
MeshRenderer
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1059381751
}
m_Enabled
:
1
m_CastShadows
:
1
m_ReceiveShadows
:
1
m_DynamicOccludee
:
1
m_MotionVectors
:
1
m_LightProbeUsage
:
1
m_ReflectionProbeUsage
:
1
m_RenderingLayerMask
:
1
m_RendererPriority
:
0
m_Materials
:
-
{
fileID
:
10303
,
guid
:
0000000000000000f000000000000000
,
type
:
0
}
m_StaticBatchInfo
:
firstSubMesh
:
0
subMeshCount
:
0
m_StaticBatchRoot
:
{
fileID
:
0
}
m_ProbeAnchor
:
{
fileID
:
0
}
m_LightProbeVolumeOverride
:
{
fileID
:
0
}
m_ScaleInLightmap
:
1
m_PreserveUVs
:
0
m_IgnoreNormalsForChartDetection
:
0
m_ImportantGI
:
0
m_StitchLightmapSeams
:
1
m_SelectedEditorRenderState
:
3
m_MinimumChartSize
:
4
m_AutoUVMaxDistance
:
0.5
m_AutoUVMaxAngle
:
89
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingOrder
:
0
---
!u!33
&1059381754
MeshFilter
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1059381751
}
m_Mesh
:
{
fileID
:
10208
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
---
!u!4
&1059381755
Transform
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1059381751
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
-15.01
,
y
:
5
,
z
:
-1
}
m_LocalScale
:
{
x
:
2
,
y
:
0.5
,
z
:
0
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
4
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!1
&1577789448
GameObject
:
m_ObjectHideFlags
:
0
...
...
@@ -522,7 +629,6 @@ MonoBehaviour:
speedVector
:
{
x
:
0
,
y
:
0
}
gameSpeed
:
20
properTime
:
0
pathRenderer
:
{
fileID
:
818789542
}
pathList
:
[]
---
!u!212
&1577789450
SpriteRenderer
:
...
...
This diff is collapsed.
Click to expand it.
Assets/Scripts/Constants.cs
View file @
b3dc240e
...
...
@@ -9,4 +9,9 @@ public static class Constants
{
return
1
/
Mathf
.
Sqrt
((
1
-
(
float
)((
v
/
c
)
*
(
v
/
c
))));
}
public
static
double
RadianToDegree
(
double
r
)
{
return
r
*
180
/
Mathf
.
PI
;
}
}
This diff is collapsed.
Click to expand it.
Assets/Scripts/PathRenderer.cs
View file @
b3dc240e
...
...
@@ -2,18 +2,23 @@
using
System.Collections.Generic
;
using
UnityEngine
;
using
System.Linq
;
using
System
;
public
class
PathRenderer
:
MonoBehaviour
{
[
SerializeField
]
Square
square
;
[
SerializeField
]
GameObject
PathCollider
;
LineRenderer
_pathRenderer
;
float
_zPosition
=>
square
.
transform
.
position
.
z
;
float
_originalPathColliderY
;
// Start is called before the first frame update
void
Start
()
{
_originalPathColliderY
=
PathCollider
.
transform
.
localScale
.
y
;
_pathRenderer
=
GetComponent
<
LineRenderer
>();
_ResetPaths
();
}
...
...
@@ -39,6 +44,17 @@ public class PathRenderer : MonoBehaviour
}
}
}
if
(
Input
.
GetMouseButtonDown
(
0
))
{
RaycastHit
hit
;
var
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
{
Debug
.
Log
(
hit
.
collider
.
gameObject
.
name
);
}
}
}
private
void
_DrawOnePath
(
Vector3
point
)
...
...
@@ -48,6 +64,7 @@ public class PathRenderer : MonoBehaviour
square
.
pathList
[
0
]
=
transform
.
position
;
square
.
pathList
[
1
]
=
point
;
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
_modifyCapsule
();
}
private
void
_ResetPaths
()
...
...
@@ -66,4 +83,19 @@ public class PathRenderer : MonoBehaviour
_pathRenderer
.
positionCount
=
square
.
pathList
.
Count
();
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
}
private
void
_modifyCapsule
()
{
PathCollider
.
transform
.
localScale
=
new
Vector3
(
2
,
_originalPathColliderY
,
0
);
PathCollider
.
transform
.
eulerAngles
=
new
Vector3
(
0
,
0
,
(
float
)
Constants
.
RadianToDegree
(
Mathf
.
PI
/
2
+
Mathf
.
Atan
(
square
.
GetTangent
(
square
.
GetNthPath
(
0
)))));
float
_newY
=
square
.
GetNthPath
(
0
).
magnitude
;
PathCollider
.
transform
.
localScale
=
new
Vector3
(
2
,
_newY
*
_originalPathColliderY
,
0
);
PathCollider
.
transform
.
position
=
square
.
GetNthPath
(
0
)
/
2
;
}
}
This diff is collapsed.
Click to expand it.
Assets/Scripts/Square.cs
View file @
b3dc240e
...
...
@@ -8,4 +8,14 @@ public class Square : FlatLandObject
{
public
List
<
Vector3
>
pathList
=
new
List
<
Vector3
>();
private
float
_zPosition
=>
transform
.
position
.
z
;
public
Vector3
GetNthPath
(
int
n
)
// Get a path from (n)th destination to (n+1)th destination.
{
return
pathList
[
n
+
1
]
-
pathList
[
n
];
}
public
float
GetTangent
(
Vector3
v
)
{
return
v
.
y
/
v
.
x
;
}
}
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