Ejemplo n.º 1
0
    public void UpdateColor()
    {
        var   color = ColorPicker.getColor();
        float h, s, v;

        Color.RGBToHSV(color, out h, out s, out v);
        var c = Color.HSVToRGB(h, (preX + 16) / 32, (preY + 16) / 32, true);

        nowColor = c;
        AxisViewManager.Instance().changeColor(nowColor);
    }
    // Update is called once per frame
    void Update()
    {
        if (index == AxisViewManager.Instance().GetAxisIndex())
        {
            RaycastHit   hit;
            RaycastHit[] hits;
            ray = view.ScreenPointToRay(Input.mousePosition);
            int layerMask_sphere = 1 << 9;
            int layerMask_axis   = 1 << 10;

            if (isClicked)
            {
                if (Vector3.Dot(view.transform.forward, transform.position) >= 0)
                {
                    Physics.Raycast(ray.origin + ray.direction * 100f, -ray.direction, out hit, Mathf.Infinity, layerMask_sphere);
                }
                else
                {
                    Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask_sphere);
                }
                if (hit.point != Vector3.zero)
                {
                    transform.position = hit.point;
                    myRenderer.SetPosition(1, transform.position);
                    AxisDataManager.Instance().changeVectorAt(index, transform.position);
                }
            }
            else
            {
                if (Input.GetMouseButtonDown(0))
                {
                    hits = Physics.RaycastAll(ray, Mathf.Infinity, layerMask_axis);
                    for (int i = 0; i < hits.Length; i++)
                    {
                        isClicked = true;
                    }
                }
            }
            if (Input.GetMouseButtonUp(0))
            {
                isClicked = false;
            }
        }
        DrawName();
    }