Skip to main content

047. Unity3d Tutorial - GUITexture Healthbar 3/3

See video

We continue with another tutorial in our Hack And Slash demo made with the Unity3d Game Engine.

In this video, we will continue to set up our healthbar prefabs for our player and enemies.

Tags:

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Offline
Joined: Dec 23 2010

Around 1:18 you use :
_display = gameObject.GetComponent>GUITexture<();
(i know >< should be the other way around but the text will disappear in the comment if I reverse them)
is there any difference between that line and this one(in this case):
_display = gameObject.guiTexture;
I used the second and I have the same results.

Oh and happy new year !

Offline
Joined: Jan 9 2011

For some reason I'm getting this error when I run the game.

MissingReferenceException: The object of type 'GUITexture' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.GUITexture.get_pixelInset () (at E:/BuildAgent/work/71ca6fec1b41cc30/Runtime/Export/Generated/Graphics.cs:3141)
VitalBar.ChangeHealthBarSize (Int32 curHealth, Int32 maxHealth) (at Assets/CustomScripts/HUD Classes/VitalBar.cs:50)
Messenger`2[System.Int32,System.Int32].Broadcast (System.String eventType, Int32 arg1, Int32 arg2, MessengerMode mode) (at Assets/CustomScripts/CharacterClasses/CSMessenger Extended/Messenger.cs:179)
Messenger`2[System.Int32,System.Int32].Broadcast (System.String eventType, Int32 arg1, Int32 arg2) (at Assets/CustomScripts/CharacterClasses/CSMessenger Extended/Messenger.cs:170)
PlayerCharacter.Update () (at Assets/CustomScripts/CharacterClasses/PlayerCharacter.cs:4)

Not quite sure what its getting at. I've checked my code vs the tutorials and it looks fine. I thought it might be the texture was missing from the healthbar but I made sure that it was still in the correct path. I even reassigned it to the prefab.