public void OnDrag(PointerEventData eventData) { Vector3 globalMousePos; RectTransform m_DraggingPlane = LabEnv.NodeLab.transform as RectTransform; if (m_labCamera != null && m_labCamera.ScreenPointToWorldPointInRectangle(m_DraggingPlane, eventData.position, out globalMousePos)) { if (PickupPos != globalMousePos) { Vector3 offset = globalMousePos - PickupPos; PickupPos = globalMousePos; bool result = CheckPositionInCamera(offset + transform.position); if (result) { List <NDlabObject> l = LabEnv.GetHighLightCircuitObject(); List <NDlabObject> list = new List <NDlabObject>(); list.AddRange(l); if (list.Count < 1) { list.Add(m_labObject); } LabObjectOperateCenter.NoticeObjToMove(list, offset); } } } }
private void SetDraggedPosition(PointerEventData data) { Vector3 globalMousePos; CameraType type = m_labObject != null && m_labObject is EleLine ? CameraType.WireCamera : CameraType.LabCamera; LabCamera carme = LabEnv.GetCameraByType(type); if (carme != null && carme.ScreenPointToWorldPointInRectangle(m_DraggingPlane, data.position, out globalMousePos)) { Vector3 org = m_DraggingItem.transform.position; globalMousePos = U3DUtil.SetZ(globalMousePos, m_DraggingItem.transform.position.z); m_DraggingItem.transform.position = globalMousePos; if (m_labObject != null && m_labObject is EleLine) { bool startOut = carme.CheckPositionInCamera((m_labObject as EleLine).m_LineAction.m_StartCtrl.transform.position); bool EndOut = carme.CheckPositionInCamera((m_labObject as EleLine).m_LineAction.m_EndCtrl.transform.position); if (!startOut || !EndOut) { m_DraggingItem.transform.position = org; } } else if (!carme.CheckPositionInCamera(globalMousePos)) { m_DraggingItem.transform.position = org; } } }
/// <summary> /// create lab object by click | drag way. /// </summary> /// <param name="createWay">0:Click 1:Drag</param> private GameObject CreateLabObj(int createWay) { if (m_PerfabName == "") { return(null); } GameObject obj = NDLoad.LoadPrefab(m_PerfabName, LabEnv.NodeLab.transform); if (obj == null) { return(null); } if (createWay == 0) { SetPosOffset(obj); SetPreCreateObjData(); } else { LabEnv.ResetPreCreateLabObj(); } NDCircuitObject o = obj.GetComponent <NDCircuitObject>(); if (o != null) { o.SetDefaultData(); o.SetGameobjectName(); } m_labObject = o; return(obj); }
void BtnDelClick() { if (m_curCirObj != null) { LabEnv.ClearAllHighlightLabObj(); m_curCirObj.DestroyLabObject(); } WndManager.DestoryWnd <ClickMenuWnd>(); NDCircuitObject.CreateCirCuit(); }
public static void DeleteSelecetEle() { List <NDlabObject> l = LabEnv.GetHighLightCircuitObject(); foreach (NDlabObject obj in l) { if (obj.PlayerState == false) { obj.DestroyLabObject(); } } LabEnv.ClearAllHighlightLabObj(); }
private void SetPreCreateObjData() { if (m_PerfabName != "") { if (LabEnv.PreCreateLabObjName != "") { if (LabEnv.PreCreateLabObjName != m_PerfabName) { LabEnv.ResetPreCreateLabObj(); } } LabEnv.PreCreateLabObjName = m_PerfabName; } }
void Start() { if (m_labObject == null) { m_labObject = GetComponent <NDlabObject>(); } if (m_labObject != null) { LabObjectOperateCenter.RegeditMove(this, m_labObject); if (m_labObject is EleLine) { m_labCamera = LabEnv.GetCameraByType(CameraType.WireCamera); } else { m_labCamera = LabEnv.GetCameraByType(CameraType.LabCamera); } } }
public void OnPointerClick(PointerEventData eventData) { if (eventData.button == PointerEventData.InputButton.Right) { return; } NDlabObject obj = GetComponent <NDlabObject>(); if (obj != null) { if (obj is EleLine) { LineAction action = obj.gameObject.GetComponent <LineAction>(); if (action) { action.SetControling(); } } if (eventData.clickCount == 2)//show the Menu UI { if (obj != null && obj.PlayerState == false) { ClickMenuWnd wnd = WndManager.GetWnd <ClickMenuWnd>(); if (wnd != null) { wnd.SetCurCircuitObject(obj as NDCircuitObject); wnd.BtnDel.transform.position = new Vector3(eventData.position.x, eventData.position.y, 0); } } } else if (eventData.clickCount == 1 && eventData.dragging == false && eventData.delta.x < 0.1f && eventData.delta.y < 0.1f) { LabEnv.AddHighlightLabObj(obj, ControlButtonDown); } } }
void OnDestroy() { LabEnv.Reset(); }
void OnEnable() { LabEnv.SetLabNode(this); }
void Awake() { m_camera = LabEnv.GetCameraByType(CameraType.WireCamera); }
// Use this for initialization void Start() { LabEnv.RegisterCamera(this); }
void OnDestroy() { LabEnv.UnRegisterCamera(this); }
void Start() { InitCtrlLine(); wireCamera = LabEnv.GetCameraByType(CameraType.WireCamera); }