Commit 4c5084b2 authored by 17김현학's avatar 17김현학

Fix the bug(Issue #18)

Add Slider(Velocity, acceleration), button, text (No coding)
parent 66191322
...@@ -8,17 +8,17 @@ GameObject: ...@@ -8,17 +8,17 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 6021508400235234100} - component: {fileID: 5014434788102240908}
- component: {fileID: 6021508400235234098} - component: {fileID: 5427705129206684837}
- component: {fileID: 6021508400235234099} - component: {fileID: 5981043734760163717}
m_Layer: 5 m_Layer: 0
m_Name: PathUI m_Name: PathUI
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!224 &6021508400235234100 --- !u!224 &5014434788102240908
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
...@@ -35,9 +35,9 @@ RectTransform: ...@@ -35,9 +35,9 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0} 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} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6021508400235234098 --- !u!222 &5427705129206684837
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
...@@ -45,7 +45,7 @@ CanvasRenderer: ...@@ -45,7 +45,7 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6021508400235234101} m_GameObject: {fileID: 6021508400235234101}
m_CullTransparentMesh: 0 m_CullTransparentMesh: 0
--- !u!114 &6021508400235234099 --- !u!114 &5981043734760163717
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
...@@ -54,23 +54,28 @@ MonoBehaviour: ...@@ -54,23 +54,28 @@ MonoBehaviour:
m_GameObject: {fileID: 6021508400235234101} m_GameObject: {fileID: 6021508400235234101}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} 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_RaycastTarget: 1
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 0905f15ba4c169d478723617ce3c4ad1, type: 3} m_FontData:
m_Type: 0 m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_PreserveAspect: 0 m_FontSize: 6
m_FillCenter: 1 m_FontStyle: 0
m_FillMethod: 4 m_BestFit: 0
m_FillAmount: 1 m_MinSize: 1
m_FillClockwise: 1 m_MaxSize: 40
m_FillOrigin: 0 m_Alignment: 0
m_UseSpriteMesh: 0 m_AlignByGeometry: 0
m_RichText: 0
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
This diff is collapsed.
...@@ -12,9 +12,6 @@ public class PathRenderer : MonoBehaviour ...@@ -12,9 +12,6 @@ public class PathRenderer : MonoBehaviour
[SerializeField] [SerializeField]
GameObject PathColliderPrefab; GameObject PathColliderPrefab;
public GameObject canvas;
public GameObject pathUIPrefab;
LineRenderer _pathRenderer; LineRenderer _pathRenderer;
float _originalPathColliderY; float _originalPathColliderY;
// Start is called before the first frame update // Start is called before the first frame update
...@@ -55,7 +52,6 @@ public class PathRenderer : MonoBehaviour ...@@ -55,7 +52,6 @@ public class PathRenderer : MonoBehaviour
square.pathList[1] = point; square.pathList[1] = point;
_pathRenderer.SetPositions(square.pathList.ToArray()); _pathRenderer.SetPositions(square.pathList.ToArray());
_InstantiatePathCollider(0); _InstantiatePathCollider(0);
_InstantiatePathUI(0, point/2);
} }
private void _ResetPaths() private void _ResetPaths()
...@@ -68,9 +64,6 @@ public class PathRenderer : MonoBehaviour ...@@ -68,9 +64,6 @@ public class PathRenderer : MonoBehaviour
for (int i = 0; i < transform.childCount; i++) for (int i = 0; i < transform.childCount; i++)
{ {
Destroy(transform.GetChild(i).gameObject); 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 ...@@ -80,7 +73,6 @@ public class PathRenderer : MonoBehaviour
_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)
...@@ -100,14 +92,4 @@ public class PathRenderer : MonoBehaviour ...@@ -100,14 +92,4 @@ public class PathRenderer : MonoBehaviour
_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);
}
} }
...@@ -7,7 +7,9 @@ using System.Linq; ...@@ -7,7 +7,9 @@ using System.Linq;
public class Square : FlatLandObject public class Square : FlatLandObject
{ {
public List<Vector3> pathList = new List<Vector3>(); public List<Vector3> pathList = new List<Vector3>();
public List<float> pathVelocity = new List<float>();
private float _zPosition => transform.position.z; 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. 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 ...@@ -18,4 +20,9 @@ public class Square : FlatLandObject
{ {
return v.y / v.x; return v.y / v.x;
} }
}
public Vector3 GetMiddlePoint(int st, int en)
{
return (pathList[en] - pathList[st]) / 2;
}
}
\ No newline at end of file
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using System;
using System.Linq;
public class UIManager : MonoBehaviour public class UIManager : MonoBehaviour
{ {
[SerializeField]
Square square;
public GameObject canvas; public GameObject canvas;
public GameObject pathUIPrefab;
private GameObject _pathUI;
private int prevSelectPathNum = -1;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
_InstantiatePathUI();
_pathUI.SetActive(false);
} }
// Update is called once per frame // Update is called once per frame
...@@ -26,19 +37,33 @@ public class UIManager : MonoBehaviour ...@@ -26,19 +37,33 @@ public class UIManager : MonoBehaviour
if (obj.tag == "path") if (obj.tag == "path")
{ {
int pathNum = int.Parse(obj.name.Substring(13)); int pathNum = int.Parse(obj.name.Substring(13));
string str = "PathUI-" + pathNum;
GameObject t = canvas.transform.FindChild(str).gameObject; if (pathNum != prevSelectPathNum)
if (t.activeSelf == true)
{ {
t.SetActive(false); _pathUI.GetComponent<Text>().text = obj.name;
_pathUI.SetActive(true);
prevSelectPathNum = pathNum;
} }
else 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";
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment