Esempio n. 1
0
        /// <summary>
        /// 用户拖动组件
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件</param>
        private void listView2_ItemDrag(object sender, ItemDragEventArgs e)
        {
            dragItem = e.Item;
            view     = DragView.view2;
            string strItem = e.Item.ToString();

            //开始进行"Drag"操作
            DoDragDrop(strItem, DragDropEffects.Move);
        }
Esempio n. 2
0
    void Start()
    {
        canChangeItem = true;
        int count = listEnhanceItems.Count;

        dFactor      = (Mathf.RoundToInt((1f / count) * 10000f)) * 0.0001f;
        mCenterIndex = count / 2;
        if (count % 2 == 0)
        {
            mCenterIndex = count / 2 - 1;
        }
        int index = 0;

        for (int i = count - 1; i >= 0; i--)
        {
            listEnhanceItems[i].CurveOffSetIndex = i;
            listEnhanceItems[i].CenterOffSet     = dFactor * (mCenterIndex - index);
            listEnhanceItems[i].SetSelectState(false);
            GameObject obj = listEnhanceItems[i].gameObject;

            DragView script = obj.GetComponent <DragView>();
            if (script != null)
            {
                script.SetScrollView(this);
            }
            index++;
        }

        // set the center item with startCenterIndex
        if (startCenterIndex < 0 || startCenterIndex >= count)
        {
            Debug.LogError("## startCenterIndex < 0 || startCenterIndex >= listEnhanceItems.Count  out of index ##");
            startCenterIndex = mCenterIndex;
        }

        // sorted items
        listSortedItems      = new List <ScrollViewItem>(listEnhanceItems.ToArray());
        totalHorizontalWidth = cellWidth * count;
        curCenterItem        = listEnhanceItems[startCenterIndex];
        curHorizontalValue   = 0.5f - curCenterItem.CenterOffSet;
        LerpTweenToTarget(0f, curHorizontalValue, false);

        //
        // enable the drag actions
        //
        EnableDrag(true);
    }
Esempio n. 3
0
    public GameObject RayCast(Camera cam, Vector3 inPos)
    {
        Vector3 pos = cam.ScreenToViewportPoint(inPos);

        if (float.IsNaN(pos.x) || float.IsNaN(pos.y))
        {
            return(null);
        }
        if (pos.x < 0f || pos.x > 1f || pos.y < 0f || pos.y > 1f)
        {
            return(null);
        }

        Ray   ray = cam.ScreenPointToRay(inPos);
        float dis = 100f;

        RaycastHit[] hits = Physics.RaycastAll(ray, dis, rayCastMask);
        if (hits.Length > 0)
        {
            for (int i = 0; i < hits.Length; i++)
            {
                GameObject go       = hits[i].collider.gameObject;
                DragView   dragView = go.GetComponent <DragView>();
                if (dragView == null)
                {
                    continue;
                }
                else
                {
                    // 只需返回当前悬停对象
                    return(go);
                }
            }
        }
        return(null);
    }
Esempio n. 4
0
 /// <summary>
 /// 用户拖动组件
 /// </summary>
 /// <param name="sender">事件发送者</param>
 /// <param name="e">事件</param>
 private void listView2_ItemDrag(object sender, ItemDragEventArgs e)
 {
     dragItem = e.Item;
     view = DragView.view2;
     string strItem = e.Item.ToString();
     //开始进行"Drag"操作
     DoDragDrop(strItem, DragDropEffects.Move);
 }
Esempio n. 5
0
 private void Awake()
 {
     DragInstance = this;
     canvasParent = GameObject.FindGameObjectWithTag("Canvas");
 }