<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — How to change the terrain texture with a PlayMaker action ?]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1884&amp;type=atom" />
	<updated>2021-12-04T11:44:11Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=1884</id>
		<entry>
			<title type="html"><![CDATA[Re: How to change the terrain texture with a PlayMaker action ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7943#p7943" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[philzmz]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=606</uri>
			</author>
			<updated>2021-12-04T11:44:11Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7943#p7943</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to change the terrain texture with a PlayMaker action ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7941#p7941" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2021-12-02T23:18:40Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7941#p7941</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to change the terrain texture with a PlayMaker action ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7940#p7940" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[philzmz]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=606</uri>
			</author>
			<updated>2021-12-02T17:50:21Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7940#p7940</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to change the terrain texture with a PlayMaker action ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7934#p7934" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2021-12-01T21:13:54Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7934#p7934</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[How to change the terrain texture with a PlayMaker action ?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7933#p7933" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[philzmz]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=606</uri>
			</author>
			<updated>2021-12-01T18:17:51Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7933#p7933</id>
		</entry>
</feed>
