Skip to content
This repository has been archived by the owner on Aug 22, 2018. It is now read-only.

RequireComponentAttribute unuseable #661

Closed
stefnotch opened this issue Apr 4, 2018 · 3 comments
Closed

RequireComponentAttribute unuseable #661

stefnotch opened this issue Apr 4, 2018 · 3 comments

Comments

@stefnotch
Copy link

@xen2 Why can't I use RequireComponentAttribute?
It says:

CS0246	The type or namespace name 'RequireComponentAttribute' could not be found (are you missing a using directive or an assembly reference?)

Code:

var x = typeof(RequireComponentAttribute);

However, AllowMultipleComponentsAttribute works. Both of them are in the same namespace and are supposed to be in the same .dll.

One slightly interesting thing is that the RequireComponentAttribute doesn't seem to get used anywhere.

@stefnotch
Copy link
Author

image

Apparently, it's missing from the .dll.

@xen2
Copy link
Contributor

xen2 commented Apr 5, 2018

Not part of the C# project file. Looks like a file that should have been erased.

@stefnotch
Copy link
Author

stefnotch commented Apr 5, 2018

@xen2 Oh, that explains a lot. Though, it seems like a rather convenient attribute. My use case would be something like this:
Force the user to add a camera component to the player entity:

[RequireComponentAttribute(typeof(CameraComponent))]
public class Player: SyncScript
{
    private CameraComponent _camera;
    public void Start() {
         _camera = this.Entity.Get<CameraComponent>();
    }
}

Though, after thinking about it for a while, it would probably be more elegant to use [NotNull] to force the user to add a camera component

public class Player: SyncScript
{
    //Game Studio doesn't seem to check this, which makes it rather useless
    [NotNull]
    public CameraComponent Camera { get; set; }
}

#662

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants