Skip to content
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

Component: Toast #40

Open
nah0y opened this issue Mar 25, 2015 · 0 comments
Open

Component: Toast #40

nah0y opened this issue Mar 25, 2015 · 0 comments

Comments

@nah0y
Copy link
Contributor

nah0y commented Mar 25, 2015

Hello!

I wanted to do a demo scene for the toasts, but it seems broken.
It was working really nice before, now, when you call the Toaster.PopupToast method, it creates a huge Toast of 1000x1000.
It's also really weird, because putting the Toast prefab in the scene (the one in Resources), it's 1000x1000 and I can't resize it. The only thing I can do to make it have its size back is doing a small modif, then pressing Ctrl+Z... lol

Anyway, I think the way the Toast is handled is really complex for no reason.

  • I understand that we need to add a gameObject with the Toaster script on it so it can be in the scene, and it can be drag&dropped in a button event to trigger it.
    The thing is that, if that's the case, then why not just have directly in the scene a gameObject called ToastManager, that is in the empty scene directly?
    It's really confusing to have an empty gameObject, where you just attach a script like that.
    On top of that, it's even completely useless to have that, because you can only call the PopupToast public method and can't pass a string parameter to say what you want to display in the message.
    So if you want 2 different toasts, you have to create 2 empty gameObjects with the Toast component on them, define a different text for each one, and can't even change that at runtime :/
    Even if that's what you want, why can't you simply let people create a real Toast component, like the Toast prefab in resources, so they can have visual feedback on the toast and not have an empty gameObject?
  • Anyway, all of this to say that I think that toasts need to be called only from script, or maybe if users don't want to call them by script, they need to place directly the toast component (with UI etc...) wherever they want and link the event to this particular toast. But I don't know how this is useful...
  • The ToastControl class is weird :/ I mean, why do you ok you load the Toast component from memory in InitToastSystem, but why don't you just do that in the ToastManager script (the one who is called Toast right now)?
    And then you have the MakeToast method, that store values in static variables, then instantiate the toast, why don't you just instantiate the toast, get the component attached on it and call a init method passing all the variables?
  • Also, instead of just having one method with a lot of parameters, I would add one with just a string for the text that will use the other default values, much easier to use for 99.99999% cases.
  • I would have renamed PopupToast to simply Show.

In conclusion, what I think is best, is add a menu where user can create a ToastManager, that will place the ToastManager gameObject correctly in the canvas (and will be the parent of the toasts).
This ToastManager do not have any variable, so nothing is exposed to the inspector. It's just here to be the parent of the toasts, and initialise things.
Rewrite a little the Toast classes to remove all the unnecessary code.

And the test scenes will have to call the toast via script.

If you really want to have a toast component with color, text, duration etc... exposed to the inspector, you can maybe make a ToastTrigger component that one can attach to a gameObject that has a button for example, and they will drag&drop this component in the button event method.
Maybe that's not a bad idea :D

And for the last thing about toast:

  • It will be great to have 2 different toasts, one normal (the one you already have) and another one with a button on the right (to display "Cancel", "Discard" etc...)

PS: I don't know if you want to do it yourself, but if you want me to do it, just tell me I'll try to get into it ;)

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

No branches or pull requests

2 participants