public void Init() { if (!util) { util = ScriptableObject.CreateInstance <TerrainUVUtil>(); } GetTargetInfo(); #if UNITY_EDITOR //Create initial pigment map if (pigmentMap == null) { GeneratePigmentMap(); } #endif }
//Grab the terrain position and size and pass it to the shaders public void GetTargetInfo() { if (debug) { Debug.Log("Getting target info for " + terrainObjects.Length + " object(s)"); } if (!util) { util = ScriptableObject.CreateInstance <TerrainUVUtil>(); } util.GetObjectPlanarUV(terrainObjects); //Terrain UV terrainScaleOffset = util.terrainScaleOffset; //Determine if the object is a terrain or mesh workflow = util.workflow; if (debug) { Debug.Log("Terrain type: " + workflow); } //If using Unity Terrains terrains = util.terrains; //Avoid unused variable warning material = null; //based on first terrain's splatmap resolution, or hardcoded to 1024px for meshes pigmentmapSize = util.pigmentMapSize; //Summed size targetSize = util.size; //First terrain makes up the corner targetOriginPosition = util.originPosition; //Center of terrain(s) targetCenterPosition = util.centerPostion; SetPigmentMap(); }