top of page
Search

Space Rob thinking: update 11


Gotta love Unity! Firstly, I think the Touch script I previously created is outdated, although I might be wrong: onClick button function, which is part of the Button object that I'm using, is automatically converted to a touch press.


Previously, I'd learned to make move and jump buttons as images, then attached event triggers to them, then clarified via a Touch script what mouse up&down did...but, I don't need that anymore! I think.


Now, as for how to change the text: upon clicking/touching the button, in the same Action method just put...no, wait, I'm going to call towards a Reset method, which will then re-set the integer, re-pull the button component and re-allocate an integer to it, which will change the text. Reason for calling a method, is so that I don't re-add all of this in the script for each different action, which is wasteful.


So, how about if you want to change the text, without implementing that action? The mythical drag&drop, how do we do that??

Again, gotta love Unity, and I guess game engines in general: I started watching what appeared to be an interesting video on how to add this via the script...then, I realised: why don't I go in Unity, just add an event trigger to the button, select...End Drag (lol not Drag, which upon testing, triggered every time you drag away from the button!) as the trigger, which intuitively sounds like it'll do something once I drag&drop, then say that when it triggers, I invoke the Reset method?


It worked like a charm!


Now, perhaps I need to tackle the graphical fade/transition elephant in the room...


And now, for some imagery!

Behold, the Unity screen in all its glory! The arrows and right-most thought button were the previous move and jump buttons, respectively, to be removed once I'm 100% that the new thought buttons work.

The Button text is just a placeholder, which gets changed by the script at runtime.


And, ze script! Well, a snapshot of it, but it highlights how, for now, a simple IF statement and some integer placement can handle the buttons. I am dubious, though, of how robust this will be when things get more complicated...we shall see!


Your laboring scripter,


Stefano Ronchi


 
 
 

Recent Posts

See All
Do it the Sims way.

Sims 4 is on Game Pass, so we rejoiced. Not with wild, uncontrolled euphoria, mind you: just a little thrill of excitement at getting to...

 
 
 

Comments


Post: Blog2_Post

Subscribe Form

Thanks for submitting!

  • Facebook
  • Twitter
  • LinkedIn

©2022 by Star Cake Inc.. Proudly created with Wix.com

bottom of page