This commit is contained in:
parent
a93c6bbd4c
commit
7b46f3e11b
|
@ -2,6 +2,7 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityEngine.UI;
|
||||||
//============================================================
|
//============================================================
|
||||||
//支持中文,文件使用UTF-8编码
|
//支持中文,文件使用UTF-8编码
|
||||||
//@author #AUTHOR#
|
//@author #AUTHOR#
|
||||||
|
@ -17,19 +18,64 @@ public class DeviceItem : MonoBehaviour
|
||||||
|
|
||||||
public int startIndex;
|
public int startIndex;
|
||||||
public int volume;
|
public int volume;
|
||||||
public DragTest1 oriPrefab;
|
public DragTest oriPrefab;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
public void Init(DeviceManager _deviceManager, int _startIndex, int _volume, DragTest1 _dtPrefab)
|
public MeshRenderer _mesh = null;
|
||||||
|
public void Init(DeviceManager _deviceManager, int _startIndex, int _volume, DragTest _dtPrefab)
|
||||||
{
|
{
|
||||||
gameObject.AddComponent<BoxCollider>();
|
|
||||||
|
BoxCollider boxCollider = GetComponent<BoxCollider>();
|
||||||
|
if (!boxCollider)
|
||||||
|
{
|
||||||
|
if (gameObject.GetComponent<MeshRenderer>() != null)
|
||||||
|
{
|
||||||
|
_mesh = gameObject.GetComponent<MeshRenderer>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_mesh = transform.GetChild(0).GetComponent<MeshRenderer>();
|
||||||
|
}
|
||||||
|
if (_mesh != null)
|
||||||
|
{
|
||||||
|
var initrot = transform.rotation;
|
||||||
|
transform.rotation = Quaternion.identity;
|
||||||
|
|
||||||
|
var bounds = _mesh.bounds;
|
||||||
|
var a = transform.gameObject.AddComponent<BoxCollider>();
|
||||||
|
a.isTrigger = false;
|
||||||
|
a.center = bounds.center - transform.position;
|
||||||
|
|
||||||
|
a.size = bounds.size;
|
||||||
|
|
||||||
|
transform.rotation = initrot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
gameObject.AddComponent<ClickEvent>();
|
||||||
|
|
||||||
|
//gameObject.AddComponent<BoxCollider>();
|
||||||
deviceManager = _deviceManager;
|
deviceManager = _deviceManager;
|
||||||
startIndex = _startIndex;
|
startIndex = _startIndex;
|
||||||
volume = _volume;
|
volume = _volume;
|
||||||
oriPrefab = _dtPrefab;
|
oriPrefab = _dtPrefab;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMouseDown()
|
//private void OnMouseDown()
|
||||||
|
//{
|
||||||
|
// if (!EventSystem.current.IsPointerOverGameObject())
|
||||||
|
// {
|
||||||
|
// Vector3 pos = Input.mousePosition;
|
||||||
|
// deviceManager.SetMenuValue(pos, this, oriPrefab);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
public void OnselfClick()
|
||||||
{
|
{
|
||||||
if (!EventSystem.current.IsPointerOverGameObject())
|
if (!EventSystem.current.IsPointerOverGameObject())
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class DeviceManager : MonoBehaviour
|
||||||
deviceItems.Add(deviceItem);
|
deviceItems.Add(deviceItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetMenuValue(Vector3 pos, DeviceItem di, DragTest1 dtPrefab)
|
public void SetMenuValue(Vector3 pos, DeviceItem di, DragTest dtPrefab)
|
||||||
{
|
{
|
||||||
editorMenu.gameObject.SetActive(true);
|
editorMenu.gameObject.SetActive(true);
|
||||||
Vector2 uiLocalPos;
|
Vector2 uiLocalPos;
|
||||||
|
|
|
@ -15,15 +15,15 @@ using UnityEngine.EventSystems;
|
||||||
public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler
|
public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
public DragTest1 oriObjectPrefab;
|
public DragTest oriObjectPrefab;
|
||||||
private DragTest1 targetObject;
|
private DragTest targetObject;
|
||||||
private UPosItem currentUPosItem;
|
private UPosItem currentUPosItem;
|
||||||
|
|
||||||
public Func<bool> DragCondition;
|
public Func<bool> DragCondition;
|
||||||
public Action<DragTest1> DragAction;
|
public Action<DragTest> DragAction;
|
||||||
|
|
||||||
public Action<DragTest1> BeginDragAction;
|
public Action<DragTest> BeginDragAction;
|
||||||
public Action<DragTest1> EndDragAction;
|
public Action<DragTest> EndDragAction;
|
||||||
|
|
||||||
//public DragTest1 currentDevice;
|
//public DragTest1 currentDevice;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler,
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dt"></param>
|
/// <param name="dt"></param>
|
||||||
/// <param name="index">机位号码,从0开始</param>
|
/// <param name="index">机位号码,从0开始</param>
|
||||||
public bool CountUPos(DragTest1 dt, int index)
|
public bool CountUPos(DragTest dt, int index)
|
||||||
{
|
{
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
|
@ -138,10 +138,10 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler,
|
||||||
private void OnRay(GameObject target)
|
private void OnRay(GameObject target)
|
||||||
{
|
{
|
||||||
currentUPosItem = null;
|
currentUPosItem = null;
|
||||||
target.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 5));
|
target.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition + new Vector3(0, 0, 2));
|
||||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||||
RaycastHit hitInfo;
|
RaycastHit hitInfo;
|
||||||
if (Physics.Raycast(ray, out hitInfo))
|
if (Physics.Raycast(ray, out hitInfo,100, 1 << 10))
|
||||||
{
|
{
|
||||||
if (hitInfo.collider != null && hitInfo.collider.GetComponent<UPosItem>())
|
if (hitInfo.collider != null && hitInfo.collider.GetComponent<UPosItem>())
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class UPosItem : MonoBehaviour
|
||||||
[ContextMenu("Set")]
|
[ContextMenu("Set")]
|
||||||
public void SetValue()
|
public void SetValue()
|
||||||
{
|
{
|
||||||
//instruct = Instantiate(Resources.Load<SpriteRenderer>("Adam/Instruct"), transform);
|
instruct = Instantiate(Resources.Load<SpriteRenderer>("Adam/Instruct"), transform);
|
||||||
//DestroyImmediate(transform.GetChild(0).gameObject);
|
//DestroyImmediate(transform.GetChild(0).gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -544,13 +544,14 @@ public class GameManager : MonoBehaviour
|
||||||
go.name = Racks[i].id;
|
go.name = Racks[i].id;
|
||||||
if (!go.GetComponent<ClickEvent>())
|
if (!go.GetComponent<ClickEvent>())
|
||||||
go.AddComponent<ClickEvent>();
|
go.AddComponent<ClickEvent>();
|
||||||
go.GetComponent<DragTest>().isplace = true;
|
|
||||||
|
//go.GetComponent<DragTest>().isplace = true;
|
||||||
go.transform.SetParent(item.transform.Find("U位/" + U));
|
go.transform.SetParent(item.transform.Find("U位/" + U));
|
||||||
go.GetComponent<DragTest>().isplace = true;
|
//go.GetComponent<DragTest>().isplace = true;
|
||||||
Array.ForEach(go.transform.GetComponentsInChildren<DragTest>(), (item) =>
|
//Array.ForEach(go.transform.GetComponentsInChildren<DragTest>(), (item) =>
|
||||||
{
|
//{
|
||||||
item.enabled = false;
|
// item.enabled = false;
|
||||||
});
|
//});
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,8 +129,8 @@ public class ClickEvent : MonoBehaviour
|
||||||
|
|
||||||
GameManager.Inst.nowDeviceID = d.deviceList.id;
|
GameManager.Inst.nowDeviceID = d.deviceList.id;
|
||||||
GameManager.Inst.nowDevice = gameObject;
|
GameManager.Inst.nowDevice = gameObject;
|
||||||
|
gameObject.GetComponent<DeviceItem>().OnselfClick();
|
||||||
PatternChoose.Inst.transform.Find("设备类/设备配置").gameObject.SetActive(true);//√
|
//PatternChoose.Inst.transform.Find("设备类/设备配置").gameObject.SetActive(true);//√
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ public class TransparentGlowManage : MonoBehaviour
|
||||||
{
|
{
|
||||||
ClickEvent clickEvent = item.GetComponent<ClickEvent>();
|
ClickEvent clickEvent = item.GetComponent<ClickEvent>();
|
||||||
BoxCollider boxCollider = item.GetComponent<BoxCollider>();
|
BoxCollider boxCollider = item.GetComponent<BoxCollider>();
|
||||||
|
DeviceItem deviceItem= item.GetComponent<DeviceItem>();
|
||||||
//CabinetInfor cabinetInfor = item.GetComponent<CabinetInfor>();
|
//CabinetInfor cabinetInfor = item.GetComponent<CabinetInfor>();
|
||||||
//Transform U = item.Find("U位");
|
//Transform U = item.Find("U位");
|
||||||
|
|
||||||
|
@ -141,7 +142,8 @@ public class TransparentGlowManage : MonoBehaviour
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!deviceItem)
|
||||||
|
item.gameObject.AddComponent<DeviceItem>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue