예제 #1
0
    void HighlightFeature(GameObject hitObject)
    {
        if (hitObject)
        {
//			Debug.Log (hitObject.name + " Hit!");
            FeatureCollider hitFeature = hitObject.GetComponent <FeatureCollider>();
            if (hitFeature)
            {
//				Debug.Log ("Feature Collider Hit!");
                // already a highlighted object
                if (highlighted)
                {
                    if (hitFeature != highlighted)
                    {
//						Debug.Log("New Feature Highlighted!");
                        // replace highlighted
                        highlighted.EndHover();
                        highlighted = hitFeature;
                        highlighted.StartHover();
                    }
                }
                else
                {
                    highlighted = hitFeature;
                    highlighted.StartHover();
                }
            }
            //Ray is not hitting a Feature Collider
            else
            {
//				Debug.Log("No Feature Hit!");
                if (highlighted)
                {
                    highlighted.EndHover();
                    highlighted = null;
                }
            }
        }
        else
        {
//			Debug.Log("No Collision");
            if (highlighted)
            {
                highlighted.EndHover();
                highlighted = null;
            }
        }
    }
예제 #2
0
//	void OnGUI() {
//		string text = "HI!";
//		GuiHelper.StereoBox (xpos,.5f,.1f,.1f,ref text,Color.white);
//	}
    void Update()
    {
        if (Input.GetKeyDown(SelectionKey))
        {
            if (highlighted && !selected)
            {
                selected = highlighted;
//				UI.enabled = true;
            }
            else
            {
//				UI.enabled = false;
                selected = null;
            }
        }
        if (Input.GetKeyDown(RotationKey))
        {
            rotating = true;
        }
        if (Input.GetKeyUp(RotationKey))
        {
//			UI.enabled = false;
            selected = null;
            rotating = false;
        }

        if (!selected && !rotating)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.gameObject.GetComponent <FeatureCollider>() != null)
                {
                    // already a highlighted object
                    if (highlighted)
                    {
                        if (hit.collider.gameObject.GetComponent <FeatureCollider>() != highlighted)
                        {
                            // replace highlighted
                            highlighted.EndHover();
                            highlighted = hit.collider.gameObject.GetComponent <FeatureCollider>();
                            highlighted.StartHover();
                        }
                    }
                    else
                    {
                        highlighted = hit.collider.gameObject.GetComponent <FeatureCollider>();
                        highlighted.StartHover();
                    }
                }
                //Ray is not hitting a Feature Collider
                else
                {
                    if (highlighted)
                    {
                        highlighted.EndHover();
                        highlighted = null;
                    }
                }
            }
            else
            {
                if (highlighted)
                {
                    highlighted.EndHover();
                    highlighted = null;
                }
            }
        }
    }