Is there a way to get access or maybe generate shapes texture/material and use it say in UI.Image ?

Avatar
  • updated
  • Answered

In order to able use it with own custom shaders over UI.Image component?

So far my tests to apply Rectangle.MeshRenderer.material[0] to Image.material were causing editor crashes.

I use actual component instances in code, static type access above is just an example.

for example, 


when Image has UIDissolve component  from https://github.com/mob-sakai/UIEffect

GetComponent<Image>().material = rectangle .GetComponent<MeshRenderer>().materials[0];

this will crash editor.

I am aware that it is not Shapes problem but some Unity bug since nothing should crash editor, but i am interested in practical way applying different effects to shapes without going deep into source code.

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Answered

I'm not sure why Unity would crash, but, generally directly accessing the materials like this is not the intended use of Shapes, as Shapes needs full control over the materials used on your objects. Anything outside of that you're kinda on your own I'm afraid!

That said, looking at the existing source code for how parameters are implemented should give you an idea how you can add more features if you like - usually there's the .cs file, the editor inspector, and the shader core file for every shape. The rest is generated by the codegen!

Avatar
Freya Holmér creator
  • Answer
  • Answered

I'm not sure why Unity would crash, but, generally directly accessing the materials like this is not the intended use of Shapes, as Shapes needs full control over the materials used on your objects. Anything outside of that you're kinda on your own I'm afraid!

That said, looking at the existing source code for how parameters are implemented should give you an idea how you can add more features if you like - usually there's the .cs file, the editor inspector, and the shader core file for every shape. The rest is generated by the codegen!