コード例 #1
0
 // ---------[ EVENTS ]---------
 public void NotifyTagClicked(ModTagDisplayComponent display)
 {
     if (tagClicked != null)
     {
         tagClicked(display);
     }
 }
        /// <summary>Event handler for a tag being clicked.</summary>
        private void TagClickHandler(ModTagDisplayComponent display)
        {
            string tagName = display.data.tagName;
            if(this.m_selectedTags.Contains(tagName))
            {
                this.m_selectedTags.Remove(tagName);
            }
            else
            {
                this.m_selectedTags.Add(tagName);
            }

            this.view.SetTagFilter(this.m_selectedTags);
        }
コード例 #3
0
        private void PresentData_Editor(IEnumerable <ModTagDisplayData> displayData)
        {
            Debug.Assert(!Application.isPlaying);

            if (loadingOverlay != null)
            {
                loadingOverlay.SetActive(false);
            }

            // clear
            if (m_tagDisplays != null)
            {
                foreach (ModTagDisplayComponent display in m_tagDisplays)
                {
                    GameObject displayGO = display.gameObject;
                    UnityEditor.EditorApplication.delayCall += () =>
                    {
                        DestroyImmediate(displayGO);
                    };
                }
                m_tagDisplays.Clear();
            }

            if (tagDisplayPrefab == null || container == null)
            {
                return;
            }

            // create
            foreach (ModTagDisplayData tagData in displayData)
            {
                ModTagDisplayData tdata = tagData;

                UnityEditor.EditorApplication.delayCall += () =>
                {
                    GameObject displayGO = GameObject.Instantiate(tagDisplayPrefab,
                                                                  new Vector3(),
                                                                  Quaternion.identity,
                                                                  container);
                    displayGO.hideFlags = HideFlags.HideAndDontSave | HideFlags.HideInInspector;

                    ModTagDisplayComponent display = displayGO.GetComponent <ModTagDisplayComponent>();
                    display.data = tdata;

                    m_tagDisplays.Add(display);
                };
            }

            // TODO: fix layouting?
        }
コード例 #4
0
        private void PresentData(IList <ModTagDisplayData> displayData)
        {
            Debug.Assert(displayData != null);

            if (loadingOverlay != null)
            {
                loadingOverlay.SetActive(false);
            }

            int newCount = displayData.Count;

            // remove unneeded displays
            while (newCount < m_tagDisplays.Count)
            {
                ModTagDisplayComponent display = m_tagDisplays[newCount];
                m_tagDisplays.RemoveAt(newCount);

                GameObject.Destroy(display.gameObject);
            }

            // create new displays
            while (m_tagDisplays.Count < newCount)
            {
                GameObject displayGO = GameObject.Instantiate(tagDisplayPrefab);
                displayGO.transform.SetParent(container, false);

                ModTagDisplayComponent display = displayGO.GetComponent <ModTagDisplayComponent>();
                display.Initialize();
                display.onClick += NotifyTagClicked;

                m_tagDisplays.Add(display);
            }

            // assign data
            for (int i = 0; i < newCount; ++i)
            {
                this.m_tagDisplays[i].data = displayData[i];
            }

            // fix layouting
            if (this.isActiveAndEnabled)
            {
                StartCoroutine(LateUpdateLayouting());
            }
        }
コード例 #5
0
        private void CollectChildTags()
        {
            m_tagDisplays = new List <ModTagDisplayComponent>();

            // TODO(@jackson): Why check isPlaying?
            #if UNITY_EDITOR
            if (Application.isPlaying || container != null)
            #endif
            {
                foreach (Transform t in container)
                {
                    ModTagDisplayComponent tagDisplay = t.GetComponent <ModTagDisplayComponent>();
                    if (tagDisplay != null)
                    {
                        m_tagDisplays.Add(tagDisplay);
                    }
                }
            }
        }
コード例 #6
0
        // ---------[ EVENTS ]---------
        private void TagClickHandler(ModTagDisplayComponent display)
        {
            if (m_selectedTags.Contains(display.data.tagName))
            {
                m_selectedTags.Remove(display.data.tagName);

                if (tagFilterRemoved != null)
                {
                    tagFilterRemoved(display.data.tagName);
                }
            }
            else
            {
                m_selectedTags.Add(display.data.tagName);

                if (tagFilterAdded != null)
                {
                    tagFilterAdded(display.data.tagName);
                }
            }
        }
コード例 #7
0
        private void PresentData(IEnumerable <ModTagDisplayData> displayData)
        {
            Debug.Assert(displayData != null);

            if (loadingOverlay != null)
            {
                loadingOverlay.SetActive(false);
            }

            // clear
            foreach (ModTagDisplayComponent display in m_tagDisplays)
            {
                GameObject.Destroy(display.gameObject);
            }
            m_tagDisplays.Clear();

            // create
            foreach (ModTagDisplayData tagData in displayData)
            {
                GameObject displayGO = GameObject.Instantiate(tagDisplayPrefab,
                                                              new Vector3(),
                                                              Quaternion.identity,
                                                              container);

                ModTagDisplayComponent display = displayGO.GetComponent <ModTagDisplayComponent>();
                display.Initialize();
                display.data     = tagData;
                display.onClick += NotifyTagClicked;

                m_tagDisplays.Add(display);
            }

            // fix layouting
            if (this.isActiveAndEnabled)
            {
                StartCoroutine(LateUpdateLayouting());
            }
        }