Base class used for creating custom buttons. Can be inherited to create custom buttons.
Inheritance: MonoBehaviour
Esempio n. 1
0
 public void HideOther()//隐藏未选定对象,先全部隐藏,再把选定的重新显示出来就行了
 {
     foreach (TouchableObject tobj in objectsInScene)
     {
         tobj.Hide(false);
     }
     foreach (Transform obj in selectedObjects)
     {
         TouchableObject tobj = obj.GetComponent <TouchableObject>();
         if (tobj.isSpecial)
         {
             Transform tobjp = obj.parent;
             for (int i = 0; i < tobjp.childCount; i++)
             {
                 //tobjp.GetChild(i).GetComponent<TouchableObject>().Solid(false);
                 tobjp.GetChild(i).GetComponent <TouchableObject>().SuperShow(true);
             }
         }
         else
         {
             //tobj.Solid(false);
             tobj.SuperShow(true);
         }
     }
 }
Esempio n. 2
0
    public void DoubleClick()
    {
        DebugLog.DebugLogInfo("双击-----------------");
        if (BlockManager.Instance.availableBaseCount > 0)
        {
            DebugLog.DebugLogInfo("availableBaseCount--- " + BlockManager.Instance.availableBaseCount);
            BlockManager.Instance.availableBaseCount--;
            TouchableObject tobj = GetComponent <TouchableObject>();
            tobj.SetDraggable(false);
            tobj.SetRotatable(false);
            TweenRotation tween = TweenRotation.Begin(gameObject, 0.5f, targetRotation);
            DebugLog.DebugLogInfo("tween--- " + tween);
            tween.method = UITweener.Method.EaseInOut;
            UITweener tweener = TweenPosition.Begin(gameObject, 0.3f, targetPosition);
            DebugLog.DebugLogInfo("tweener--- " + tweener);
            tweener.method = UITweener.Method.EaseInOut;
            //TweenRotation tween = GetComponent<TweenRotation>();
            tween.from = m_transform.localEulerAngles;

            tween.to = targetAngles;
            float y = tween.from.y;
            if (Mathf.Abs(360 - tween.from.y) < Mathf.Abs(tween.from.y - 0))
            {
                //tween.from = new Vector3(tween.from.x, tween.from.y - 360, tween.from.z);
                tween.to = new Vector3(tween.to.x, tween.to.y + 360, tween.to.z);
            }
            DebugLog.DebugLogInfo("from:" + tween.from + "to:" + tween.to);
            tween.SetOnFinished(BlockManager.Instance.AddScore);
            //BlockManager.Instance.AddScore();
            isFinished = true;//标志该结构已经归位

            this.GetComponent <DraggableObject>().enabled = false;
            this.GetComponent <RotatableObject>().enabled = false;
        }
    }
Esempio n. 3
0
    public void AddInstance(TouchableObject o) {
	if (o.Verbosity > 1)
	{
	    Debug.Log("Added " + o.name +
		" to hapticMaterial " + name
		+ " instances (update will be synced)");
	}
	Instances.Add(o);
    }
Esempio n. 4
0
 //添加控制脚本,控制模型进行拼图操作
 void Add_block_componet(List <GameObject> objects)
 {
     for (int i = 0; i < objects.Count; i++)
     {
         objects[i].AddComponent <Block>();
         objects[i].AddComponent <RotatableObject>();
         objects[i].AddComponent <DraggableObject>();
         TouchableObject tempInfo = objects[i].AddComponent <TouchableObject>();
         named.TryGetValue(objects[i].name, out tempInfo.ModelName);
         // print(objects[i].name+"  "+tempInfo.ModelName);
     }
 }
Esempio n. 5
0
    /**
     * public void Init()
     * {
     *  foreach(TouchableObject tou in preObjectsAll)
     *  {
     *      if (tou.isNode && tou.state != States.Hide &&tou.isRealTouchableObject)
     *      {
     *          objectsAll.Add(tou);
     *          objectsInScene.Add(tou);
     *          objectsInSceneTemp.Add(tou);
     *      }
     *  }
     * }
     **/
    public void ControlRegion()//核心代码啊这是
    {
        List <TouchableObject> specialObjects = new List <TouchableObject>();

        //如果禁止计算区域,比如在骨单位场景就要这么做
        if (GameCamera.Inst.noControlRegion)
        {
            return;
        }
        foreach (TouchableObject obj in objectsInSceneTemp)
        {
            if (obj.CalculateDistance(core) > length)//大于这个距离,不管他本来是显示还是隐藏,都要隐藏掉
            {
                obj.SuperShow(false);
            }
            else//在距离内,也要检查他是否是hide状态,是的话,仍然不显示
            {
                if (!(obj.state == States.Hide))//如果他不是真正的隐藏状态,那么再进行下一步判断
                {
                    obj.SuperShow(true);
                    if (obj.isSpecial && !specialObjects.Contains(obj.m_transform.parent.GetComponent <TouchableObject>()))
                    {
                        //如果是特殊的,把它的父级物体先加进集合以备后用,但应该先检测下是否已经包含这个元素了
                        specialObjects.Add(obj.m_transform.parent.GetComponent <TouchableObject>());
                    }
                }
            }
        }
        foreach (TouchableObject obj in specialObjects)
        {
            for (int i = 0; i < obj.m_transform.childCount; i++)
            {
                obj.m_transform.GetChild(i).GetComponent <TouchableObject>().SuperShow(true);
            }
        }
        foreach (Transform obj in selectedObjects)
        {
            TouchableObject tobj = obj.GetComponent <TouchableObject>();
            if (tobj.isSpecial)
            {
                Transform tobjp = obj.parent;
                for (int i = 0; i < tobjp.childCount; i++)
                {
                    tobjp.GetChild(i).GetComponent <TouchableObject>().SuperShow(true);
                }
            }
            else
            {
                tobj.SuperShow(true);
            }
        }
    }
