Esempio n. 1
0
 protected override void OnObjectDeselect()
 {
     IsOn = isSelected;
     base.OnObjectDeselect();
     OnDeselect?.Invoke();
     SetDynamicValueChange(false);
 }
Esempio n. 2
0
 void Start()
 {
     onSelect += delegate (GameObject selectedObject) {
         Debug.Log ("selected " + selectedObject);
     };
     onDeselect += (unselectedObject) => Debug.Log ("unselected " + unselectedObject);
 }
Esempio n. 3
0
        public void Deselected()
        {
            TimeManager.SelectedObject = null;
            OnDeselect?.Invoke();
            isSelected = false;
            try
            {
                foreach (var elem in SelectUI)
                {
                    elem.enabled = false;
                }

                foreach (var child in GetComponentsInChildren <MeshRenderer>())
                {
                    child.material = storedMaterials[child.gameObject.GetInstanceID()];
                }

                if (CurJointIntersectionCount > 0)
                {
                    foreach (var elem in ApproachUI)
                    {
                        elem.enabled = true;
                    }
                }

                // Reset alpha for selection material
                var colour = Globals.SELECTION_MATERIAL.color;
                Globals.SELECTION_MATERIAL.color = new Color(colour.r, colour.g, colour.b, 1.0f);
            }
            catch (KeyNotFoundException e)
            {
                Debug.LogWarning("Child object's material not found!");
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Assigns all events to the selectable, since there are so many of them.
 /// </summary>
 /// <param name="selectable">The selectable to assign events to.</param>
 /// <param name="i">The index of the methods array.</param>
 /// <param name="j">The number to pass into the method.</param>
 private void AssignSelectable(KMSelectable selectable, ref int i, ref int j)
 {
     if (OnCancel != null && i < OnCancel.Length)
     {
         selectable.OnCancel += OnCancel[i](j);
     }
     if (OnDefocus != null && i < OnDefocus.Length)
     {
         selectable.OnDefocus += OnDefocus[i](j);
     }
     if (OnDeselect != null && i < OnDeselect.Length)
     {
         selectable.OnDeselect += OnDeselect[i](j);
     }
     if (OnFocus != null && i < OnFocus.Length)
     {
         selectable.OnFocus += OnFocus[i](j);
     }
     if (OnHighlight != null && i < OnHighlight.Length)
     {
         selectable.OnHighlight += OnHighlight[i](j);
     }
     if (OnHighlightEnded != null && i < OnHighlightEnded.Length)
     {
         selectable.OnHighlightEnded += OnHighlightEnded[i](j);
     }
     if (OnInteract != null && i < OnInteract.Length)
     {
         selectable.OnInteract += OnInteract[i](j);
     }
     if (OnInteractEnded != null && i < OnInteractEnded.Length)
     {
         selectable.OnInteractEnded += OnInteractEnded[i](j);
     }
     if (OnLeft != null && i < OnLeft.Length)
     {
         selectable.OnLeft += OnLeft[i](j);
     }
     if (OnRight != null && i < OnRight.Length)
     {
         selectable.OnRight += OnRight[i](j);
     }
     if (OnSelect != null && i < OnSelect.Length)
     {
         selectable.OnSelect += OnSelect[i](j);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListViewCustom)
            {
                return;
            }
            isStartedListViewCustom = true;

            base.Start();

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException(String.Format("DefaultItem is null. Set component of type {0} to DefaultItem.", typeof(TComponent).FullName));
            }
            DefaultItem.gameObject.SetActive(true);

            var topFillerObj = new GameObject("top filler");

            topFillerObj.transform.SetParent(Container);
            topFiller = topFillerObj.AddComponent <RectTransform>();
            topFiller.SetAsFirstSibling();
            topFiller.localScale = Vector3.one;

            var bottomFillerObj = new GameObject("bottom filler");

            bottomFillerObj.transform.SetParent(Container);
            bottomFiller            = bottomFillerObj.AddComponent <RectTransform>();
            bottomFiller.localScale = Vector3.one;

            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                scrollHeight = scrollRect.GetComponent <RectTransform>().rect.height;
                if (itemHeight == 0)
                {
                    var rect             = DefaultItem.GetComponent <RectTransform>();
                    var preffered_height = LayoutUtility.GetPreferredSize(rect, 1);
                    itemHeight = (preffered_height <= 0) ? rect.rect.height : preffered_height;
                }
                layout = Container.GetComponent <EasyLayout.EasyLayout>();
                CalculateMaxVisibleItems();

                var r = scrollRect.gameObject.AddComponent <ResizeListener>();
                r.OnResize.AddListener(Resize);
            }

            customItems = SortItems(customItems);
            UpdateView();

            DefaultItem.gameObject.SetActive(false);

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
Esempio n. 6
0
        /// <summary>
        /// This function is called when the MonoBehaviour will be destroyed.
        /// </summary>
        protected override void OnDestroy()
        {
            OnSelect.RemoveListener(OnSelectCallback);
            OnDeselect.RemoveListener(OnDeselectCallback);

            RemoveCallbacks();

            base.OnDestroy();
        }
Esempio n. 7
0
        public void Deselect()
        {
            parent.Active = false;

            /*
             * if (OnDeselect != null)
             *  parent.Scene.QueueMethod(OnDeselect, parent);
             */
            OnDeselect?.Invoke(parent);
        }
Esempio n. 8
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListView)
            {
                return;
            }
            isStartedListView = true;

            base.Start();
            base.Items = new List <ListViewItem>();

            SelectedItemsCache = SelectedIndicies.Convert <int, string>(GetDataItem);

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException("DefaultItem is null. Set component of type ImageAdvanced to DefaultItem.");
            }
            DefaultItem.gameObject.SetActive(true);
            if (DefaultItem.GetComponentInChildren <Text>() == null)
            {
                throw new MissingComponentException("DefaultItem don't have child with 'Text' component. Add child with 'Text' component to DefaultItem.");
            }

            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                var scrollRectTransform = scrollRect.transform as RectTransform;
                scrollHeight = scrollRectTransform.rect.height;
                scrollWidth  = scrollRectTransform.rect.width;

                layout = Container.GetComponent <LayoutGroup>();
                if (layout is EasyLayout.EasyLayout)
                {
                    LayoutBridge = new EasyLayoutBridge(layout as EasyLayout.EasyLayout, DefaultItem.transform as RectTransform);
                    LayoutBridge.IsHorizontal = IsHorizontal();
                }
                else if (layout is HorizontalOrVerticalLayoutGroup)
                {
                    LayoutBridge = new StandardLayoutBridge(layout as HorizontalOrVerticalLayoutGroup, DefaultItem.transform as RectTransform);
                }

                CalculateItemSize();
                CalculateMaxVisibleItems();
            }

            DefaultItem.gameObject.SetActive(false);

            UpdateItems();

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
Esempio n. 9
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListView)
            {
                return;
            }
            isStartedListView = true;

            base.Start();

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException("DefaultItem is null. Set component of type ImageAdvanced to DefaultItem.");
            }
            DefaultItem.gameObject.SetActive(true);
            if (DefaultItem.GetComponentInChildren <Text>() == null)
            {
                throw new MissingComponentException("DefaultItem don't have child with 'Text' component. Add child with 'Text' component to DefaultItem.");
            }

            var topFillerObj = new GameObject("top filler");

            topFillerObj.transform.SetParent(Container);
            topFiller = topFillerObj.AddComponent <RectTransform>();
            topFiller.SetAsFirstSibling();
            topFiller.localScale = Vector3.one;

            var bottomFillerObj = new GameObject("bottom filler");

            bottomFillerObj.transform.SetParent(Container);
            bottomFiller            = bottomFillerObj.AddComponent <RectTransform>();
            bottomFiller.localScale = Vector3.one;

            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                scrollHeight    = scrollRect.GetComponent <RectTransform>().rect.height;
                itemHeight      = DefaultItem.GetComponent <RectTransform>().rect.height;
                maxVisibleItems = (int)Math.Ceiling(scrollHeight / itemHeight) + 1;
                layout          = Container.GetComponent <EasyLayout.EasyLayout>();

                var r = scrollRect.gameObject.AddComponent <ResizeListener>();
                r.OnResize.AddListener(Resize);
            }

            UpdateItems();

            DefaultItem.gameObject.SetActive(false);

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
Esempio n. 10
0
    private void Awake()
    {
        OnSelect.AddListener(SelectDown);
        OnSelectUp.AddListener(SelectUp);
        OnDeselect.AddListener(Deselect);

        originalColor = GetComponent <SpriteRenderer>().color;

        attrs.isNeighbour = false;
        attrs.isSelected  = false;
    }
