Skip to content

Instantly share code, notes, and snippets.

@karl-
Created March 19, 2015 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karl-/ff7c0f605d52f92ba5c9 to your computer and use it in GitHub Desktop.
Save karl-/ff7c0f605d52f92ba5c9 to your computer and use it in GitHub Desktop.
using UnityEditor;
using UnityEngine;
using System.Linq;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for manually re-generating all ProBuilder color arrays in scene.
*/
public class pb_FixColorsOutOfBounds : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Fix Colors Out of Bounds", false, pb_Constant.MENU_REPAIR)]
public static void MenuFixColors()
{
foreach(pb_Object pb in Resources.FindObjectsOfTypeAll(typeof(pb_Object)).Where(x => x.hideFlags == HideFlags.None))
{
if(pb.colors == null || pb.colors.Length != pb.vertexCount)
{
pb.SetColors( pbUtil.FilledArray(Color.white, pb.vertexCount) );
pb.ToMesh();
pb.Refresh();
pb.Finalize();
}
}
if(pb_Editor.instance != null)
pb_Editor.instance.UpdateSelection();
SceneView.RepaintAll();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment