Skip to content
Snippets Groups Projects
Pointer.cs 968 B
Newer Older
  • Learn to ignore specific revisions
  • Richard Marcus's avatar
    Richard Marcus committed
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using static CommunicationEvents;
    
    public class Pointer : Gadget
    {
    
        public WorldCursor Cursor;
    
        void Awake()
        {
    
            if (FactManager == null)
                FactManager = GameObject.FindObjectOfType<FactManager>();
    
            if (this.Cursor == null)
                this.Cursor = GameObject.FindObjectOfType<WorldCursor>();
    
    
            this.UiName = "Point Mode";
    
            CommunicationEvents.TriggerEvent.AddListener(OnHit);
    
        }
    
        void OnEnable()
        {
            this.Cursor.setLayerMask(~this.ignoreLayerMask.value);
        }
    
    Richard Marcus's avatar
    Richard Marcus committed
    
        public override void OnHit(RaycastHit hit)
        {
    
    Richard Marcus's avatar
    Richard Marcus committed
            if (!this.isActiveAndEnabled) return;
    
            var pid = FactManager.AddPointFact(hit).Id;
    
    Richard Marcus's avatar
    Richard Marcus committed
            if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Ray"))
            {
    
                FactManager.AddOnLineFact(pid, hit.transform.GetComponent<FactObject>().URI, true);