/// <summary>
 /// Whether the given data is valid.
 /// </summary>
 /// <param name="data">The data to check.</param>
 /// <param name="checkIfHovered">Whether to check if the hover state is active.</param>
 /// <returns>Whether the data is valid.</returns>
 protected virtual bool IsValidData(SurfaceData data, bool checkIfHovered = false)
 {
     return(data.Transform != null &&
            data.Transform.gameObject != null &&
            SourceValidity.Accepts(data.Transform.gameObject) &&
            (!checkIfHovered || HoveringElements.Any(element => element.Transform.Equals(data.Transform))));
 }
コード例 #2
0
        public virtual void Exit(SurfaceData data)
        {
            if (data.Transform == null || !SourceValidity.Accepts(data.Transform) || !HoveringElements.Contains(data))
            {
                return;
            }

            IsHovered = false;
            HoveringElements.Remove(data);
            Exited?.Invoke(CreateHoverPayload(data));
            if (HoveringElements.Count == 0)
            {
                HoverDeactivated?.Invoke();
            }
        }
コード例 #3
0
        public virtual void Enter(SurfaceData data)
        {
            if (data.Transform == null || !SourceValidity.Accepts(data.Transform))
            {
                return;
            }

            IsHovered = true;
            HoveringElements.Add(data);
            if (HoveringElements.Count == 1)
            {
                HoverActivated?.Invoke();
            }
            Entered?.Invoke(CreateHoverPayload(data));
        }
コード例 #4
0
        public virtual void Select(SurfaceData data)
        {
            if (data.Transform == null || !SourceValidity.Accepts(data.Transform) || !HoveringElements.Contains(data))
            {
                return;
            }

            IsActivated = true;
            Activated?.Invoke(CreateSelectedPayload(data));

            if (!EmitExitOnSelect)
            {
                return;
            }

            foreach (SurfaceData element in HoveringElements.ToArray())
            {
                Exit(element);
            }
            HoveringElements.Clear();
        }
コード例 #5
0
 /// <inheritdoc />
 protected override bool IsSourceValid(GameObject source)
 {
     return(base.IsSourceValid(source) && SourceValidity.Accepts(source));
 }