Exemple #1
0
 /// <summary>Remove selectable object from list of selectable objects</summary>
 public void RemoveSelectableObject(SelectableObject selectableObject)
 {
     if (selectableObjects.Contains(selectableObject))
     {
         selectableObjects.Remove(selectableObject);
         decalHandler.RetractSelectionDecal(selectableObject);
     }
 }
Exemple #2
0
 /// <summary>Add selectable object to list of selectable objects</summary>
 public void AddSelectableObject(SelectableObject selectableObject)
 {
     if (!selectableObjects.Contains(selectableObject))
     {
         selectableObjects.Add(selectableObject);
         decalHandler.AssignSelectionDecal(selectableObject);
     }
 }
 /// <summary>Retracts the decal managing the given selectable object</summary>
 public void RetractSelectionDecal(SelectableObject selectable)
 {
     foreach (SelectionDecal decal in selectionDecals)
     {
         if (decal.AssignedSelectable == selectable)
         {
             decal.Retract();
             break;
         }
     }
 }
        /// <summary>Set up the decal with the given selectable object and color</summary>
        public void Setup(SelectableObject selectableObject)
        {
            AssignedSelectable = selectableObject;
            AssignedSelectable.AssignSelectionDecal(this);

            projectorHoverDecal.orthographicSize  = AssignedSelectable.HoverDecalSize;
            projectorSelectDecal.orthographicSize = AssignedSelectable.SelectDecalSize;

            projectorHoverDecal.material.color  = AssignedSelectable.DecalColor;
            projectorSelectDecal.material.color = AssignedSelectable.DecalColor;

            projectorHoverDecal.gameObject.SetActive(false);
            projectorSelectDecal.gameObject.SetActive(false);

            gameObject.SetActive(true);
        }
Exemple #5
0
        /// <summary>Checks whether the user is hovering over entities in the scene</summary>
        private void HandleHovering(bool pointerOverUI)
        {
            if (pointerOverUI)
            {
                //if pointer was over ui and hovered object isn't null, handle hover end
                if (hoveredObject != null)
                {
                    EndHover();
                }
                return;
            }

            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 1000f, selectableLayers.value))
            {
                SelectableObject selectableObject = hit.collider.GetComponentInParent <SelectableObject>();

                //exit if no selectable object component was found
                if (selectableObject == null)
                {
                    return;
                }

                // exit if the selectable object is not in the selectable objects list
                if (selectableObject != null && !selectableObjects.Contains(selectableObject))
                {
                    Debug.LogWarningFormat("selectable object {0} is not in the selectable objects list", selectableObject.name);
                    return;
                }

                // setup hovered object if it wasn't assigned yet
                if (hoveredObject == null)
                {
                    hoveredObject = selectableObject;
                    hoveredObject.HoverStart();
                }
            }
            else
            {
                if (hoveredObject != null)
                {
                    EndHover();
                }
            }
        }
Exemple #6
0
 /// <summary>ends hovering of hovered object</summary>
 private void EndHover()
 {
     hoveredObject.HoverEnd();
     hoveredObject = null;
 }
 public void Retract()
 {
     AssignedSelectable.RetractSelectionDecal();
     AssignedSelectable = null;
     gameObject.SetActive(false);
 }
 /// <summary>Assigns a decal to given selectable object</summary>
 public void AssignSelectionDecal(SelectableObject selectableObject)
 {
     GetDecal().Setup(selectableObject);
 }