Commit 9159b7bc authored by Chae Ho Shin's avatar Chae Ho Shin

fix some shader bugs & make path info appear at mouse point

parent 5112f241
......@@ -50,7 +50,7 @@
float x1 = abs(worldPos.x - _PlanePosition.x);
float z1 = abs(worldPos.z - _PlanePosition.z);
float y1 = abs(_PlanePosition.y - worldPos.y);
bool wow = ((x1 * x1) + (z1 * z1)) < ((y1 + 0.05) * (y1 + 0.05)) && ((x1 * x1) + (z1 * z1)) > ((y1) * (y1));
bool wow = ((x1 * x1) + (z1 * z1)) < ((y1 + 0.08) * (y1 + 0.08)) && ((x1 * x1) + (z1 * z1)) > ((y1) * (y1));
//float dotProd1 = tmp.y;
return (worldPos.y > _PlanePosition.y) || !wow;
//float dotProd1 = dot(worldPos - _PlanePosition, _PlaneNormal);
......@@ -89,7 +89,7 @@
float x1 = abs(worldPos.x - _PlanePosition.x);
float z1 = abs(worldPos.z - _PlanePosition.z);
float y1 = abs(_PlanePosition.y - worldPos.y);
bool wow = ((x1 * x1) + (z1 * z1)) < ((y1 + 0.05) * (y1 + 0.05)) && ((x1 * x1) + (z1 * z1)) > ((y1) * (y1));
bool wow = ((x1 * x1) + (z1 * z1)) < ((y1 + 0.08) * (y1 + 0.08)) && ((x1 * x1) + (z1 * z1)) > ((y1) * (y1));
//float dotProd1 = tmp.y;
return (worldPos.y > _PlanePosition.y) || !wow;
//float dotProd1 = dot(worldPos - _PlanePosition, _PlaneNormal);
......
......@@ -26,7 +26,7 @@ RenderSettings:
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_SkyboxMaterial: {fileID: 2100000, guid: c586755a7c8d6af4bb1944882f90197c, type: 2}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
......@@ -652,7 +652,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
square: {fileID: 934514725}
canvas: {fileID: 1193230060}
playercamera: {fileID: 1661408489}
canvas: {fileID: 1193230064}
mytime: {fileID: 1678224219}
wintext: {fileID: 512200287}
_pathUI: {fileID: 1496132462}
......@@ -737,7 +738,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d99664edeab700d4ca972d282f99515b, type: 3}
m_Name:
m_EditorClassIdentifier:
time: 0.1
time: 0.02
leaveworldline: 1
--- !u!64 &439858919
MeshCollider:
......@@ -1549,7 +1550,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d99664edeab700d4ca972d282f99515b, type: 3}
m_Name:
m_EditorClassIdentifier:
time: 0.1
time: 0.02
leaveworldline: 1
--- !u!54 &839664888
Rigidbody:
......@@ -2265,7 +2266,7 @@ 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: -79.45, y: -10.800001}
m_AnchoredPosition: {x: -79.45001, y: -10.799988}
m_SizeDelta: {x: 99.9, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1034884447
......@@ -2966,7 +2967,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d99664edeab700d4ca972d282f99515b, type: 3}
m_Name:
m_EditorClassIdentifier:
time: 0.1
time: 0.02
leaveworldline: 1
--- !u!64 &1320474665
MeshCollider:
......@@ -3195,10 +3196,10 @@ RectTransform:
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -487.74, y: -318.42}
m_Pivot: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 164, y: 105}
m_SizeDelta: {x: 312.26, y: 132.57999}
m_Pivot: {x: 0, y: 0}
--- !u!1 &1661408487
GameObject:
m_ObjectHideFlags: 0
......@@ -3278,7 +3279,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1661408487}
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 5, z: 0}
m_LocalPosition: {x: 0, y: 50, z: 0}
m_LocalScale: {x: 1, y: 0.1000003, z: 1}
m_Children: []
m_Father: {fileID: 0}
......
......@@ -4,7 +4,7 @@ using UnityEngine;
public static class Constants
{
public static double c => 3; // speed of light.
public static double c => 5; // speed of light.
public static double Gamma(double v)
{
return 1.0f / Mathf.Sqrt((1 - (float)((v / c) * (v / c))));
......
......@@ -12,7 +12,7 @@ public class UIManager : MonoBehaviour
[SerializeField]
Camera playercamera;
public GameObject canvas;
public Canvas canvas;
public Text mytime;
//public Planemovement clock1;
//public Planemovement clock2;
......@@ -45,15 +45,16 @@ public class UIManager : MonoBehaviour
}
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
RaycastHit hit1;
RaycastHit hit2;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
if (Physics.Raycast(ray, out hit1))
{
ray = playercamera.ViewportPointToRay(hit.textureCoord);
if (Physics.Raycast(ray, out hit))
ray = playercamera.ViewportPointToRay(hit1.textureCoord);
if (Physics.Raycast(ray, out hit2))
{
var obj = hit.collider.gameObject;
var obj = hit2.collider.gameObject;
if (obj.tag == "path")
{
......@@ -63,8 +64,14 @@ public class UIManager : MonoBehaviour
{
pathName.text = obj.name;
//_pathUI.transform.position = middlePoint;
_pathUI.transform.position = middlePoint + (square.GetDestPoint(pathNum) + new Vector3(0, 300, 0)) * 2.5f;
//Debug.Log(square.GetMiddlePoint(pathNum, pathNum + 1));
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;
_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)
_pathUI.SetActive(true);
prevSelectPathNum = pathNum;
}
......
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