microsoft / MixedReality-SpectatorView

Mixed reality spectator experiences
MIT License
193 stars 114 forks source link

can not sync Material modified by MaterialPropertyBlock #350

Open tjsgtql opened 4 years ago

tjsgtql commented 4 years ago
MaterialPropertyBlock materialProperty;
Renderer renderer;
int propertyID;

void Start()
{
    materialProperty = new MaterialPropertyBlock();
    renderer = GetComponent<Renderer>();
    propertyID = Shader.PropertyToID("_Color");
    InvokeRepeating ("ChangeColor",1,1);
}

void ChangeColor()
{
    Color color=new Color(Random.Range(0f,1f),Random.Range(0f,1f),Random.Range(0f,1f));
    materialProperty.Clear ();
    renderer .GetPropertyBlock(materialProperty);
    materialProperty.SetColor(propertyID ,color);
    renderer.SetPropertyBlock(materialProperty);
}
matthejo commented 4 years ago

I've just merged a PR into the master branch that enables this. https://github.com/microsoft/MixedReality-SpectatorView/pull/351

You have to add two usings to any file that uses MaterialPropertyBlock:

using Microsoft.MixedReality.SpectatorView;
using MaterialPropertyBlock = Microsoft.MixedReality.SpectatorView.MaterialPropertyBlock;

You also need to make sure the feature synchronization is enabled, if you've customized your performance parameters in the Spectator View -> Edit Global Performance Parameters menu.

image

Please let me know if you hit issues with this!

tjsgtql commented 4 years ago

I've just merged a PR into the master branch that enables this.

351

You have to add two usings to any file that uses MaterialPropertyBlock:

using Microsoft.MixedReality.SpectatorView;
using MaterialPropertyBlock = Microsoft.MixedReality.SpectatorView.MaterialPropertyBlock;

You also need to make sure the feature synchronization is enabled, if you've customized your performance parameters in the Spectator View -> Edit Global Performance Parameters menu.

image

Please let me know if you hit issues with this!

Thank you for your prompt response, I may have to test for a few days. Waiting for my good news!

tjsgtql commented 4 years ago

When I enabled the feature synchronization, the color can be synchronized. And, I think that the textures can also be synchronized?I add the propertyName "_MainTex", and it was not worked. supplement,I have not pulled you commit 11a030d.