Esempio n. 11
0
        /// <summary>
        /// This function is called when the MonoBehaviour will be destroyed.
        /// </summary>
        public override void OnDestroy()
        {
            OnSelect.RemoveListener(OnSelectCallback);
            OnDeselect.RemoveListener(OnDeselectCallback);

            ScrollRect = null;

            RemoveCallbacks();

            base.OnDestroy();
        }
Esempio n. 12
0
 public void SoftDeselect()
 {
     parent.Active = false;
     if (OnSoftDeselect == null)
     {
         OnDeselect?.Invoke(parent);
     }
     else
     {
         OnSoftDeselect.Invoke(parent);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListViewCustom)
            {
                return;
            }

            base.Start();
            base.Items = new List <ListViewItem>();

            SelectedItemsCache = SelectedItems;

            SetItemIndicies = false;

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException(String.Format("DefaultItem is null. Set component of type {0} to DefaultItem.", typeof(TComponent).FullName));
            }
            DefaultItem.gameObject.SetActive(true);

            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                var scroll_rect_transform = scrollRect.transform as RectTransform;
                scrollHeight = scroll_rect_transform.rect.height;
                scrollWidth  = scroll_rect_transform.rect.width;

                CalculateItemSize();

                layout          = Container.GetComponent <EasyLayout.EasyLayout>();
                layout.Stacking = (IsHorizontal()) ? EasyLayout.Stackings.Vertical : EasyLayout.Stackings.Horizontal;

                CalculateMaxVisibleItems();

                var r = scrollRect.gameObject.AddComponent <ResizeListener>();
                r.OnResize.AddListener(SetNeedResize);
            }

            DefaultItem.gameObject.SetActive(false);

            Direction = direction;

            UpdateItems();

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);

            isStartedListViewCustom = true;
        }
