Difference between revisions of "Effect Attributes Animation V3"

From PopcornFX
Jump to navigation Jump to search
(Created page with "{| |link=Unity|50px<br/><div style="text-align:center;"><<<</div> | __TOC__ |} Particle effect attributes are exposed on the Unity/...")
 
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{|
 
{|
|[[Image:Unity-logo-g.png|link=Unity|50px]]<br/><div style="text-align:center;">[[Unity|<<<]]</div>
+
|[[Image:Unity-logo-g.png|link=Unity_V3|50px]]<br/><div style="text-align:center;">[[Unity_V3|<<<]]</div>
 
| __TOC__
 
| __TOC__
 
|}
 
|}
  
[[Particle effect attributes]] are exposed on the [[Unity/PKFx-Runtime Assembly/PKFxFX component | PKFxFX component's]] inspector view.
+
[[Particle effect attributes]] are exposed on the [[PKFxFX_component_V3 | PKFxFX component]]'s inspector view.
  
=Using the [[PKFx-Helper Assembly|PKFxAnimFloat*]] classes=
+
=Using the [[PKFx-Helper Assembly V3|PKFxAnimFloat*]] classes=
  
 
# Add the PKFxAnimFloat component corresponding to your attribute's type to the GameObject holding the PKFxFX component.
 
# Add the PKFxAnimFloat component corresponding to your attribute's type to the GameObject holding the PKFxFX component.
Line 12: Line 12:
 
# You can now access the attribute via the helper component's public variable : "value".
 
# 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 component#SetAttribute|PKFxFX.SetAttribute()]] with the appropriate [[PKFxManager Assembly#Attribute|Attribute]] argument.<br>
 
 
== 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.[[PKFxFX component#SetAttribute|SetAttribute]](new P[[PKFxManager Assembly#Attribute|KFxManager.Attribute]]("MyColor", newColor));
 
 
 
If you're not sure whether an effect has a specific attribute or not, you can check using [[PKFxFX component#AttributesExist|PKFxFX.AtributesExist()]] with an [[PKFxManager Assembly#AttributeDesc|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 Assembly#AttributeDesc|PKFxManager.AttributeDesc]] desc = new PKFxManager.AttributeDesc([[PKFxManager Assembly#BaseType enum|PKFxManager.BaseType.Float4]], "MyColor");
 
 
if (myFX != null && myFX.[[PKFxFX component#AttributesExist|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.<br>
 
To do so, you'll need to use :
 
  [[PKFxFX_component#GetAttribute|PKFxFX.GetAttribute]](string name)
 
or
 
  [[PKFxFX_component#GetAttribute|PKFxFX.GetAttribute]](string name, [[PKFxManager_Assembly#BaseType_enum | PKFxManager.BaseType]] type)
 
 
So for example : getting an attribute named "MyColor" of type float4:
 
 
[[PKFxFX component|PKFxFX]] myFX = this.GetComponent<PKFxFX>();
 
Vector4 attrColor;
 
 
 
if (myFX != null)
 
{
 
    [[PKFxManager_Assembly#Attribute|PKFxManager.Attribute]] attr = myFX.[[PKFxFX component#GetAttribute|GetAttribute]]("MyColor");
 
    if (attr != null)
 
        attrColor = attr.ValueFloat4;
 
}
 
  
 
[[Category:Unity_V3]]
 
[[Category:Unity_V3]]
 
[[Category:HowTo_V3]]
 
[[Category:HowTo_V3]]

Latest revision as of 10:38, 16 July 2019

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".