Esempio n. 6
0
 public void HideSelected()//隐藏所选
 {
     foreach (Transform obj in selectedObjects)
     {
         TouchableObject tobj = obj.GetComponent <TouchableObject>();
         if (tobj.isSpecial)
         {
             Transform tobjp = obj.parent;
             for (int i = 0; i < tobjp.childCount; i++)
             {
                 tobjp.GetChild(i).GetComponent <TouchableObject>().Hide(false);
             }
         }
         else
         {
             tobj.Hide(false);
         }
     }
 }
Esempio n. 7
0
    void Update()
    {
        // WTD: basically the phone asking "YOU TOUCHING ME?"
        FlowerController = Flower3.GetComponent <Animator>();
        Input.simulateMouseWithTouches = true;

        if (Input.touchCount > 0)          //  && Input.GetTouch(0).phase == TouchPhase.Began)
        {
            Touch touchedFinger = Input.touches [0];
            Debug.Log("Current Finger?: " + touchedFinger);
            //Animation.Play ("headShake");
            switch (touchedFinger.phase)
            {
            case TouchPhase.Ended:
                m_Ray = Camera.main.ScreenPointToRay(touchedFinger.position);
                if (Physics.Raycast(m_Ray.origin, m_Ray.direction, out m_RayCastHit, Mathf.Infinity))
                {
                    TouchableObject touchableObj = m_RayCastHit.collider.gameObject.GetComponent <TouchableObject> ();

                    if (touchableObj)
                    {
                        m_CurrentTouchableObject = touchableObj;
                        Debug.Log("Click detected");
                        FlowerController.Play("opening");
                    }
                    else
                    {
                        if (m_CurrentTouchableObject)
                        {
                            m_CurrentTouchableObject = null;
                            FlowerController.Play("closed");
                        }
                    }
                }
                break;

            default:
                break;
            }
        }
    }
Esempio n. 8
0
    void Update()
    {
        BeetriceLevelUp = BeetriceAnimationsLevelUp.GetComponent <Animator>();
        Input.simulateMouseWithTouches = true;

        if (Input.touchCount > 0)          //  && Input.GetTouch(0).phase == TouchPhase.Began)
        {
            Touch touchedFinger = Input.touches [0];
            Debug.Log("Current Finger?: " + touchedFinger);
            //Animation.Play ("headShake");
            switch (touchedFinger.phase)
            {
            case TouchPhase.Ended:
                m_Ray = Camera.main.ScreenPointToRay(touchedFinger.position);
                if (Physics.Raycast(m_Ray.origin, m_Ray.direction, out m_RayCastHit, Mathf.Infinity))
                {
                    TouchableObject touchableObj = m_RayCastHit.collider.gameObject.GetComponent <TouchableObject> ();
                    if (touchableObj)
                    {
                        m_CurrentTouchableObject = touchableObj;
                        Debug.Log("Click detected");
                        BeetriceLevelUp.Play("headshake");
                    }
                    else
                    {
                        if (m_CurrentTouchableObject)
                        {
                            m_CurrentTouchableObject = null;
                            BeetriceLevelUp.Play("static");
                        }
                    }
                }
                break;

            default:
                break;
            }
        }
    }
