コード例 #1
0
        public void SyncAttachedComponents()
        {
            var added      = false;
            var components = InternalGameObject.GetComponents <Component> ();

            foreach (var c in components)
            {
                if (!m_attachedComponents.Where(i => i.Component == c).Any())
                {
                    m_attachedComponents.Add(new ComponentInfo(c.GetType(), c));
                    added = true;
                }
            }

            // sometimes component changes by newly added component (i.e. Transform->RectTransform)
            for (int i = 0; i < m_attachedComponents.Count; ++i)
            {
                if (!components.Contains(m_attachedComponents[i].Component))
                {
                    m_attachedComponents.RemoveAt(i);
                }
            }

            if (added)
            {
                Save();
            }
        }
コード例 #2
0
        public UnityEngine.Component AddComponent(Type t)
        {
            var c = InternalGameObject.AddComponent(t);

            if (c != null)
            {
                m_attachedComponents.Add(new ComponentInfo(t, c));
                Save();
            }
            return(c);
        }
コード例 #3
0
        public T AddComponent <T> () where T : UnityEngine.Component
        {
            var c = InternalGameObject.AddComponent <T> ();

            if (c != null)
            {
                m_attachedComponents.Add(new ComponentInfo(typeof(T), c));
                Save();
            }
            return(c);
        }
コード例 #4
0
        public UnityEngine.Component GetComponent(Type t)
        {
            var c = InternalGameObject.GetComponent(t);

            if (c != null)
            {
                if (!m_attachedComponents.Where(i => i.Component == c).Any())
                {
                    m_attachedComponents.Add(new ComponentInfo(t, c));
                    Save();
                }
            }
            return(c);
        }
コード例 #5
0
        public T GetComponent <T> () where T : UnityEngine.Component
        {
            var c = InternalGameObject.GetComponent <T> ();

            if (c != null)
            {
                if (!m_attachedComponents.Where(i => i.Component == c).Any())
                {
                    m_attachedComponents.Add(new ComponentInfo(typeof(T), c));
                    Save();
                }
            }
            return(c);
        }