Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating MaterialID in MetaCGOptions at Runtime
#1
Does updating MaterialID in MetaCGOptions on an already generated segment switch the active material?

I have a Volume Mesh with two material slots, id 0 and id 1. I want to flip between them at runtime, on an already (runtime) generated spline. 

var spline = obj.GetComponent<CurvySpline>();

foreach (var point in spline.ControlPointsList)
{
    var cg = point.GetMetadata<MetaCGOptions>(true);
    cg.MaterialID = 1;
}

spline.SetDirtyAll();


This currently doesn't make any difference.
Reply
#2
Hi,
Let's try to be overkill and see if it still doesn't work. Please add to the end of your code

spline.Refresh();
yourGenerator.Refresh(true);

if it works, try it without the "true" argument
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
I've tried it with this added, no luck.

Attached images have the details for the materials in the generator. Are there any other settings that I should be aware of?

I've also tried to check "Materials" in the Shape Extrusion, but that caused everything to stretch to almost straight lines from the texture edge. I am not really sure what that setting does.

Thanks for any help!


Attached Files Image(s)
       
Reply
#4
Hi

You have to activate the Materials option in the Shape Extrusion module so that they are taken into consideration.
Since you were not aware of this, I am wondering if you did assign Material Ids in the shape used for extrusion.
Let me summerize to you what you need to do:
1- You add instances of type Meta CG Options to the control points of the spline used as a cross section for your extrusion . More about that here: https://curvyeditor.com/documentation/sp...cg_options
2- You activate the Materials option in the Shape Extrusion module
3- You associate each used Material Id with a material in the Volume Mesh module.

Did you manage to make it work?

You can find in the example scenes cases of mesh extrusions using multiple materials. One example is the 26_CGExtrusionExtendedUV.unity scene. Also the rails in all train scenes use two materials

You do that by setting the material Ids at the Control Point level using the Meta CG Options script.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#5
Thank you for your detailed response!

I will give this a shot, but want to clarify something in my previous post.

If I enable the materials option in the shape extrusion module, even with one material, I get the attached result, is this normal behavior?

   
Reply
#6
Maybe there is a bug. Can you send me please a reproduction case so I can debug this?
Thanks
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Accessing generator's input spline in script, changing it at runtime smackledorf 3 277 06-17-2021, 01:59 PM
Last Post: _Aka_
Shocked Change spline path at runtime burn0815 7 750 05-27-2021, 08:27 PM
Last Post: _Aka_
  Join 2 Spline at Runtime Dextex 1 301 05-17-2021, 02:01 PM
Last Post: _Aka_
  Assigning "OnControlPointReached" and "OnEndReached" values during runtime? TenaciousLibbs 2 2,517 02-18-2021, 01:12 PM
Last Post: PretzelStudios

Forum Jump: