-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to make ABaseInlet usage clearer, as AInlet will be deprecated #13
Comments
I see you're writing an answer now so I'll keep this short: I now see that ABaseInlet looks like it is intended to replace AInlet eventually. Is this true? |
Yes! :) Your observation is valid, their is some duplicated code within the AInlet and the BaseInlet. AInlet already uses the Start, Update and FixedUpdate Methods and you need to override them if you want to change them. Since inheritance could be a root for complexity and bugs I was thinking on an approach using compositions which is more Unity'sh. As you can see, the ABaseInlet provides no implementation for Unity Messages (Start, Update etc.) so you are free to use them, which is I guess a bit to more easy understand for beginners. Another reason was the usage of only on ContinuousResolver Instance within a separated MonoBehaviour, using UnityEvents to propagate the appearance and loose of Streams among a UnityScene. I wrote a documentation for that |
What do you think about this approach!? Maybe it's to complicated - over engineered - ? |
I think this approach is good, but I think it's a bit confusing at the moment because the other examples and docs. Can you remove the old examples and update the docs? I also think the provided example in the new wiki page is a bit confusing at the bullet point about "Reference the AStreamIsFound". (It is clear before that). Why does the screenshot have different I think a better example (for clarity, not necessarily for simplicity) would show how to subscribe to the Resolver's events via code. |
Ok, I will take care on that... |
(Edited title of issue to reflect its true topic) I'll edit this post with other little things I notice.
|
Thanks for the comment, I see the problem with WaitForFixedUpdate() - you're absolute right about that I will change that accordingly. The difference between FixedUpdate and Update is important for physics simulation or - as I assume - stable sampling rates for the game state since the update frequency depends heavily on game logic. |
This problem deserves its own comment: What happens if the resolver is already running then a new gameObject is instantiated and it wants access to an already-found stream? onStreamFound won't trigger because it is already in knownStreams.
|
Nice question... 😅 Actually, I never thought to this point since I assume that the applications using LSL are not that kind of dynamic but ok let's see how this could be achieved... I would think the most simple solution to this might be a new Method within resolver which could get used for requesting a specific stream. Example: // a component inheriting from InletFloatSamples implementing your logic
void Start(){
var resolver = FindObjectOfType<Resolver>();
LSLStreamInfoWrapper streamInfo;
bool isAvailable = resolver.IsStreamAvailable("yourStreamName", out streamInfo);
if(isAvailable){
// use it immediately
this.AStreamIsFound(streamInfo);
}else
{
// register listener dynamically for the event which is expected later....
resolver.onStreamFound.addListener(this.AStreamIsFound);
}
} To answer your question... As far as I know, there is no option to invoke just one callback from the listener collection. |
To answer this question:
It is possible to override the property using the new keyword but this might cause strange behavior and bugs cause at runtime it is not possible to decide which version of a property should be used except using explizit type casts. Due to Unitys serialization logic it will provide both properties in the inspector which might become ambiguous. So this might not be an option.. 😞 And Unity also raises an error if you try that.. 👍 However, I'm not completely sure what the problem is... The script on your prefab inherits from InletFloatSamples so it get's the properties from this base class.... Whenever you instantiate the prefab (in your scene) you could change the content of the properties for this single instance (as long you did not click the Apply-Button in the inspector) or make a copy of the prefab with the expected default values. |
Ah. I'm showing my Unity-unfamiliarity here. I'm working on some components that I'm going to package up and share across different projects and, after sufficient testing, release as open source (Asset Store - someday). There are some assumptions that the general experimental framework makes about inlet type, control value range, etc, that I want reflected in the different assets. I hadn't thought to releasing the prefab, I thought only of releasing code, but in this case it makes sense to release the prefab. Thanks for reminding me of that.
That should work but it puts more burden on the user to add probably unfamiliar code to their Start() implementation. It would be nice if this code existed in |
BTW, here are the changes that I've made so far. It's incomplete. For example, I can never get out of the I just thought it might be useful for this discussion. |
Sorry for the late response, for this problem:
We should open a new issue... (made this #14 ). I would like to discuss this problem in detail. I suppose that a thread based approach might be necessary. Due to this:
I would recommend not to make too much dependencies/assumptions among framework components. I seems to be better to provide smaller building blocks with proper documentation which can be reused within custom scripts written by the user, which is the more Unity'sh way to build applications. I also tried to write a comprehensive framework for building experiments you can find the approach here <- this is absolutely not usable, I hopefully got time this year to improve the implementation. The major thing I learned during this work is, putting too much effort into abstraction makes things neither simpler nor useful 😞 Anyway, if you are interested in building a framework we could stick heads together and searching for a better approach 🙏 |
Yes, I would like that. This discussion is off-topic and should probably go somewhere else, but I'm not sure where. We're working towards a couple specific experiments at the moment and building the pieces we need for those as we go. I doubt I'll get there, but it would be great to offer functionality similar to NBS Presentation (or PsychToolbox, or E-Prime, or Superlab, etc). Of course Unity takes care of most of this, we just need the glue to make it an Experiment. There are a few things that I'm focused on for the current projects.
|
Just a suggestion, we could put this discussion to the VREF repository. because, all you requirements you described are mainly target by this project, however, nothing is really finished. Or you create a new repository for these components and if want, you could invite me as a contributor and I put the interesting components from the VREF repository to yours. The reusable components I see in this collection are:
I would not spend that much time in abstraction due to the (experimental) task dependent requirements. Rather, I would spend more time to investigate and reuse Unitys Feature and document them proper for future experiments. As an example, the Experimenter View could be achieved through different layers. |
Am I missing something or did you just not get around to it yet? I'm working on a project using LSL4Unity now so I can attempt to reduce repeated code if desired. I'm new to C# though so I can't promise it'll be good.
The text was updated successfully, but these errors were encountered: