public override void Init() { if (!ObjectPrivate.TryGetFirstComponent(out Mesh)) { Log.Write(LogLevel.Error, LogTag, "No MeshComponent found! Aborting."); return; } else { List <RenderMaterial> materials = Mesh.GetRenderMaterials().ToList(); if (materials.Count == 0) { Log.Write(LogLevel.Error, LogTag, "GetRenderMaterials() == null! Aborting."); return; } else { foreach (RenderMaterial material in materials) { if (material == null) { Log.Write(LogTag, "Material is null"); } else { Log.Write(LogTag, material.Name); Log.Write(LogTag, material.ToString()); } } } Log.Write(LogTag, $"Mesh.IsScriptable={Mesh.IsScriptable}"); if (!Mesh.IsScriptable) { Log.Write(LogLevel.Warning, LogTag, $"MeshComponent {Mesh.Name} is not scriptable"); } SubscribeToScriptEvent(AbsorptionCommand, (ScriptEventData data) => { ISimpleData idata = data.Data.AsInterface <ISimpleData>(); RenderMaterial m = Mesh.GetRenderMaterial(materials[0].Name); MaterialProperties p = m.GetProperties(); p.Absorption = Absorption; m.SetProperties(p, Duration, InterpolationModeParse(Interpolation)); }); SubscribeToScriptEvent(BrightnessCommand, (ScriptEventData data) => { ISimpleData idata = data.Data.AsInterface <ISimpleData>(); RenderMaterial m = Mesh.GetRenderMaterial(materials[0].Name); MaterialProperties p = m.GetProperties(); p.Brightness = Brightness; m.SetProperties(p, Duration, InterpolationModeParse(Interpolation)); }); SubscribeToScriptEvent(TintCommand, (ScriptEventData data) => { ISimpleData idata = data.Data.AsInterface <ISimpleData>(); RenderMaterial m = Mesh.GetRenderMaterial(materials[0].Name); MaterialProperties p = m.GetProperties(); if (!Sansar.Color.TryParse(tint.ToRGBA(), out p.Tint)) { Log.Write(LogLevel.Error, LogTag, "TintCommand: Failed to parse as Sansar.Color"); return; } m.SetProperties(p, Duration, InterpolationModeParse(Interpolation)); }); SubscribeToScriptEvent(EmissiveCommand, (ScriptEventData data) => { ISimpleData idata = data.Data.AsInterface <ISimpleData>(); RenderMaterial m = Mesh.GetRenderMaterial(materials[0].Name); MaterialProperties p = m.GetProperties(); p.EmissiveIntensity = EmissiveIntensity; m.SetProperties(p, Duration, InterpolationModeParse(Interpolation)); }); SubscribeToScriptEvent(FlipbookCommand, (ScriptEventData data) => { ISimpleData idata = data.Data.AsInterface <ISimpleData>(); RenderMaterial m = Mesh.GetRenderMaterial(materials[0].Name); MaterialProperties p = m.GetProperties(); p.FlipbookFrame = Frames; m.SetProperties(p, Duration, InterpolationModeParse(Interpolation)); }); } }