/// <inheritdoc /> public virtual void ApplyMaterialPatch(Material material, MWMaterial patch) { if (patch.Color != null) { _materialColor.FromUnityColor(material.color); _materialColor.ApplyPatch(patch.Color); material.color = _materialColor.ToColor(); } if (patch.MainTextureOffset != null) { _textureOffset.FromUnityVector2(material.mainTextureOffset); _textureOffset.ApplyPatch(patch.MainTextureOffset); material.mainTextureOffset = _textureOffset.ToVector2(); } if (patch.MainTextureScale != null) { _textureScale.FromUnityVector2(material.mainTextureScale); _textureScale.ApplyPatch(patch.MainTextureScale); material.mainTextureScale = _textureScale.ToVector2(); } if (patch.MainTextureId != null) { var textureId = patch.MainTextureId.Value; textureAssignments[material.GetInstanceID()] = textureId; if (patch.MainTextureId == Guid.Empty) { material.mainTexture = null; } else { MREAPI.AppsAPI.AssetCache.OnCached(textureId, tex => { if (!material || textureAssignments[material.GetInstanceID()] != textureId) { return; } material.mainTexture = (Texture)tex; }); } } }
/// <inheritdoc /> public virtual void ApplyMaterialPatch(IMixedRealityExtensionApp app, Material material, MWMaterial patch) { if (patch.Color != null) { _materialColor.FromUnityColor(material.color); _materialColor.ApplyPatch(patch.Color); material.color = _materialColor.ToColor(); } if (patch.MainTextureOffset != null) { _textureOffset.FromUnityVector2(material.mainTextureOffset); _textureOffset.ApplyPatch(patch.MainTextureOffset); material.mainTextureOffset = _textureOffset.ToVector2(); } if (patch.MainTextureScale != null) { _textureScale.FromUnityVector2(material.mainTextureScale); _textureScale.ApplyPatch(patch.MainTextureScale); material.mainTextureScale = _textureScale.ToVector2(); } if (patch.MainTextureId != null) { var textureId = patch.MainTextureId.Value; mainTextureAssignments[material.GetInstanceID()] = textureId; if (patch.MainTextureId == Guid.Empty) { material.mainTexture = null; } else { app.AssetManager.OnSet(textureId, tex => { if (!material || mainTextureAssignments[material.GetInstanceID()] != textureId) { return; } material.mainTexture = (Texture)tex.Asset; }); } } }