User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Create mesh prefab from decal

To create a proper mesh prefab out of a decal instance, copy the script below to one of your Editor folders (e.g. Assets/Scripts/Editor). To create e prefab, just select your decal in the scene view and press Assets/Create Decal Mesh Prefab from the main menu.
 

using UnityEditor;
using UnityEngine;

public class WizardCreateLight
{
    [MenuItem("Assets/Create Decal Mesh Prefab")]
    static void CreateWizard()
    {
        GameObject o = Selection.activeGameObject;

        MeshFilter filter = o.GetComponent();

        if (filter != null)
        {
            if (filter.sharedMesh != null)
            {
                AssetDatabase.CreateAsset(filter.sharedMesh, AssetDatabase.GenerateUniqueAssetPath("Assets/decal_mesh.asset"));
                AssetDatabase.SaveAssets();
            }
        }
    }
}