예제 #1
0
        public static KGComponentBase GetComponent(KGComponent component)
        {
            var type = FindComponent(component);

            if (type != null)
            {
                return((KGComponentBase)Activator.CreateInstance(type));
            }
            return(null);
        }
예제 #2
0
        private static Type FindComponent(KGComponent component)
        {
            var componentType = Assembly.GetExecutingAssembly()
                                .GetTypes().Where(type => type.Name == "KG" + component.ToString())
                                .FirstOrDefault();

            if (componentType == null)
            {
                Debug.LogError("Component not found : " + component.ToString());
                return(null);
            }

            return(componentType);
        }
예제 #3
0
        /// <summary>
        /// 컴포넌트의 네이티브 라이브러리를 설치하거나 제거한다.
        /// </summary>
        /// <param name="component">변경할 컴포넌트</param>
        /// <param name="install">설치 또는 제거 여부</param>
        /// <returns>성공 여부</returns>
        public static bool InstallNativeLibrary(KGComponent component, bool install)
        {
            var handler = GetComponent(component);

            if (install)
            {
                handler.OnInstallNativeLibrary();
            }
            else
            {
                handler.OnUninstallNativeLibrary();
            }

            return(true);
        }
예제 #4
0
        /// <summary>
        /// 컴포넌트를 활성화하거나 비활성화한다.
        /// </summary>
        /// <param name="component">변경할 컴포넌트</param>
        /// <param name="enable">활성화 또는 비활성화</param>
        /// <returns>성공 여부</returns>
        public static bool EnableComponent(KGComponent component, bool enable)
        {
            var handler = GetComponent(component);

            if (handler.isAvaliable)
            {
                Debug.LogWarning("Component(" + component.ToString() + ") not avaliable for current package.");
            }

            if (enable)
            {
                handler.OnEnable();
            }
            else
            {
                handler.OnDisable();
            }

            return(true);
        }