<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — How to change the terrain texture with a PlayMaker action ?]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1884</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1884&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in How to change the terrain texture with a PlayMaker action ?.]]></description>
		<lastBuildDate>Sat, 04 Dec 2021 11:44:11 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: How to change the terrain texture with a PlayMaker action ?]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7943#p7943</link>
			<description><![CDATA[<p>Thanks a lot, it works well ! And really sorry for the misunderstanding, you are right, this PM Action is not related to your asset ! And of course I confirm that your are always very responsive and helpful.<br />Have a nice day (or night !)<br />Phil</p>]]></description>
			<author><![CDATA[null@example.com (philzmz)]]></author>
			<pubDate>Sat, 04 Dec 2021 11:44:11 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7943#p7943</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to change the terrain texture with a PlayMaker action ?]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7941#p7941</link>
			<description><![CDATA[<p>Yes it is possible. Action below.</p><p>The fact that your terrain is made using RWT does not make any question RWT related.<br />In this case, it does not matter at all how the terrain is made: manually, using some tool or Unity API. It will just work.<br />Please do not misunderstand me: I am always ready to help if I have experience in something. But it is better to start looking for help from a person or a team, with which your question is directly related.</p><div class="codebox"><pre><code>using HutongGames.PlayMaker;
using UnityEngine;

namespace Playmaker.Actions
{
    [ActionCategory(&quot;Terrain&quot;)]
    [HutongGames.PlayMaker.Tooltip(&quot;Set Terrain Texture&quot;)]
    public class SetTerrainTexture : FsmStateAction
    {
        public Terrain terrain;
        public Texture2D texture;
        public int layerIndex = 0;

        public override void OnEnter()
        {
            DoEnter();
            Finish();
        }

        private void DoEnter()
        {
            TerrainLayer[] layers = terrain.terrainData.terrainLayers;
            layers[layerIndex].diffuseTexture = texture;
            terrain.terrainData.terrainLayers = layers;
            terrain.Flush();
        }
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 02 Dec 2021 23:18:40 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7941#p7941</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to change the terrain texture with a PlayMaker action ?]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7940#p7940</link>
			<description><![CDATA[<p>Hello Alex<br />Thanks very much for the script, it works !!!</p><p>Something that I don’t understand : if I drag a “regular” 2D texture over the Terrain Item thumbnail, it replaces the terrain texture. But with your script, I can use only a &quot;terrain layer&quot;, not a simple texture, and this would be helpful for instance to replace a terrain for instance with a geological or a Cassini map. Do you think that there would be a way to use a “regular” texture ?</p><p>I am afraid that if I ask the PlayMaker team for a custom action concerning RWT, they will tell me the same thing : “see with the developer of the asset” ;-)</p><p>Best regards, Phil</p>]]></description>
			<author><![CDATA[null@example.com (philzmz)]]></author>
			<pubDate>Thu, 02 Dec 2021 17:50:21 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7940#p7940</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to change the terrain texture with a PlayMaker action ?]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7934#p7934</link>
			<description><![CDATA[<p>Hello.</p><p>It doesn&#039;t work that way. Terrain Engine is much more complex.<br />Below is the action for this, but please in the future ask a question to the developer of the asset to which your question relates (in this case Playmaker).<br />And keep in mind that Terrain Engine will save its state after exiting play mode.</p><div class="codebox"><pre><code>using HutongGames.PlayMaker;
using UnityEngine;

namespace Playmaker.Actions
{
    [ActionCategory(&quot;Terrain&quot;)]
    [HutongGames.PlayMaker.Tooltip(&quot;Set Terrain Layer&quot;)]
    public class SetTerrainLayer : FsmStateAction
    {
        public Terrain terrain;
        public TerrainLayer layer;
        public int layerIndex = 0;

        public override void OnEnter()
        {
            DoEnter();
            Finish();
        }

        private void DoEnter()
        {
            TerrainLayer[] layers = terrain.terrainData.terrainLayers;
            layers[layerIndex] = layer;
            terrain.terrainData.terrainLayers = layers;
            terrain.Flush();
        }
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 01 Dec 2021 21:13:54 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7934#p7934</guid>
		</item>
		<item>
			<title><![CDATA[How to change the terrain texture with a PlayMaker action ?]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7933#p7933</link>
			<description><![CDATA[<p>I tried something pretty simple but... it doesn&#039;t work :-(<br />Please have a look to this video : <a href="https://youtu.be/85M4SXY3qGA">https://youtu.be/85M4SXY3qGA</a><br />Best regards<br />Phil</p>]]></description>
			<author><![CDATA[null@example.com (philzmz)]]></author>
			<pubDate>Wed, 01 Dec 2021 18:17:51 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7933#p7933</guid>
		</item>
	</channel>
</rss>
