示例#1
0
 /// <summary>
 /// Collapses the brick menu and deselects the selected surface.
 /// </summary>
 private void CollapseMenu()
 {
     if (_trackedSurface)
     {
         _trackedSurface.SetMaterial(GetCurrentMaterial());
         SelectableBehavior.DeselectSurface();
         _trackedSurface = null;
     }
     gameObject.GetComponent <Animation> ().Play("spiral-in");
 }
示例#2
0
 void Update()
 {
     // Ensures the menu is always centered over the selected surface
     if (_trackedSurface)
     {
         transform.position = Camera.main.WorldToScreenPoint(_trackedSurface.transform.position);
     }
     if (SelectableBehavior.GetSelectedSurface() && _trackedSurface != SelectableBehavior.GetSelectedSurface())
     {
         _trackedSurface = SelectableBehavior.GetSelectedSurface();
         ExpandMenu();
     }
 }
示例#3
0
    /// <summary>
    /// Selects the surface the user tapped on.
    /// </summary>
    /// <returns><c>true</c>, if a surface is found at the touch position, <c>false</c> otherwise.</returns>
    /// <param name="touch">Touch position.</param>
    private bool TrySelectSurface(Vector2 touch)
    {
        //Check if you hit a surface
        RaycastHit hit;
        var        ray       = Camera.main.ScreenPointToRay(touch);
        var        layerMask = 1 << LayerMask.NameToLayer("Ignore Raycast");  //http://answers.unity3d.com/questions/8715/how-do-i-use-layermasks.html

        if (Physics.Raycast(ray.origin, ray.direction, out hit, layerMask))
        {
            var selected = hit.collider.gameObject.GetComponent <Surface> ();
            if (selected != null)
            {
                SelectableBehavior.SelectSurface(selected);
                return(true);
            }
        }
        return(false);
    }
示例#4
0
 /// <summary>
 /// Sets the mesh.
 /// </summary>
 /// <param name="mesh">Mesh created by either TapSurfaceMesh or DragSurfaceMesh.</param>
 public void SetMeshAndSelect(Mesh mesh)
 {
     GetComponent <MeshFilter>().mesh         = mesh; //should this also be sharedMesh?
     GetComponent <MeshCollider>().sharedMesh = mesh;
     SelectableBehavior.SelectSurface(this);
 }
示例#5
0
 void Awake()
 {
     _maxGlowAmount = 0.25f;
     _instance      = this;    //set our static reference to our newly initialized instance
 }