예제 #1
0
    /// <summary>
    /// Show x-Axis
    /// </summary>
    public void ShowX()
    {
        //create Axis if not exits
        if (_xAxis == null)
        {
            //create Axis
            _xAxis = new GameObject();
        }

        //Check if LineRenderer == null
        if (_xAxis.GetComponent <LineRenderer>() == null)
        {
            //max is maximum bounds + seeable length
            var max = 0.4f + _bounds.GetMaxBounds().x;

            //min is minimum bounds - seeable length
            var min = _bounds.GetMinBounds().x - 0.4f;

            //store pos
            var pos = _obj.transform.position;

            //set start of x-Axis line
            var start = new Vector3(max, pos.y, pos.z);

            //set end of x-Axis line
            var end = new Vector3(min, pos.y, pos.z);

            //Draw line
            DrawLine(_xAxis, start, end, Color.red);
        }

        //set LineRenderer enabled
        _xAxis.GetComponent <LineRenderer>().enabled = true;
    }
예제 #2
0
        /// <summary>
        ///     Create prefab buttons and click listener for object selected bar
        /// </summary>
        public void Start()
        {
            //Add click listener
            createWalkTargetButton.GetComponent <Button>().onClick.AddListener(() =>
            {
                //Instantiate walk target
                GameObject target = Instantiate(Resources.Load("Utility/WalkTarget"), selectObject.GetObject().transform) as GameObject;
                target.name       = "WalkTarget";
                WalkTargetManager.getInstance().AddWalkTarget(target);

                //Set bounds and position
                ObjectBounds _bounds      = new ObjectBounds(selectObject.GetObject().transform.gameObject);
                float size                = _bounds.GetMaxBounds().x - _bounds.GetMinBounds().x;
                Vector3 newPos            = new Vector3(selectObject.GetObject().transform.position.x - 0.8f * size, 0.025f, selectObject.GetObject().transform.position.z);
                target.transform.position = newPos;

                //Hide button
                createWalkTargetButton.SetActive(false);
            });

            //Add click listener
            createTargetButton.GetComponent <Button>().onClick.AddListener(() =>
            {
                GameObject go           = selectObject.GetObject();
                GameObject target       = Instantiate(go, go.transform.position, go.transform.rotation);
                target.transform.parent = go.transform;
                target.name             = "moveTarget";
                target.GetComponent <Renderer>().material = (Material)Resources.Load("Materials/targetMaterial", typeof(Material));

                //Add script
                target.AddComponent <HoldPos>();

                //Set bounds and position
                ObjectBounds bounds       = new ObjectBounds(go.transform.gameObject);
                float size                = bounds.GetMaxBounds().x - bounds.GetMinBounds().x;
                Vector3 newPos            = new Vector3(go.transform.position.x + size + 0.25f * size, go.transform.position.y, go.transform.position.z);
                target.transform.position = newPos;

                //Remove hands and walk targets from move target
                //if (target.transform.GetChildRecursiveByName("RightHand(Clone)") || target.transform.GetChildRecursiveByName("LeftHand(Clone)") || target.transform.GetChildRecursiveByName("WalkTarget"))

                /*if (HandChecker.HasHands(go) || target.transform.Find("WalkTarget"))
                 * {
                 *  foreach (Transform child in target.transform)
                 *  {
                 *      //if (child.name.Equals("RightHand(Clone)") || child.name.Equals("LeftHand(Clone)") || child.name.Equals("WalkTarget"))
                 *      if (child.name.Equals(HandChecker.GetRightHand(go).name) || child.name.Equals("LeftHand(Clone)") || child.name.Equals("WalkTarget"))
                 *      {
                 *          Destroy(child.gameObject);
                 *      }
                 *  }
                 * }*/

                //Remove all the children of the move traget
                foreach (Transform child in target.transform)
                {
                    Destroy(child.gameObject);
                }

                //Hide button
                createTargetButton.SetActive(false);
            });
        }