Unity 5 Tutorial: Turn Based Battle System #07 - Gui Improvements

Unity 5 Tutorial: Turn Based Battle System #07 - Gui Improvements

xOctoManx

8 лет назад

14,330 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@jespernilsson9435
@jespernilsson9435 - 02.02.2016 20:43

Good work m8!! You even got me interested in the UI stuff again with this series, so stuck in code lately that i forgot how fun it is =)

Ответить
@danieljennings4162
@danieljennings4162 - 18.09.2016 18:08

Great work first off. I am having a small problem with the scaling of the text. The targetButton is not scaling right(only moves up slightly when deactivating the height in "Spacer"), also the text is not centered anymore and the Max size will not let me go bellow the Font size(14).

Ответить
@PatoMiner
@PatoMiner - 21.09.2016 21:59

Hi! I'm having trouble when I add the 2 components in order to get a single button displayed correctly. I can't set the anchors/size right of the Button under Spacer (I can't move anchors nor resize the button) so I get the button fitting the whole spacer panel :P.

PD: I hate UI stuff (at least until I get the grip of how it works perfectly)

Ответить
@PatoMiner
@PatoMiner - 22.09.2016 21:55

I'm making progress! So..at the end of this part of the tutorial, I'm having the Buttons cloned and created in the Spacer right at the start, and not when the progressbar is full. What am I missing?

Also: Is this on the Asset Store of Unity? It would be great :D

Ответить
@tadpolily
@tadpolily - 16.12.2016 23:36

What is supposed to go into the enemy prefab variable in the Enemy Select Button script? Adding EnemyButtons() method to start has caused my screen to go wonky and buttons don't show up

Ответить
@pierrecassuto
@pierrecassuto - 24.04.2017 23:48

Hi OctoMan,
Thank you for these videos. Really enjoying learning with you!

Quick question: I get error CS029: Cannot implicitly convert type 'UnityEngine.UI.Text[]' to 'UnityEngine.UI.text"
This is related to the line 'Text buttonText = newButton.transform.FindChild ("Text").gameObject.GetComponent<Text> ();'

Do you know where I may have made a mistake? I'm stumped...

Ответить
@echardeengine227
@echardeengine227 - 30.04.2017 04:23

Hi OctoMan,
I'm French and i love your videos !
You are a great teacher ^^
Thank you

Ответить
@BasicallyASlug
@BasicallyASlug - 05.05.2017 04:38

Hi OctoMan, when my heros reach the ADDTOLIST state, nothing happens, could you please help me with this if possible?

Ответить
@Ett.Gammalt.Bergtroll
@Ett.Gammalt.Bergtroll - 15.05.2017 17:15

Newer versions of Unity has a new element to for the Horizontal Layout Group called "Control Child Size" with Width and Height as well.

EDIT: (For anyone else viewing this tutorial with a newer version of Unity): Just leave those as default and it will work.

Ответить
@Jack-ik4qu
@Jack-ik4qu - 23.07.2017 20:26

Hey Octoman. Thanks a million for the tutorial! So I'm having huge trouble with the layout groups and inheriting size. Using Unity 2017.1, Child Controls Size and Child Force Expand do not match this tutorial at all. I can't get text Max Size to adjust the button height to save my life. Keeps smashing them all to the left or expanding them to the full spacer size. When I start the game, the buttons are huge and greatly overfill the screen. Help would be much appreciated!

Ответить
@chaolihai-innit
@chaolihai-innit - 09.08.2017 18:06

Wooo! This is getting kinda tough, but still, thank you very much!

Ответить
@ThePerro
@ThePerro - 01.09.2017 15:31

When I add the vertical layout group to the spacer, the enemy panel just disappears and I can't get it back? Can you help me?

Ответить
@Mantuyama
@Mantuyama - 20.09.2017 15:48

Hello OctoMan! Thank you for incredibly useful tutorials. I ran into a small problem. When I compile and run the script. the Target Buttons spawn at the top of the Hierarchy and not under the Spacer. Also, Unity states that Find Child function is obsolete and that I should use Find instead. Any idea on how to fix the Target Buttons problem? Thank you.

Ответить
@justinwhitehead8014
@justinwhitehead8014 - 06.02.2018 22:05

Love the videos! Thanks SO much! One thing in terminology though, = ("equals") is an assignment operator, and == ("is equal to") is a relation operator. Its a dumb, minor, grammar thing, but you've been referring to = as "is equal to" for each video

Ответить
@presin16
@presin16 - 15.02.2018 16:31

Octoman, I get an error that's keeping my BattleStateMachine from compiling. "Assets/Scripts/BattleStateMachine.cs(89,25): error CS0246: The type or namespace name `EnemySelectButton' could not be found. Are you missing a using directive or an assembly reference?"

I've re-watched the segment where that is set up several times, and believe all my code matches what's in the video, but I don't know enough C# to know where I've gone wrong. Any idea? Any Unity changes since this was made that I might need to account for?

Love the series. Thanks!

Ответить
@snork10
@snork10 - 28.03.2018 15:16

Very good tuts! But please zoom in more when you are writing code. Hard to see with bad eye sight :/

Ответить
@mikeh6452
@mikeh6452 - 01.07.2018 15:39

hello al I'm currently at 7 ins into the video and my layout buttons are laying out correctly until I add a bunch of buttons then the new buttons will overflow through the bottom of the spacer object, any suggestions? Best Fit is set for the text the vertical layout on the spacer is set so child Controls size width is true height is false same for the option child force expand
as for the horizontal layout on the button itself child control size = false child force expand = false
the layout element is set flexible height and width = 0 . As far as I can tell that is exactly what needs to happen and it nearly works but in the end doesn't because the buttons overflow the spacer

Ответить
@darrc13
@darrc13 - 05.10.2018 03:32

I'm having a small issue using unity 2018.2.7f1, for the most part everything works fine, but the buttons dont seem to go to the right place when theyre created.I thought they werent being created at all but after a little testing i figured out that they were being created in the scene, just off out of view of the camera, and very big. Any advice on what might be going on here would be greatly appreciated.

Ответить
@dzulfaqqoramin659
@dzulfaqqoramin659 - 02.11.2018 11:25

Hi guys! Thank you octobro to continue this series to the end.
I got small problem, i was get this phase done earlier. But if I add another enemy with different name, the button is not spawn at all. I got confused how to fix it. Anyone would please tell me how to do that ? T^T

Ответить
@danh9676
@danh9676 - 05.01.2019 19:03

Leave it to me to get stuck for a day on the enemy buttons not instansiating.

This is a PSA, make sure your enemy select button script is attached to your button prefab

However for some reason the background disappears just leaving the text. It's working though

Ответить
@omnidps
@omnidps - 29.04.2019 18:26

Hi, ive been trying to fix a problem with this for hours, where the scale changes when you press play(am at the end of the video). I.e, the scale of the instantied buttons isnt, 1,1,1 but some other andom number, and they dont space them out evenly. If i manually change them to 1,1,1 , it looks like how its supposed to. Would it be something wrong with the code?

Ответить
@DanIel-fl1vc
@DanIel-fl1vc - 10.05.2019 13:46

This is starting to get hard to follow, I hope there will be some kind of review of everything later in the tutorial series. Otherwise I'll have to go through all the scripts line by line and figure out what the hell is going on.

Ответить
@shuka1080
@shuka1080 - 12.05.2019 21:28

hi octodude, I really like your tutorial and ive been following it so far. I was wondering why did the enemy button not showed up but instead it gave me this NullReferenceException: Object reference not set to an instance of an object
BattleStateMachine.EnemyButtons () (at Assets/scripts/BattleStateMachine.cs:100)
BattleStateMachine.Start () (at Assets/scripts/BattleStateMachine.cs:50) . I thought the name of the enemy gameobject was different from the one i wrote down in the script but i've tried it and nothing happens. Can you somehow enlighten me where it went wrong?

Ответить
@ryanhaberle4884
@ryanhaberle4884 - 18.06.2019 06:48

Yo thanks for the help. I have learned tons about unity that I wasn't sure about. These videos helped solidify some topics I didn't quite understand in school as well. OctoMan will definitely be a hidden boss in my game(If I ever release it.)

Ответить
@EonsAway
@EonsAway - 21.09.2019 14:29

Oii Mate, i'm currently stuck at the following:

NullReferenceException: Object reference not set to an instance of an object
BattleStateMachine.EnemyButtons () (at Assets/Scripts/BattleStateMachine.cs:96)
BattleStateMachine.Start () (at Assets/Scripts/BattleStateMachine.cs:45)

if i play the scene it instantiate a Target1Button (Clone)at the top of the hierarchy instead of in the spacer.


In the battlemanager i have EnemyButton > Target1Button conncented and spacer connected to the spacer
In the Target1Button the script EnemySelectButton is also connected


Thanks!

Ответить
@FyresGames
@FyresGames - 06.01.2021 01:54

If you get huge buttons for unknown reasons you just need to edit newButton.transform.SetParent(Spacer); for newButton.transform.SetParent(Spacer,false);

Ответить
@ling4217
@ling4217 - 15.03.2021 18:18

code in BattleStateMachine:
GameObject newButton = Instantiate(enemyButton); //without "as GameObject"
Text buttonText = newButton.transform.Find("Text").gameObject.GetComponent<Text>(); //use Find instead of FindChild


is that ok for those little change? cause i dont know what meaning in "as" , and FindChild seems outdated in Unity

Ответить
@mirageowl
@mirageowl - 15.06.2021 17:59

When I first watched these videos years ago they helped me a lot since I was not very familiar with Unity and your videos helped me learn. Now years later I am still coming back to these videos to understand what you are doing and implementing them in my own way, making changes along the way. While your naming can be confusing your explanations are always clear, really thanks a lot for these videos!

Ответить
@swellyswells9644
@swellyswells9644 - 27.09.2021 23:04

Hey I’m loving these videos thank you so much! If you or anyone can help though, my text on my button disappears when adding the horizontal layout component and toggling the true and false options won’t help either. My text is set to best fit min 10 max 30 and my spacer is about the same size as yours but slightly bigger. Thanks in advanced for anyone with ideas!

Ответить
@lucasvieira7391
@lucasvieira7391 - 21.06.2022 22:33

Se liguem que vocês podem estar usando o TextMeshPro, e não vai funcionar o Text
na linha: Text buttonText = newButton.transform.Find("Text").gameObject.GetComponent<Text>();
precisa ser: TextMeshProUGUI buttonText = newButton.GetComponentInChildren<TextMeshProUGUI>();

Ответить
@Franklinsbrother
@Franklinsbrother - 05.09.2022 22:45

I have posted comments here at least twice about inquiring for help on the text in the center box disappearing, and both got deleted. Is there a problem with that?

Ответить
@samimikaelofficial
@samimikaelofficial - 21.08.2023 00:07

Hey everyone! I noticed that if you're using a newer version of Unity, the UI Button's text component has been replaced with TextMeshPro. This means that you need to pay attention in your scripts as well. To make this change, you should add 'using TMPro;' at the beginning of your script. Additionally, when you come across the part where you used to retrieve the Button's text component with the line 'Text buttonText = newButton.transform.Find("Text").gameObject.GetComponent<Text>();', replace it with 'TMP_Text buttonText = newButton.transform.Find("Text").gameObject.GetComponent<TMP_Text>();'. There you go!

Ответить
@imperiumsam6512
@imperiumsam6512 - 12.11.2023 04:20

Help please: when I use the vertical layout group on the Spacer everything works perfectly fine, but as soon as I add the horizontal layout group, the text disappears completely. How do I fix this?

Ответить
@razore3rus206
@razore3rus206 - 26.02.2024 15:43

The button wouldn't appear until I figured out that instead of 'Text', mine said 'Text (Legacy)'. Once I changed it, the button appeared on start. Maybe it will help someone.

Ответить
@OctoManGames
@OctoManGames - 29.04.2019 19:00

to avoid strange scaling: newButton.transform.SetParent(Spacer, false);

Ответить