Difference between revisions of "Effect Attributes Animation V3"

From PopcornFX
Jump to navigation Jump to search
(Using the PKFxAnimFloat* classes)
Line 16: Line 16:
 
Alternatively, you can access the attributes in your scripts using the [[PKFxFX_component_V3 | PKFxFX_component]]'s public methods.
 
Alternatively, you can access the attributes in your scripts using the [[PKFxFX_component_V3 | PKFxFX_component]]'s public methods.
  
You need to know the name and the type of the attribute you want to access and call [[PKFxFX_component_V3#SetAttribute|PKFxFX.SetAttribute()]] with the appropriate [[PKFxManager Assembly#Attribute|Attribute]] argument.<br>
+
You need to know the name and the type of the attribute you want to access and call [[PKFxFX_component_V3#SetAttribute|PKFxFX.SetAttribute()]] with the appropriate [[PKFxManager_V3#Attribute|Attribute]] argument.<br>
  
 
== Setting an Attribute ==
 
== Setting an Attribute ==
Line 26: Line 26:
 
   
 
   
 
  if (myFX != null)
 
  if (myFX != null)
     myFX.[[PKFxFX_component_V3#SetAttribute|SetAttribute]](new P[[PKFxManager Assembly#Attribute|KFxManager.Attribute]]("MyColor", newColor));
+
     myFX.[[PKFxFX_component_V3#SetAttribute|SetAttribute]](new [[PKFxManager_V3#Attribute| PKFxManager.Attribute]]("MyColor", newColor));
  
  
If you're not sure whether an effect has a specific attribute or not, you can check using [[PKFxFX_component_V3#AttributesExist|PKFxFX.AtributesExist()]] with an [[PKFxManager Assembly#AttributeDesc|AttributeDesc]] parameter built with the proper type and name.
+
If you're not sure whether an effect has a specific attribute or not, you can check using [[PKFxFX_component_V3#AttributesExist|PKFxFX.AtributesExist()]] with an [[PKFxManager_V3#AttributeDesc|AttributeDesc]] parameter built with the proper type and name.
  
 
Setting the same attribute as above after checking it exists:
 
Setting the same attribute as above after checking it exists:
Line 36: Line 36:
 
  Vector4 newColor = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
 
  Vector4 newColor = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
 
   
 
   
  [[PKFxManager Assembly#AttributeDesc|PKFxManager.AttributeDesc]] desc = new PKFxManager.AttributeDesc([[PKFxManager Assembly#BaseType enum|PKFxManager.BaseType.Float4]], "MyColor");
+
  [[PKFxManager_V3#AttributeDesc|PKFxManager.AttributeDesc]] desc = new PKFxManager.AttributeDesc([[PKFxManager_V3#BaseType enum|PKFxManager.BaseType.Float4]], "MyColor");
 
   
 
   
  if (myFX != null && myFX.[[PKFxFX component#AttributesExist|AttributesExist]](desc))
+
  if (myFX != null && myFX.[[PKFxFX component V3#AttributesExist|AttributesExist]](desc))
 
     myFX.SetAttribute(new PKFxManager.Attribute("MyColor", newColor));
 
     myFX.SetAttribute(new PKFxManager.Attribute("MyColor", newColor));
  
Line 47: Line 47:
 
   [[PKFxFX_component_V3#GetAttribute|PKFxFX.GetAttribute]](string name)
 
   [[PKFxFX_component_V3#GetAttribute|PKFxFX.GetAttribute]](string name)
 
or
 
or
   [[PKFxFX_component_V3#GetAttribute|PKFxFX.GetAttribute]](string name, [[PKFxManager_Assembly#BaseType_enum | PKFxManager.BaseType]] type)
+
   [[PKFxFX_component_V3#GetAttribute|PKFxFX.GetAttribute]](string name, [[PKFxManager_V3#BaseType_enum | PKFxManager.BaseType]] type)
  
 
So for example : getting an attribute named "MyColor" of type float4:
 
So for example : getting an attribute named "MyColor" of type float4:
Line 56: Line 56:
 
  if (myFX != null)
 
  if (myFX != null)
 
  {
 
  {
     [[PKFxManager_Assembly#Attribute|PKFxManager.Attribute]] attr = myFX.[[PKFxFX component#GetAttribute|GetAttribute]]("MyColor");
+
     [[PKFxManager_V3#Attribute|PKFxManager.Attribute]] attr = myFX.[[PKFxFX component V3#GetAttribute|GetAttribute]]("MyColor");
 
     if (attr != null)
 
     if (attr != null)
 
         attrColor = attr.ValueFloat4;
 
         attrColor = attr.ValueFloat4;

Revision as of 15:34, 5 July 2018

Unity-logo-g.png

Particle effect attributes are exposed on the PKFxFX component's inspector view.

Using the PKFxAnimFloat* classes

  1. Add the PKFxAnimFloat component corresponding to your attribute's type to the GameObject holding the PKFxFX component.
  2. On the PKFxAnimFloat component, set the name of the attribute you want to manipulate.
  3. You can now access the attribute via the helper component's public variable : "value".

Accessing directly through scripts

Alternatively, you can access the attributes in your scripts using the PKFxFX_component's public methods.

You need to know the name and the type of the attribute you want to access and call PKFxFX.SetAttribute() with the appropriate Attribute argument.

Setting an Attribute

So for example : setting an attribute named "MyColor" of type float4:

PKFxFX myFX = this.GetComponent<PKFxFX>();
Vector4 newColor = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);

if (myFX != null)
    myFX.SetAttribute(new  PKFxManager.Attribute("MyColor", newColor));


If you're not sure whether an effect has a specific attribute or not, you can check using PKFxFX.AtributesExist() with an AttributeDesc parameter built with the proper type and name.

Setting the same attribute as above after checking it exists:

PKFxFX myFX = this.GetComponent<PKFxFX>();
Vector4 newColor = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);

PKFxManager.AttributeDesc desc = new PKFxManager.AttributeDesc(PKFxManager.BaseType.Float4, "MyColor");

if (myFX != null && myFX.AttributesExist(desc))
    myFX.SetAttribute(new PKFxManager.Attribute("MyColor", newColor));

Getting an Attribute

A much less common case, but for some reason you might need to retrieve an attribute's value.
To do so, you'll need to use :

 PKFxFX.GetAttribute(string name)

or

 PKFxFX.GetAttribute(string name,  PKFxManager.BaseType type)

So for example : getting an attribute named "MyColor" of type float4:

PKFxFX myFX = this.GetComponent<PKFxFX>();
Vector4 attrColor;
 
if (myFX != null)
{
    PKFxManager.Attribute attr = myFX.GetAttribute("MyColor");
    if (attr != null)
        attrColor = attr.ValueFloat4;
}