예제 #1
0
        /// <summary>
        /// Add component that already exists
        /// </summary>
        /// <param name="component">Component to add</param>
        /// <returns></returns>
        internal object AddComponent(object component)
        {
            CoreComponent instance = (CoreComponent)component;

            Components.Add(instance);

            instance.Parent = this;

            instance.Awake();
            instance.Start();

            return(instance);
        }
예제 #2
0
        /// <summary>
        /// Add component by string
        /// </summary>
        /// <param name="classname">Component name</param>
        public object AddComponent(string classname)
        {
            System.Type   type     = System.Type.GetType(classname);
            CoreComponent instance = (CoreComponent)System.Activator.CreateInstance(type);

            Components.Add(instance);

            instance.Parent = this;

            instance.Awake();
            instance.Start();

            return(instance);
        }