/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
using Live2D.Cubism.Core;
using Live2D.Cubism.Rendering;
using Live2D.Cubism.Editor.Importers;
using System.Linq;
using UnityEngine;
using UnityEditor;
namespace Live2D.Cubism.Samples.Editor
{
///
/// Shows how Cubism model importing can be customized.
///
internal static class ImportCustomization
{
#region Unity Event Handling
///
/// Registers processor.
///
///
/// BE CAREFUL! Uncomment the following line to enable the sample.
// DON'T DO THIS IN REAL PROJECTS!
///
// [InitializeOnLoadMethod]
private static void RegisterModelImporter()
{
CubismImporter.OnDidImportModel += OnModelImport;
}
#endregion
#region Cubism Import Event Handling
///
/// Customizes model importing.
///
/// Event source.
/// Imported model.
private static void OnModelImport(CubismModel3JsonImporter sender, CubismModel model)
{
// Lets pretend we want to change the vertex colors of all drawables to green...
foreach (var renderer in model.Drawables.Select(d => d.GetComponent()))
{
renderer.Color = Color.green;
}
}
#endregion
}
}