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); } }
/// <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); } }