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 Thumbnail(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/splines/curvysplinesegment#meta_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
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_
Wink Modifying Splines at Runtime artsung 1 7 01-30-2024, 09:40 AM
Last Post: _Aka_
  Is it possible to create a road texture at runtime? artsung 1 4 01-30-2024, 09:30 AM
Last Post: _Aka_
  Cant Generate Meshes At Runtime alms94 5 22 01-26-2024, 11:27 AM
Last Post: _Aka_

Forum Jump: