Playmaker Forum

PlayMaker Feedback => Action Requests => Topic started by: ttham on February 08, 2017, 07:29:11 AM

Title: Create material Action.[SOLVED]
Post 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.
Title: Re: Create material Action.
Post by: ttham on February 09, 2017, 09:35:13 AM
Here ya go mate
Code: [Select]
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 ();
}
}
}
Title: Re: Create material Action.
Post by: ttham on February 09, 2017, 09:35:35 AM
Thanks dude  ;)
Title: Re: Create material Action.
Post by: jeanfabre on February 10, 2017, 02:40:51 AM
:)

 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
Title: Re: Create material Action.
Post by: psypol on April 26, 2017, 06:00:46 PM
Here ya go mate
Code: [Select]
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
Title: Re: Create material Action.
Post by: jeanfabre on April 27, 2017, 03:51:17 AM
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

Title: Re: Create material Action.[SOLVED]
Post by: psypol on May 02, 2017, 03:29:30 PM
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.