Esempio n. 14
0
        /// <summary>
        /// This function is called when the MonoBehaviour will be destroyed.
        /// </summary>
        public override void OnDestroy()
        {
            OnSelect.RemoveListener(OnSelectNode);
            OnDeselect.RemoveListener(OnDeselectNode);

            if (Nodes != null)
            {
                Nodes.Dispose();
                //Nodes = null;
            }

            base.OnDestroy();
        }
Esempio n. 15
0
        /// <summary>
        /// This function is called when the MonoBehaviour will be destroyed.
        /// </summary>
        protected override void OnDestroy()
        {
            layout       = null;
            LayoutBridge = null;

            OnSelect.RemoveListener(OnSelectCallback);
            OnDeselect.RemoveListener(OnDeselectCallback);

            ScrollRect = null;

            RemoveCallbacks();

            base.OnDestroy();
        }
Esempio n. 16
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListViewGameObjects)
            {
                return;
            }
            isStartedListViewGameObjects = true;

            base.Start();

            DestroyGameObjects = true;

            UpdateItems();

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
Esempio n. 17
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedTreeViewCustom)
            {
                return;
            }
            isStartedTreeViewCustom = true;

            setContentSizeFitter = false;

            base.Start();

            Refresh();

            OnSelect.AddListener(OnSelectNode);
            OnDeselect.AddListener(OnDeselectNode);
            KeepSelection = false;

            DataSource = NodesList;
        }
Esempio n. 18
0
    public void Deselect()
    {
        if (GetComponent <MyObject>().team != Team.A)
        {
            return;
        }

        OnDeselect?.Invoke();

        if (selectionIndicator != null)
        {
            selectionIndicator.SetActive(false);
        }
        if (rangeIndicator != null)
        {
            rangeIndicator.SetActive(false);
        }
        if (waypointRenderer != null)
        {
            waypointRenderer.enabled = false;
        }
    }
        private void HandleTapping()
        {
            Touch[] touches = Input.touches;
            for (int i = 0; i < touches.Length; i++)
            {
                if (touches[i].phase != TouchPhase.Ended)
                {
                    continue;
                }
                OnTap?.Invoke();

                if (!ShootGraphicsRays(Input.mousePosition))
                {
                    if (!ShootPhysicsRay(touches[i].position))
                    {
                        OnDeselect?.Invoke();
                    }
                }
            }

            if (touches.Length == 1)
            {
                if (touches[0].deltaPosition.magnitude > _DragThreshold)
                {
                    SetCurrentState(TouchInputState.DRAGGING);
                }
            }

            if (touches.Length == 2)
            {
                float delta = InputUtils.GetTouchDistanceDelta(touches[0], touches[1]);

                if (Mathf.Abs(delta) > _PinchThreshold)
                {
                    SetCurrentState(TouchInputState.PINCHING);
                }
            }
        }
        private void HandleDebugMouse()
        {
#if UNITY_EDITOR
            if (Input.GetMouseButtonDown(1))
            {
                _PreviousMousePosition = Input.mousePosition;
                OnDragStart?.Invoke();
            }

            if (Input.GetMouseButton(1))
            {
                Vector2 mousePos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
                OnDragDelta?.Invoke((mousePos - _PreviousMousePosition) * 2);
                _PreviousMousePosition = Input.mousePosition;
            }

            if (Input.GetMouseButtonUp(1))
            {
                OnDragStop?.Invoke();
            }

            OnPinchDelta?.Invoke(Input.mouseScrollDelta.y * 45);

            if (Input.GetMouseButtonDown(0))
            {
                OnTap?.Invoke();

                if (!ShootGraphicsRays(Input.mousePosition))
                {
                    if (!ShootPhysicsRay(Input.mousePosition))
                    {
                        OnDeselect?.Invoke();
                    }
                }
            }
#endif
        }
