示例#1
0
        /*
         * Design notes:
         *
         * The design is meant to minimize the need to hard code field values in the editor
         * while maintaining the use of serialized properties to format each field properly.
         *
         * With the exception of the core fields and the observers list, all sections are expected
         * to start with a 'start' property field and end with the section's namesake 'complex'
         * field. 'Complex' in this context means a field with child fields.  They are used
         * to control the foldout state for their associated section.  All other fields that
         * belong to a section are expected to be between the start and end fields.  (The
         * property iterator follows the field order in the class definition.)
         *
         * All fields are expected to be in a section with sections layed out internally as follows:
         *
         * Section start field
         * ....
         * .... Other section fields
         * ....
         * Section end complex field
         *
         * The order of the fields in each section is the same as defined in the source class.
         * The order of the sections is controlled by this editor code.
         *
         * To allow reordering of sections, each section goes through separate load and draw
         * draw steps.  The load step gathers the persistant serialized properties from the
         * property iterator.  The draw step draws the properties.
         */

        #region Editor Members

        void OnEnable()
        {
            var outfit = target as StandardOutfit;

            // Assume auto-detect has already been performed if the motion root is assigned
            // Want to be conservative.
            if (!Application.isPlaying && outfit && !outfit.MotionRoot)
            {
                StandardOutfit.UnsafeRefreshAllSettings(outfit);
                EditorUtility.SetDirty(outfit);
            }
        }
        private static void RefreshAllSettings(
            StandardOutfit outfit, bool singleUndo = true, string undoLabel = "Refresh All Outfit Settings")
        {
            if (singleUndo)
            {
                Undo.IncrementCurrentGroup();
            }

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

            StandardOutfit.UnsafeRefreshAllSettings(outfit);

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