From eea59757d9583a6474eae8ffd70afdced29f1683 Mon Sep 17 00:00:00 2001 From: yulong <1838206582@qq.com> Date: Fri, 22 Mar 2024 14:48:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Temp/Scripts/Doubleclickdelete.cs | 62 +++++++++++++++++------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/Assets/Temp/Scripts/Doubleclickdelete.cs b/Assets/Temp/Scripts/Doubleclickdelete.cs index 353ec8a3..8de87e4d 100644 --- a/Assets/Temp/Scripts/Doubleclickdelete.cs +++ b/Assets/Temp/Scripts/Doubleclickdelete.cs @@ -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(); + } @@ -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(); + // 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(); + 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; } } } + }