Override Busy text

Hello EveryOne,
I wanted to replace Busy Text in the TurnBaseCourse inspirating me from button Action creation.
So in the BaseAction Script I have had public abstract String under the GetActionName one;

    public abstract string GetActionName();

    //new line
    public abstract string CurrentActionName();

then as for GetActionName, i have had new override string in each action you have, move rotate, etc. under the GetActionName:

Calling them alternativly running and spinning.

     public override string GetActionName()
    {
        return "Move";
    }

    public override string CurrentActionName()
    {
        return "Running";
    }

Then in the ActionBusyUI Script i’ve created a serializedField for the textmeshpro:

[SerializeField] private TextMeshProUGUI currentAction;
Don’t forget to save and drag the BusyUI TextMeshPro in the new field in unity :slight_smile:

Then I’ve created the updateText method to replace the actual text (in the ActionBusyUI script) where I reach on the selected action:

    private void UpdateActionText()
    {
        BaseAction SelectedAction = UnitActionSystem.Instance.GetSelectedAction();
        
        currentAction.text = SelectedAction.CurrentActionName();
    }

And to finish I add this UpdateActionText method in the UnitActionSystem_OnBusyChanged(object sender, bool isBusy) method:

    private void UnitActionSystem_OnBusyChanged(object sender, bool isBusy)
    {
        if (isBusy)
        {
            Show();
            UpdateActionText();
        }
        else
        {
            Hide();
        }
    }

That’s all :slight_smile:
Now when I move, the running text appears in the old busy panel. The same when I spin :wink:


Hoping it Help.
Thanks a lot for your course.
Have a nice day.
François

2 Likes

That’s a nice addition, good job!

1 Like

Thanks master ! :slight_smile:
So I go to post a way to replace and override image button now, following your way to code (I hope so :slight_smile: )
Schuus

François

PS/ Just say me if it’s the good place to post to help the others?

Privacy & Terms