playMaker

Author Topic: Set material float on a UI Image object? [SOLVED]  (Read 5359 times)

CorB

  • Playmaker Newbie
  • *
  • Posts: 4
Set material float on a UI Image object? [SOLVED]
« on: November 25, 2021, 07:16:25 PM »
Hi there,
First post here, so first of all a big thank you to the Playmaker creator and the community. The tool itself and all these custom actions are just amazing :) Being using it for a couple of month now and I truely enjoy it !

I'd like to do some shader shenanigans on UI elements and I want to control custom shaders/material properties through FSMs.

Although it works just fine on Mesh Renderers, looks like I can't use Get Material / Set Material Float on an Image object.
I get an error saying that it requires a renderer and "Click to add required component" just adds a mesh renderer.

I can drag and drop the material component on the FSM and use Set Material Float that way without any error... But then the modification applies to the material itself and all game objects using it.

Guess I could just use 3D objects in the canvas but that feels a bit dirty. Also maybe I'm doing it wrong, being comfortable enough with 3d objects and shaders but the canvas and 2D stuff are still confusing for me - so any hint would be great :)
« Last Edit: November 26, 2021, 10:15:52 AM by CorB »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Set material float on a UI Image object?
« Reply #1 on: November 26, 2021, 09:23:04 AM »
Hi.
For changing material data on the object only, you need to use : Set Material Property Block (Ecosystem)
But for Ui this does not work, see this post on the unity forum :

https://forum.unity.com/threads/big-problem-with-lacking-materialpropertyblock-for-ui-image.506941/

so for now it looks that you have to do it the 'dirty' way ;)

CorB

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Set material float on a UI Image object?
« Reply #2 on: November 26, 2021, 10:14:22 AM »
Oh ok I see, so that's not even a Playmaker related issue. Thanks for claryfying that.

Well then problem solved, back to my comfort zone with 3d objects ;D
Thanks !