コード例 #1
0
        /// <summary>
        /// Called when we need to load its data.
        /// </summary>
        public static void Load()
        {
            //Create a new PrivateSnapData if our current one is null.
            if (PrivateSnapData == null)
            {
                PrivateSnapData = new SerializableGlobalSnappingData();
            }

            //Load our data.
            PrivateSnapData.Load(SupportedClasses);

            //Set our values.
            AmountToSnapTo    = PrivateSnapData.amountToSnapTo;
            EnableSnapping    = PrivateSnapData.enableSnapping;
            GridSize          = PrivateSnapData.gridSize;
            GridColor         = PrivateSnapData.gridColor;
            GridScale         = PrivateSnapData.gridScale;
            PixelsPerMeter    = PrivateSnapData.pixelsPerMeter;
            UsePixelsPerMeter = PrivateSnapData.usePixelsPerMeter;
            UseNGUIInspector  = PrivateSnapData.useNGUIInspector;

            ApplicableClasses = PrivateSnapData.GetClasses();
        }
コード例 #2
0
        /// <summary>
        /// Called when this addon needs to save its data.
        /// </summary>
        public static void Save()
        {
            //if the data is not null.
            if (PrivateSnapData != null)
            {
                //Set our classes...
                PrivateSnapData.SetClasses(ApplicableClasses);

                //And then save our data.
                PrivateSnapData.Save();
            }
            else             //the data was null, which is...not good.  Output an error message, and try to
                             //load the EditorPrefs keys, or initialize with the default values.
            {
                Debug.LogError(u2dexInfo.AbbreviatedName + " could not save its settings, due to them being null." +
                               "  Attempting to recover by loading any keys we have, or initializing them to default values.");

                //Initialize our PrivateSnapData
                PrivateSnapData = new SerializableGlobalSnappingData();

                //Attempt to load our data, or initialize them to the default values.
                PrivateSnapData.Load(SupportedClasses);
            }
        }