Playmaker Forum
PlayMaker Feedback => Action Requests => Topic started by: ttham on February 08, 2017, 07:29:11 AM
-
Good day. Can someone please make an action that creates standard unity 5 material?
I found some code here http://answers.unity3d.com/questions/21457/is-it-possible-to-create-a-material-asset-from-a-s.html (http://answers.unity3d.com/questions/21457/is-it-possible-to-create-a-material-asset-from-a-s.html)
But I don't really know how to use it.
-
Here ya go mate
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System ;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory (ActionCategory.Material)]
public class AddMaterialAction : FsmStateAction
{
[UIHint(UIHint.Variable)]
public FsmMaterial AddMaterial;
public override void Reset()
{
AddMaterial = null;
}
public override void OnEnter()
{
AddMaterial = new FsmMaterial (Shader.Find("Standart"));
Finish ();
}
}
}
-
Thanks dude ;)
-
:)
I am glad you could solve this, also, I would expand on this and expose the shader name as a public FsmString so that the action can createa new material with any shaders.
Bye,
Jean
-
Here ya go mate
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System ;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory (ActionCategory.Material)]
public class AddMaterialAction : FsmStateAction
{
[UIHint(UIHint.Variable)]
public FsmMaterial AddMaterial;
public override void Reset()
{
AddMaterial = null;
}
public override void OnEnter()
{
AddMaterial = new FsmMaterial (Shader.Find("Standart"));
Finish ();
}
}
}
Hello.
can i have more infos about the usage of this piece of code ?
it doesn't seem to create any new material inside the project folders.
do i use it properly ?
what am i supposed to put inside the "add material" variable of the action ?
am i supposed to tell the action which material i would like to make a COPY of ?
please help
-
Hi,
Ok, this action isn't really working as is, I have created one on the Ecosystem.
(http://i.imgur.com/13bNfkd.png)
and basically, you need to fill the shader you want, to get the list, simply try to create a material manually and check what's available in the list of shaders.
Bye,
Jean
-
thanks a lot jean.
it seems to do what i wanted.
For noobs like me : take note that the material(or shader actually) that is created during runtime don't appears in the hierarchy of the project.
But if you store this new material in a variable and set it on an object it will actually work and you can modify the color of it individually, independantly from any other instance of the same object.