This commit is contained in:
yulong 2024-03-22 14:48:55 +08:00
parent cd741d461e
commit eea59757d9
1 changed files with 44 additions and 18 deletions

View File

@ -1,4 +1,5 @@
using System;
using DataModel.Model;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
@ -14,10 +15,9 @@ public class Doubleclickdelete : MonoBehaviour
public int count;//用来判断点击了几下
public float interval = 0.2f;//用来判断双击间隔时间
private bool iscount = true;//用来判断的是单机还是双击
public Scenariopage scenariopage;
void Start()
{
scenariopage = GetComponent<Scenariopage>();
}
@ -66,24 +66,47 @@ public class Doubleclickdelete : MonoBehaviour
RaycastHit hit;
if (Physics.Raycast(ray, out hit, Mathf.Infinity))
{
if (hit.collider.gameObject.tag == "model")
if (hit.collider.gameObject.tag=="model")
{
if (DragManager.Instance.devices.Count > 0)
Modeldeletion(hit.collider.gameObject);
//if (DragManager.Instance.devices.Count > 0)
//{
// Scenariopage scenariopage = GetComponent<Scenariopage>();
// for (int i = 0; i < DragManager.Instance.devices.Count; i++)
// {
// int index = i;
// if (hit.collider.gameObject.name == DragManager.Instance.devices[index].name)
// {
// Destroy(DragManager.Instance.devices[index].gameObject);
// DragManager.Instance.devices.RemoveAt(index);
// if (scenariopage.properties.Count > 0)
// {
// Deletebutton(scenariopage,DragManager.Instance.devices[index].gameObject.name);
// }
// break;
// }
// }
//}
}
}
}
private void Modeldeletion(GameObject gameObject)
{
Scenariopage scenariopage = GetComponent<Scenariopage>();
for (int i = 0; i < DragManager.Instance.devices.Count; i++)
{
int index = i;
if (gameObject.name == DragManager.Instance.devices[index].name)
{
Destroy(DragManager.Instance.devices[index].gameObject);
DragManager.Instance.devices.RemoveAt(index);
if (scenariopage.properties.Count > 0)
{
for (int i = 0; i < DragManager.Instance.devices.Count; i++)
{
int index = i;
if (hit.collider.gameObject.name == DragManager.Instance.devices[index].name)
{
Destroy(DragManager.Instance.devices[index].gameObject);
if (scenariopage.properties.Count > 0)
{
Deletebutton(scenariopage, DragManager.Instance.devices[index].gameObject.name);
}
}
}
Deletebutton(scenariopage, DragManager.Instance.devices[index].gameObject.name);
}
break;
}
}
}
@ -97,8 +120,11 @@ public class Doubleclickdelete : MonoBehaviour
if (scenariopage.properties[index].name == name)
{
Destroy(scenariopage.properties[index].gameObject);
scenariopage.properties.RemoveAt(index);
break;
}
}
}
}