コード例 #1
0
        private void UpdateChildren()
        {
            HashSet <ColorGroup> childSet = s_CachedChildSet ?? (s_CachedChildSet = new HashSet <ColorGroup>());

            if (m_Children != null)
            {
                for (int i = m_Children.Count - 1; i >= 0; --i)
                {
                    childSet.Add(m_Children[i]);
                }

                m_Children.Clear();
            }

            SearchForChildren(transform, false);

            if (m_Children != null)
            {
                for (int i = m_Children.Count - 1; i >= 0; --i)
                {
                    ColorGroup child = m_Children[i];

                    // if this wasn't previously attached
                    if (!childSet.Remove(child))
                    {
                        child.Refresh();
                    }
                }
            }

            foreach (var child in childSet)
            {
                child.m_Parent = null;
                child.Refresh();
            }

            childSet.Clear();
        }
コード例 #2
0
        private void SearchForChildren(Transform inTransform, bool inbOnSelf = true)
        {
            if (inbOnSelf)
            {
                ColorGroup color = inTransform.GetComponent <ColorGroup>();
                if (color != null)
                {
                    if (m_Children == null)
                    {
                        m_Children = new List <ColorGroup>();
                    }

                    m_Children.Add(color);
                    color.m_Parent = this;
                    return;
                }
            }

            for (int i = inTransform.childCount - 1; i >= 0; --i)
            {
                SearchForChildren(inTransform.GetChild(i), true);
            }
        }
コード例 #3
0
 protected override void OnValidate()
 {
     base.Reset();
     m_ColorGroup = this.CacheComponent(ref m_ColorGroup);
 }