- Home /
Toggle ON/OFF MaterialChange
Pretty basic question but i can't seem to get it to work. I want to change the material of an object when it's stored in the array safedArray. I also want the material to change back when it's not stored in the array anymore.
This is my basic c# function:
public void ShowMarker(bool show, string key)
{
// only stores are supported
var label = _city.FindStore(key);
if (!label)
{
Debug.LogError("No store with key '" + key + "' found");
return;
}
label.GetComponent<MeshRenderer>().material = show ? _selectedMaterial : _normalMaterial;
}
It gets its arguments from this JavaScript-function:
mergeInto(LibraryManager.library, {
UnityReceivedTap: function (str) {
var safedArray =[];
var input;
input = Pointer_stringify(str);
if(input)
{
var receiverArray = input.split(';');
}
var storekey = receiverArray[0];
if(safedArray.includes(storekey))
{
SendMessage('NATIVE_BRIDGE', 'PostHideMarker', storekey);
safedArray.splice(storekey);
}
else
{
safedArray.push(storekey);
SendMessage('NATIVE_BRIDGE', 'PostShowMarker', storekey);
}
},
});
Changing the material is already working. Changing the material back is not and i don't really get why.
Your answer
Follow this Question
Related Questions
How do perform the operations as per the commands at client side in socket unity? 0 Answers
GetComponents array in C# error ? 4 Answers
Why ExecuteInEditMode Always Causes NullReferenceException Errors Even In Clamping!! 2 Answers
How do I know the reason of not running my game smooth? 0 Answers
The name 'TrackManager' does not exist in the current context [Unity Vuforia Ground Plane Project] 0 Answers