Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Hi,
How can I change a color of a 3D label by clicking on a button?
I tried to write the code below but it doesn't work:
$scope.SwitchConf = function () {
$scope.app.view.Home.wdg["3DLabel-2"].fontColor= 'red';
When I click on the button, the function "SwitchConf" is called but the color don't change.
Is it possible to do this by this way?
Thanks for your help...
Maxime.
Solved! Go to Solution.
Hi, Maxime
What type of project did you create? Mobile or 3D eyewear?
I tried both codes below and they work in my mobile project, in preview and on device.
$scope.setColorRGB = function(){
$scope.view.wdg['3DLabel-1'].fontColor = "#ff0000";
}
or
$scope.setColorName = function(){
$scope.view.wdg['3DLabel-1'].fontColor = "red";
}
Have you tried the code on device?
Sometimes it doesn't work in preview, but works on device.
Hi @dsgnrClarK ,
I created a mobile project.
I tried both code you send me, but in my app it doesn't works (in preview and on device).
I created also a new project and test the code but it doesn't work
I changed the code for check my function is called:
$scope.SwitchConf = function () {$scope.view.wdg['3DLabel-2'].visible = false;}
The result is OK.
Ok thanks,
I tried your code, and it's work.
So I copied and this is OK in my project also.
But I saw when I remove the line for modify the text, the color don't change. Do you know why?
The view does not seem to be refreshing...
Hi, @MaximeDid
Which version of Vuforia Studio and browser are you using?
Could you attach your project?
Hi @dsgnrClarK ,
I am using VuforiaStudio 8.5.15.4805 and Chrome Version 87.0.4280.88.
Please find my project in attachment.
Now I see the issue, but I don't know the mechanism behind it.
Sorry about that.
OK no problem.
I will only have to change the text to update the color.
Thank you for your help.
It looks like an update bug a work around
$scope.setColorName = function(){
var currentText = $scope.view.wdg['3DLabel-1'].text;
$scope.view.wdg['3DLabel-1'].fontColor = "red";
$scope.view.wdg['3DLabel-1'].text = currentText+ " ";
$timeout(function() {
$scope.view.wdg['3DLabel-1'].text = currentText;
}, 500);
}