Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Accessing probuilder material palette in code

Discussion in 'World Building' started by KRWatkins, Nov 9, 2022.

  1. KRWatkins

    KRWatkins

    Joined:
    Jun 25, 2019
    Posts:
    6
    Hello I am trying to design a surface manager and would like to use the arrays presented in the Material Pallete scriptable objects Pro Builder uses. Please excuse any improper terminology or redundancies as I'm not a great programmer. I see the MaterialPalette is an internal sealed class and therefore cannot be accessed outside. In my surface manager I made a reference to a scriptable object called 'test' since I could not get access to MaterialPalette as a variable. I tried to see if 'test' could access the array, I tried to cast test as a material palette but cannot because it's protection, I tried to cast it as an object since Scriptable Object inherits from it and no dice. I hope this can be done, I'd rather not create a new scriptable object with arrays of materials if probuilder is already doing that.

    Learned that internal: Can only be accessed from within the assembly it is defined (or friend assemblies). sealed: Cannot be inherited. Tried to give the surface manager the ProBuilder namespace thinking that'd make it within the assembly but I'm pulling at straws here.

    As of right now I'm suspecting I may have to just make my own arrays since I don't think I can get the one from the palette. At least I can use Probuilder.Face() to get the current material on whatever I'm raycasting at to compare with.

    I've looked through Probuilder.MaterialEditor, Probuilder.ProBuilderEditor, Probuilder.MeshEditor and anything like that look for another more explosed class that uses MaterialPalette. In MaterialEditor.cs there's a public static MaterialPalette CurrentPalette which looks like it's checking it for an array of materials but I'm already in over my head and should move on to something easier.
     
    Last edited: Nov 10, 2022