-
Notifications
You must be signed in to change notification settings - Fork 0
Create a picking method
Ben edited this page Jul 20, 2019
·
3 revisions
In order to create a new picking method for your prefabs, you need to create a new C# Script in your project.
The following example is a picking method that will select the last prefabs of your list and rotate by 60° around its Y-axis.
using Hexamap;
using System;
using System.Linq;
using UnityEngine;
[PickingMethodName("Last")]
public static class PickingMethodLast
{
public static Tuple<GameObject, int> Pick(Tile tile, GameObject[] prefabs)
{
return new Tuple<GameObject, int>(prefabs.Last(), 60);
}
}
Tile tile
is the model of the tile you are choosing the prefab for. GameObject[] prefabs
is the list of prefabs you have set in the settings of the landform.
The return value of the method Pick
is a Tuple
where the first object is the prefab to use and the second one is the rotation you want to apply to the prefab. Note that this rotation will be added to whatever value you picked in the "Rotate" field.