コード例 #1
0
    protected GesturePointer GetPointer(GameObject p, bool isMultiPoints = false)
    {
        if (p == null)
        {
            return(null);
        }
        GesturePointer newPointer = new GesturePointer();

        newPointer.isMultiPoints = isMultiPoints;
        newPointer.body          = Instantiate(p);
        for (int i = 0; i <= longPressBorder.Count; i++)
        {
            Transform bodyTran = newPointer.body.transform.Find(Common.CO.LEVEL_PREFIX + i.ToString());
            if (bodyTran == null)
            {
                newPointer.levelBodyList.Add(null);
                newPointer.levelLineList.Add(null);
                continue;
            }
            newPointer.levelBodyList.Add(bodyTran.gameObject);
            LineRenderer line = bodyTran.GetComponentInChildren <LineRenderer>();
            newPointer.levelLineList.Add(line);
        }
        newPointer.ResetLevelLine();
        newPointer.body.SetActive(false);
        return(newPointer);
    }
コード例 #2
0
    //通常時,ドラッグ時ポインター
    protected void SetPointer(Vector2 pos = default(Vector2))
    {
        if (Common.FUNC.IsNanVector(pos))
        {
            return;
        }

        if (isLongPressing || isTransform)
        {
            endPoint = pos;
        }
        else
        {
            startPoint = pos;
        }

        if (pointerObj == null || pointerObj.body == null)
        {
            return;
        }

        if (pos == default(Vector2))
        {
            //off
            pointerObj.body.SetActive(false);
            if (pointerStartObj != null)
            {
                pointerStartObj.body.SetActive(false);
                pointerStartObj.ResetLevelLine();
            }
            if (pointerLongObj != null)
            {
                pointerLongObj.body.SetActive(false);
                pointerLongObj.ResetLevelLine();
            }
        }
        else
        {
            //on
            pointerObj.body.SetActive(true);
            pointerObj.body.transform.position = ChangeWorldVector(pos);

            Vector2 sPos = ChangeWorldVector(startPoint);
            Vector2 ePos = ChangeWorldVector(endPoint);
            if (isLongPressing)
            {
                //長押し時ライン
                if (pointerLongObj != null)
                {
                    pointerLongObj.AddLevelLine(ePos - sPos, isTapPlayer);
                }
            }
            else if (isTransform)
            {
                //通常タップ時ポインター・ライン
                if (pointerStartObj != null)
                {
                    pointerStartObj.body.SetActive(true);
                    pointerStartObj.body.transform.position = sPos;
                    pointerStartObj.AddLevelLine(ePos - sPos, isTapPlayer);
                }
            }
        }
    }