添加双击
This commit is contained in:
parent
adff1ae9b0
commit
6fb4e3e2b7
File diff suppressed because it is too large
Load Diff
|
|
@ -79,6 +79,7 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
public List<DependencyLevel> dependencyLevel = new List<DependencyLevel>();
|
||||
|
||||
public int clickCurrentLevel = 2;
|
||||
private RaycastHit hit;
|
||||
[ContextMenu("1")]
|
||||
private void Awake()
|
||||
{
|
||||
|
|
@ -108,35 +109,19 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
{
|
||||
//landMarks = new List<string> { "网络负荷:49.84 kw", "上网负荷:49.84 kw", "削峰负荷:49.84 kw", "填谷负荷:49.84 kw", "发电负荷:49.84 kw" };
|
||||
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
||||
cameraRt.OnLimitScroll += (s) =>
|
||||
cameraRt.onLimitScroll += (s) =>
|
||||
{
|
||||
SwitchLand(s);
|
||||
webAdapter.OnLevelChange(s);
|
||||
};
|
||||
|
||||
cameraRt.onLeftMouseDown += OnLeftClick;
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var hit = rayHitTester.HitTest();
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
if (hit.collider != null)
|
||||
{
|
||||
Debug.Log("clickCurrentLevel==" + clickCurrentLevel);
|
||||
if (cameraRt.currentLevelIndex == 0) return;
|
||||
clickCurrentLevel--;
|
||||
if (clickCurrentLevel <= 0)
|
||||
{
|
||||
clickCurrentLevel = 0;
|
||||
}
|
||||
cameraRt.currentLevelIndex = clickCurrentLevel;
|
||||
//currentLevel = clickCurrentLevel;
|
||||
SwitchLand(clickCurrentLevel);
|
||||
cameraRt.SetTarget(hit.collider.transform);
|
||||
}
|
||||
}
|
||||
hit = rayHitTester.HitTest();
|
||||
|
||||
if (hit.collider != null)
|
||||
{
|
||||
landMarks.Clear();
|
||||
|
|
@ -156,13 +141,31 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
|
||||
}
|
||||
|
||||
public void OnLeftClick()
|
||||
{
|
||||
if (hit.collider != null)
|
||||
{
|
||||
Debug.Log("clickCurrentLevel==" + clickCurrentLevel);
|
||||
if (cameraRt.currentLevelIndex == 0) return;
|
||||
clickCurrentLevel--;
|
||||
if (clickCurrentLevel <= 0)
|
||||
{
|
||||
clickCurrentLevel = 0;
|
||||
}
|
||||
cameraRt.currentLevelIndex = clickCurrentLevel;
|
||||
//currentLevel = clickCurrentLevel;
|
||||
SwitchLand(clickCurrentLevel);
|
||||
cameraRt.SetTarget(hit.collider.transform);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 展示地标
|
||||
/// </summary>
|
||||
/// <param name="land"></param>
|
||||
public async void ShowLandMark()
|
||||
public void ShowLandMark()
|
||||
{
|
||||
if (currentLand == null) return;
|
||||
currentLand.GetComponent<MeshRenderer>().materials = select;
|
||||
|
|
@ -170,7 +173,8 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
|||
lastLand = currentLand;
|
||||
SwitchLevel(-1);
|
||||
AreaData areaData = currentLand.GetComponent<CityInfo>().areaData;
|
||||
if (areaData != null && !bool.Parse(areaData.success)) return;
|
||||
|
||||
if (areaData != null && !string.IsNullOrEmpty(areaData.success) && !bool.Parse(areaData.success)) return;
|
||||
for (int i = 0; i < areaData.data.items.Count; i++)
|
||||
{
|
||||
string info = $"{areaData.data.items[i].label}:{areaData.data.items[i].value}{areaData.data.items[i].unit}";
|
||||
|
|
|
|||
|
|
@ -179,20 +179,46 @@ public class CameraRT : MonoBehaviour
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 startPosition;
|
||||
private bool isDragging;
|
||||
public Action onLeftMouseDown;
|
||||
void Move()
|
||||
{
|
||||
if (EventSystem.current.IsPointerOverGameObject())
|
||||
return;
|
||||
|
||||
if (Input.GetMouseButton(0))
|
||||
//if (EventSystem.current.IsPointerOverGameObject())
|
||||
// return;
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
startPosition = Input.mousePosition;
|
||||
isDragging = false;
|
||||
}
|
||||
else if (Input.GetMouseButton(0))
|
||||
{
|
||||
if (!isDragging && Vector3.Distance(Input.mousePosition, startPosition) > 10)
|
||||
{
|
||||
isDragging = true;
|
||||
Debug.Log("Started dragging.");
|
||||
}
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
if (isDragging)
|
||||
{
|
||||
Debug.Log("Ended dragging.");
|
||||
}
|
||||
else
|
||||
{
|
||||
onLeftMouseDown?.Invoke();
|
||||
Debug.Log("Clicked.");
|
||||
}
|
||||
isDragging = false;
|
||||
}
|
||||
if (isDragging)
|
||||
{
|
||||
float h = Input.GetAxis("Mouse X") * Time.deltaTime * xSpeed_move;
|
||||
float v = Input.GetAxis("Mouse Y") * Time.deltaTime * ySpeed_move;
|
||||
|
||||
target.Translate(-h, 0, -v);
|
||||
|
||||
|
||||
if (!isRangeClamped)
|
||||
return;
|
||||
float targetX = target.position.x;
|
||||
|
|
@ -202,6 +228,10 @@ public class CameraRT : MonoBehaviour
|
|||
|
||||
target.position = new Vector3(targetX, target.position.y, targetZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Rotate()
|
||||
|
|
@ -226,7 +256,7 @@ public class CameraRT : MonoBehaviour
|
|||
}
|
||||
|
||||
|
||||
public Action<int> OnLimitScroll;
|
||||
public Action<int> onLimitScroll;
|
||||
public int currentLevelIndex = 2;
|
||||
public int lastLevelIndex = 2;
|
||||
void Scroll()
|
||||
|
|
@ -248,7 +278,7 @@ public class CameraRT : MonoBehaviour
|
|||
if (currentLevelIndex != lastLevelIndex)
|
||||
{
|
||||
Debug.Log($"UnityLog=currentLevelIndex=={currentLevelIndex}");
|
||||
OnLimitScroll?.Invoke(currentLevelIndex);
|
||||
onLimitScroll?.Invoke(currentLevelIndex);
|
||||
lastLevelIndex = currentLevelIndex;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue