- Home /
Question by
AngelFox22 · Apr 23, 2012 at 03:20 PM ·
guicounterintegerprogress bar
Need help with basic magic system
I have a number (6) I want to display and bring up within the code. The magic used changes when number reaches 3. Once the player uses all points the player loses.
Trying to figure this out for ages but no matter how I go about it always seems to get error messages. Please help.
Code so far:
var windowRect : Rect = Rect (20, 20, 120, 50);
var currentMagic: int = 6; var aTexture : Texture;
function OnGUI () { windowRect = GUI.Window (0, windowRect, WindowFunction, "Magic Point");
}
function WindowFunction (windowID : int) {
if(!aTexture){
Debug.LogError("Assign a Texture in the inspector.");
return;
}
GUI.DrawTexture(Rect(10,10,60,60), aTexture, ScaleMode.ScaleToFit, true, 10.0f);
// GUI.Label (Rect (10, 10, 100, 20), currentMagic);
}
function Update() {
//magic system
var particleAnimator : ParticleAnimator = GetComponent(ParticleAnimator);
var modifiedColors : Color[] = particleAnimator.colorAnimation;
if(Input.GetMouseButtonDown(0))
particleEmitter.emit = true;
modifiedColors[0] = Color.blue;
particleAnimator.colorAnimation = modifiedColors;
currentMagic--;
if(Input.GetMouseButtonUp(0))
particleEmitter.emit = false;
if(Input.GetMouseButtonDown(1))
particleEmitter.emit = true;
modifiedColors[0] = Color.white;
particleAnimator.colorAnimation = modifiedColors;
currentMagic--;
if(Input.GetMouseButtonUp(1))
particleEmitter.emit = false;
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613070640im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Shot Counter Question 2 Answers
OnGUI sliders only accept float? C# 2 Answers
Little image next to GUI ? 1 Answer
Gui Counter Problem 1 Answer