コード例 #1
0
        public void CreateComponents()
        {
            foreach (Type t in registeredComponents)
            {
                ModComponentAttribute attribute = t.GetCustomAttributes(typeof(ModComponentAttribute), false)[0] as ModComponentAttribute;

                if (attribute.disabled)
                {
                    continue;
                }

                if (!attribute.componentType.HasFlag(ModComponentType.DontDestroyOnLoad))
                {
                    continue;
                }

                gameObject.AddComponent(t);
            }
        }
コード例 #2
0
        /// <summary>
        /// Called every time the active scene changes.
        /// </summary>
        public void CreateSceneComponents()
        {
            GameObject sceneObject = new GameObject();

            foreach (Type t in registeredComponents)
            {
                ModComponentAttribute attribute = t.GetCustomAttributes(typeof(ModComponentAttribute), false)[0] as ModComponentAttribute;

                if (attribute.disabled)
                {
                    continue;
                }

                if (!attribute.componentType.HasFlag(ModComponentType.RecreateOnSceneChange))
                {
                    continue;
                }

                sceneObject.AddComponent(t);
            }
        }