private void CreateComponentHandler(MainComponent component)
        {
            if (!component.GetType().IsDefined(typeof(ComponentHandlerAttribute), false))
            {
                Debug.LogError("MainComponent no Handler:" + component.GetType());
                return;
            }
            var attrubte = component.GetType().GetAttribute <ComponentHandlerAttribute>();

            if (attrubte.handler == null)
            {
                return;
            }

            var handler = (MainComponentHandler)Activator.CreateInstance(attrubte.handler);

            handler.attribute = attrubte;
            handler.chart     = this;
            handler.SetComponent(component);
            component.handler = handler;
            m_ComponentHandlers.Add(handler);
        }
        private void AddComponent(MainComponent component)
        {
            var type = component.GetType();

            m_Components.Add(component);
            List <MainComponent> list;

            if (!m_ComponentMaps.TryGetValue(type, out list))
            {
                list = new List <MainComponent>();
                m_ComponentMaps[type] = list;
            }
            component.index = list.Count;
            list.Add(component);
        }
Ejemplo n.º 3
0
        internal static string GetComponentObjectName(MainComponent component)
        {
            Dictionary <int, string> dict;
            var type = component.GetType();

            if (s_ComponentObjectName.TryGetValue(type, out dict))
            {
                string name;
                if (!dict.TryGetValue(component.index, out name))
                {
                    name = GetTypeName(type) + component.index;
                    dict[component.index] = name;
                }
                return(name);
            }
            else
            {
                var name = GetTypeName(type) + component.index;
                dict = new Dictionary <int, string>();
                dict.Add(component.index, name);
                s_ComponentObjectName[type] = dict;
                return(name);
            }
        }