Example #1
0
        private void TryCreateEvent <T>(string eventType, GameObject targetGo) where T : class
        {
            if (targetGo == null)
            {
                return;
            }

            var newEvent = new ComponentEvent(eventType)
            {
                GameObjectName = UnityNamingUtils.GetHierarchyName(targetGo.transform),
                ComponentType  = typeof(T).FullName,
                TouchPoint     = Input.mousePosition,
            };

            _events.Add(newEvent);
        }
Example #2
0
        private void CreateEvent(string eventType)
        {
            var eventSystem = EventSystem.current;
            var selected    = eventSystem.currentSelectedGameObject;

            bool             goIsNull;
            List <Component> componentsOnHere = null;

            //Null reference exceptions being thrown even when null check shows selectedGo is NOT null. This catches
            //this strange edge case where GetComponents<> throws exceptions on this missing go reference
            try
            {
                componentsOnHere = selected.GetComponents <Component>().ToList();
                goIsNull         = false;
            }
            catch
            {
                goIsNull = true;
            }


            var componentTypeNames = goIsNull ? "-" : UnityNamingUtils.GetComponentTypeNames(componentsOnHere);
            var goHierarchyName    = goIsNull ? "-" : UnityNamingUtils.GetHierarchyName(selected.transform);

            var newEvent = new TouchEvent
            {
                SceneName               = SceneManager.GetActiveScene().name,
                GameObjectName          = goHierarchyName,
                ComponentType           = componentTypeNames,
                TouchPointProp          = new Vector3S(Input.mousePosition),
                EventType               = eventType,
                IsFromEventSubscription = false,
            };

            _events.Add(newEvent);
        }
Example #3
0
 protected virtual void PopulateCommonEventData(TModel eventData, Transform componentTransform)
 {
     eventData.GameObjectName = UnityNamingUtils.GetHierarchyName(componentTransform);
     eventData.ComponentType  = typeof(TSelectable).FullName;//todo: measure performance
 }