Esempio n. 21
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListViewCustom)
            {
                return;
            }
            isStartedListViewCustom = true;

            base.Start();
            base.Items = new List <ListViewItem>();

            SelectedItemsCache = SelectedItems;

            SetItemIndicies = false;

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException(String.Format("DefaultItem is null. Set component of type {0} to DefaultItem.", typeof(TComponent).FullName));
            }
            DefaultItem.gameObject.SetActive(true);


            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                var scroll_rect_transform = scrollRect.transform as RectTransform;
                scrollHeight = scroll_rect_transform.rect.height;
                scrollWidth  = scroll_rect_transform.rect.width;

                layout = Container.GetComponent <LayoutGroup>();

                if (layout is EasyLayout.EasyLayout)
                {
                    LayoutBridge = new EasyLayoutBridge(layout as EasyLayout.EasyLayout, DefaultItem.transform as RectTransform, setContentSizeFitter);
                    LayoutBridge.IsHorizontal = IsHorizontal();
                }
                else if (layout is HorizontalOrVerticalLayoutGroup)
                {
                    LayoutBridge = new StandardLayoutBridge(layout as HorizontalOrVerticalLayoutGroup, DefaultItem.transform as RectTransform, setContentSizeFitter);
                }

                CalculateItemSize();
                CalculateMaxVisibleItems();

                var resizeListener = scrollRect.GetComponent <ResizeListener>();
                if (resizeListener == null)
                {
                    resizeListener = scrollRect.gameObject.AddComponent <ResizeListener>();
                }
                resizeListener.OnResize.AddListener(SetNeedResize);
            }

            DefaultItem.gameObject.SetActive(false);

            SetDirection(direction, false);

            UpdateItems();

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
Esempio n. 22
0
 public void Deselect()
 {
     OnDeselect?.Invoke();
 }
 public void Deselect()
 {
     //Debug.Log("<color=red>UNHIGHLIGHTED </color>" + gameObject.name);
     OnDeselect?.Invoke();
 }
Esempio n. 24
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListView)
            {
                return;
            }
            isStartedListView = true;

            base.Start();
            base.Items = new List <ListViewItem>();

            SelectedItemsCache = SelectedIndicies.ConvertAll <string>(GetDataItem);

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException("DefaultItem is null. Set component of type ImageAdvanced to DefaultItem.");
            }
            DefaultItem.gameObject.SetActive(true);
            if (DefaultItem.GetComponentInChildren <Text>() == null)
            {
                throw new MissingComponentException("DefaultItem don't have child with 'Text' component. Add child with 'Text' component to DefaultItem.");
            }

            var topFillerObj = new GameObject("top filler");

            topFillerObj.transform.SetParent(Container);
            topFiller = topFillerObj.AddComponent <RectTransform>();
            topFiller.SetAsFirstSibling();
            topFiller.localScale = Vector3.one;

            var bottomFillerObj = new GameObject("bottom filler");

            bottomFillerObj.transform.SetParent(Container);
            bottomFiller            = bottomFillerObj.AddComponent <RectTransform>();
            bottomFiller.localScale = Vector3.one;

            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                var scrollRectTransform = scrollRect.transform as RectTransform;
                scrollHeight = scrollRectTransform.rect.height;
                scrollWidth  = scrollRectTransform.rect.width;

                var itemRectTransform = DefaultItem.transform as RectTransform;
                itemHeight = itemRectTransform.rect.height;
                itemWidth  = itemRectTransform.rect.width;

                layout = Container.GetComponent <EasyLayout.EasyLayout>();

                CalculateMaxVisibleItems();
            }

            DefaultItem.gameObject.SetActive(false);

            UpdateItems();

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }