예제 #1
0
        /// <summary>
        /// Saves the preset to the internal CrayonStateGlobals list.
        /// </summary>
        public void SavePreset(GameObject g, string id, CrayonStateManager sentBy)
        {
            CrayonState[] states = g.GetComponents <CrayonState> ();
            // Create a new preset.
            CrayonPreset preset = new CrayonPreset(id);

            // Add data to the preset
            foreach (CrayonState state in states)
            {
                // Save data to a new data class
                CrayonStateData stateData = new CrayonStateData(state);
                // Add to the preset's list
                preset.AddStateData(stateData);
            }
            // Is this already in the dictionary? If so, override
            CrayonPreset oldPreset;

            if (_presetsById.TryGetValue(preset._id, out oldPreset))
            {
                _presetsById.Remove(preset._id);
            }
            _presetsById.Add(preset._id, preset);
            Debug.LogWarningFormat("Crayon preset {0} was saved.", preset._id);
            sentBy._newPresetId = null;
            SavePresetFiles();
        }
예제 #2
0
 /// <summary>
 /// Called to add state data to a preset.
 /// </summary>
 /// <param name="stateData">State data.</param>
 public void AddStateData(CrayonStateData stateData)
 {
     if (_crayonStatesData == null)
     {
         _crayonStatesData = new List <CrayonStateData>();
     }
     _crayonStatesData.Add(stateData);
 }