示例#1
0
        public static int ApplyOutfitMaterial(Outfit outfit, OutfitMaterialType matType, Material material,
                                              bool singleUndo = true, string undoLabel = null)
        {
            if (AssetDatabase.Contains(outfit))
            {
                Debug.LogError("Can't modify an outfit asset.  Outfit must be in the scene.", outfit);
                return(0);
            }

            if (singleUndo)
            {
                Undo.IncrementCurrentGroup();
            }

            undoLabel = string.IsNullOrEmpty(undoLabel) ? "Set Outfit Material" : undoLabel;
            Undo.RecordObjects(Outfit.UnsafeGetUndoObjects(outfit).ToArray(), undoLabel);

            var count = outfit.ApplySharedMaterial(matType, material);

            if (singleUndo)
            {
                Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
            }

            return(count);
        }