Esempio n. 9
0
    private void checkCollison(float positionThreshold, float angleThreshold)
    {
        float distance = Vector3.Distance(m_transform.localPosition, targetPosition);

        if (distance <= positionThreshold)
        {
            print("position ok");
        }
        if (distance <= positionThreshold &&
            Vector3.Angle(m_transform.right, targetRight) < angleThreshold &&
            Vector3.Angle(m_transform.up, targetUp) < angleThreshold &&
            Vector3.Angle(m_transform.forward, targetForward) < angleThreshold
            )//判断为达到正确位置
        {
            TouchableObject tobj = GetComponent <TouchableObject>();
            tobj.SetDraggable(false);
            tobj.SetRotatable(false);
            TweenRotation tween = TweenRotation.Begin(gameObject, 0.5f, targetRotation);
            tween.method = UITweener.Method.EaseInOut;
            UITweener tweener = TweenPosition.Begin(gameObject, 0.5f, targetPosition);
            tweener.method = UITweener.Method.EaseInOut;
            //TweenRotation tween = GetComponent<TweenRotation>();
            tween.from = m_transform.localEulerAngles;

            tween.to = targetAngles;
            float y = tween.from.y;
            if (Mathf.Abs(360 - tween.from.y) < Mathf.Abs(tween.from.y - 0))
            {
                //tween.from = new Vector3(tween.from.x, tween.from.y - 360, tween.from.z);
                tween.to = new Vector3(tween.to.x, tween.to.y + 360, tween.to.z);
            }
            Debug.Log("from:" + tween.from + "to:" + tween.to);
            //tween.PlayForward();
            //BlockManager.Instance.AddScore();
            tween.SetOnFinished(BlockManager.Instance.AddScore);
            isFinished = true;//标志该结构已经归位
            //targetRotation.
        }
    }
Esempio n. 10
0
    void Update()
    {
        if (Input.touches.Length == 1)
        {
            Debug.Log(" you clicked on k");
            Touch touchedFinger = Input.touches[0];

            switch (touchedFinger.phase)
            {
            case TouchPhase.Ended:
                m_Ray = Camera.main.ScreenPointToRay(touchedFinger.position);
                if (Physics.Raycast(m_Ray.origin, m_Ray.direction, out m_RayCastHit, Mathf.Infinity))
                {
                    TouchableObject touchableObj = m_RayCastHit.collider.gameObject.GetComponent <TouchableObject>();
                    if (touchableObj)
                    {
                        m_CurrentTouchableObject = touchableObj;
                        Debug.Log(" you clicked on ");
                    }
                    else     //nothing is selected
                    {
                        Debug.Log(" you clicked on 2");
                        if (m_CurrentTouchableObject)
                        {
                            m_CurrentTouchableObject = null;
                            Debug.Log(" you clicked on 3");
                            // reset the text back...
                        }
                    }
                }
                break;

            default:
                break;
            }
        }
    }
Esempio n. 11
0
    void Update()
    {
        if (translate) {
            // can no longer toggle selection on object
            selectMode = false;
            if (Input.touches.Length == 1) {
                //				Debug.Log("In Input.touches.Length == 1");
                Touch touchedFinger = Input.touches[0];

                switch (touchedFinger.phase) {
                case TouchPhase.Began:
                    //					Debug.Log("In TouchPhase.Began");
                    m_Ray = Camera.mainCamera.ScreenPointToRay(touchedFinger.position);
                    if (Physics.Raycast(m_Ray.origin, m_Ray.direction, out m_RayCastHit, Mathf.Infinity)) {
                        //						Debug.Log("In Physics.Raycast...");
                        TouchableObject movableObj = m_RayCastHit.collider.gameObject.GetComponent<TouchableObject>();
                        if(movableObj) {
                            //							Debug.Log("In if(movableObj)");
                            m_CurrentMovableObject = movableObj;
                        }
                    }
                    break;
                case TouchPhase.Moved:
                    //					Debug.Log("In TouchPhase.Moved");
                    if(m_CurrentMovableObject) {
                        //						Debug.Log("In m_CurrentMovableObject");
                        m_CurrentMovableObject.gameObject.transform.Translate(Time.deltaTime * m_MovementMultipier * new Vector3(touchedFinger.deltaPosition.x, 0, touchedFinger.deltaPosition.y));
                    }
                    break;

                case TouchPhase.Ended:
                    //					Debug.Log("In TouchPhase.Ended");
                    m_CurrentMovableObject = null;
                    break;

                default:
                    break;
                }
            }

            // finished translating, object is selectable again
            selectMode = true;
        }

        // Rotation
        if (rotate) {
            baseObject.transform.localRotation = Quaternion.AngleAxis (1, Vector3.up) * baseObject.transform.localRotation;
        }

        // Scale
        if(scale) {
            // get the position of the camera when the user hits the scale button
            // if the user increases their distance (x/y val) from the object, increase size
            // if the user decreases their distance fromt he object, decrease size

            //			cameraPosition = Control.cameraPositionAtScaleButtonTap;
            GameObject camera = GameObject.Find("ARCamera");
            cameraPosition = camera.transform.position;
            //			Debug.Log("cameraPosition: " + cameraPosition);
            objScale = cameraPosition.y / 10000.0F;
            Debug.Log("objScale: " + objScale);
            baseObject.transform.localScale = new Vector3 (objScale, objScale, objScale);

            // apply scale limitations
            //			if(baseObject.transform.localScale.y == 0.0f) {
            //				baseObject.transform.localScale = new Vector3 (0.5f, 0.5f, 0.5f);
            //			}
            //
            //			if(baseObject.transform.localScale.y == 5.0f) {
            //				baseObject.transform.localScale = new Vector3 (5.0f, 5.0f, 5.0f);
            //			}
            //			baseObject.transform.localScale += new Vector3 (0.01f, 0.01f, 0.01f);
        }
    }