Beispiel #1
0
        public static bool ApplyBodyPartLayer(
            Outfit outfit, int layer, 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(false);
            }

            if (outfit.BodyPartCount == 0)
            {
                return(false);
            }

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

            undoLabel = string.IsNullOrEmpty(undoLabel) ? "Set Body Part Layer" : undoLabel;

            Undo.RecordObjects(Outfit.UnsafeGetUndoObjects(outfit).ToArray(), undoLabel);

            outfit.ApplyBodyPartLayer(layer);

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

            return(true);
        }