I think you need some sort of way to tell how long the mouse button has been pressed down, and add to the power level with that. Then once the mouse button is released, you can use a method to fire based on the power gained while the button was down.
if (Input.getMouseButton(0))
{
//add amount to power level every second or however often you want
//when mouse is released
if (Input.getMouseButtonUp(0))
{
//fire something
}
}
This is the way I would go about something like this. You would also have to have a way to make sure the mouse is on the button and not just anywhere on the screen, so I would test for that as well. You might have to play around with it for a little bit, but it should work in a similar way to this.
//checks where the mousebutton position is
public Vector2 mousePosFromEvent = Event.current.mousePosition;
//the rect where the mouse position must be to use the function mouse up
public Rect eersteButton;
//release bool stand for now on false because it needs to be just pressed one time
public bool laatlos = false;
void OnGUI() {
//describe the size and position of the button rect
eersteButton = new Rect(10, 70, 100, 100);
//if mouse is on the current rect(button)
if(eersteButton.Contains(Event.current.mousePosition))
{
//if mouse up in the current rect(button)
if(Input.GetMouseButtonUp(0))
{
//realeas = true
laatlos = true;
print(laatlos);
}
}
//define the button to show up and if clicked
if(GUI.RepeatButton(new Rect(eersteButton), "button1"))
{
//checks if the button isn't released before and if the mouse is on te current rect position/size (button)
if(eersteButton.Contains(Event.current.mousePosition) && laatlos == false)
{
damage = +0.15f;
ApplyDamage();
}
}
}
maybe there is an easier option to do this but this works fine for me (it also works on a mobile phone)