Showing widget on specific camera only

Hi!

I'm a little bit lost... not sure if I have to use Event Trigger, Condition flag, Script, ... for a simple thing.

Actually, I've two buttons for cockpit and roll bar camera to show 'On board' on the upper left. I have also a TV1 camera button to go out of the car and hide this onboard widget.
But if someone use built-in ATVO camera instead of my camera buttons then it will not show my onboard widget or the widget will remain if they don't use my TV1 button.

So I'm wondering if it's possible to track the current camera and then display my widget on specific camera (cockpit and roll bar).

Do I need to use 'Camerachanged' in Event trigger to track the current camera?
If so, do I need to write a 'Condition script' about camera?
I thought it would be more simple...



Posts: 785
You can probably do a simple check for the current camera group name. This obviously assumes there are no additional onboard cameras (I think there are more built in, and of course someone can always create their own). There is no way to tell if a camera is "onboard" or not so you'll have to rely on the name.

public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var name = sim.CameraManager.CurrentGroup.Name;
if (name == "Cockpit" || name == "Rollbar")
{
// Show onboard
}
else
{
// Hide onboard
}
return null;
}
Thank you Nick for this script, it works well. Now I know how to make a widget visible or no ;)

BTW 'Rollbar' need to be written 'Roll Bar'... and I added also the Gyro cam:
if (name == "Cockpit" || name == "Roll Bar" || name == "Gyro")
Posts: 81
Bumping this a bit!

So I'm getting this to work and it seems to do the job, however I have the widget fade in with a AnimateShow("500")

The problem this causes is if I change from one camera on the list to another (for example if we're using Jean's list, from Cockpit to Roll Bar) the widget fades in again every time. What's the easiest way to avoid this? I thought about making the script disable itself if it shows the widget and make a separate script to do the opposite and hide the widget, but I feel like there's an easier solution. plus I didn't see anywhere on here how to interact with triggers in scripts
Posts: 785
It sounds like you're showing the widget from within the script (with "AnimateShow"). In that case, you can simply check if the widget is visible already before calling AnimateShow. I think you can simply check for "widget.IsVisible".
Posts: 8
Would anybody be willing to give a quick noob overview of how to edit and insert this script into my theme? It seems like maybe there's more to the "// Show onboard" and "// Hide onboard" bits in the example, plus I haven't dealt with putting scripts into my theme yet. This looks like a perfect opportunity to learn.
Posts: 287
In the exemple Nick only exlain how to detect if a camera is selected.

When you have // in script the text after are comments.

So you have to find widget and specify if you want to show them or not. The best way is perhaps to say in your script to do something with a storyboard.

If you search on the forum you can find a lot of exemple of script, but it is not so easy to know what to do.
Posts: 8
Gotcha, thanks for the reply Emmanuel. I have a history of interpreting code but not so much writing it. If I continue to enjoy doing this, it might be a good time to start learning some more.