0 like 0 dislike
141 views
Hello,

I have a problem with one effect that I need to use on SkinnedMeshRenderers. This effect is only put in the scene via script and as such I cannot change the shape type by hand. This ShapeType is set to "None" by default (see screenshot bellow)

I'd like to know how I could change the default value or simply change to skinned mesh (or anything) via script?

I tried with set sampler and set attribute but it doesn't seem to recognize my ShapeType variable (called "Mesh").

Here is a screenshot of the effect :

http://imgur.com/9W9cyan

Thanks for your help!
by valon (340 points)

1 Answer

1 like 0 dislike
 
Best answer

Hi Valon,

You should be able to set your Shape Sampler type with http://wiki.popcornfx.com/index.php/PKFxFX_component#SetSampler

You can find an example of how to push a SkinnedMesh into the Shape Sampler here :
http://wiki.popcornfx.com/index.php/Effect_Attribute_Samplers_Animation#SkinnedMesh

Hope this helps !

by valentin (7.1k points)
Thanks but my problem is mostly that the script cannot find the sampler called "Mesh" when I add the pkfx via script.

I have it working fine otherwise.

Here is the code which is on the start function :

     _effect = this.gameObject.AddComponent<PKFxFX>();

    _effect.m_FxName = "Skinned_Effect.pkfx";

      _effect.SetSampler(new PKFxManager.Sampler("Mesh", new PKFxManager.SamplerDescShapeSkinnedMesh(Vector3.zero, Vector3.one, Vector3.zero, this.GetComponent<SkinnedMeshRenderer>(), (int)PKFxManager.EMeshChannels.Channel_Position)));
      this.gameObject.GetComponent<SkinnedMeshRenderer>().enabled = false;
Oh ok sorry !

If you want to initialize all the FX via script, you must load the samplers by hand,
put this lines before the SetSampler :

    List<PKFxManager.SamplerDesc> FxSamplersDesc = PKFxManager.ListEffectSamplersFromFx(_effect.FxPath);
    _effect.LoadSamplers(FxSamplersDesc, true);
Thanks!

This is what I forgot to do. It's working fine now.
...