Created
March 19, 2015 18:48
-
-
Save karl-/ff7c0f605d52f92ba5c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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