/// <summary>
 /// Switches to the given brushCollection, to edit it. (now this collection it the currently displayed one in the editor window)
 /// </summary>
 /// <param name="collection"></param>
 public static void SwitchToBrushCollection(BrushCollection collection)
 {
     if (Instance != null)
     {
         if (collection != null)
         {
             Instance.selectedBrushCollectionIndex = collection.GetIndex();
             Instance.brushes = collection;
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returnes the last used brush collection, if none it returns a new one
        /// </summary>
        /// <returns></returns>
        public static KeyValuePair <int, BrushCollection> GetLastUsedBrushCollection()
        {
            //try to find the last used brush collection and return it
            if (EditorPrefs.HasKey(lastBrushCollection_EditPrefsKey))
            {
                string          guid = EditorPrefs.GetString(lastBrushCollection_EditPrefsKey, "");
                string          path = AssetDatabase.GUIDToAssetPath(guid);
                BrushCollection lastUsedCollection = AssetDatabase.LoadAssetAtPath <BrushCollection>(path);

                //return found one or create one
                if (lastUsedCollection != null)
                {
                    return(new KeyValuePair <int, BrushCollection>(lastUsedCollection.GetIndex(), lastUsedCollection));
                }
            }

            //create one if none found
            BrushCollection brushCollection = CreateInstance(defaultBrushCollectionName);

            return(new KeyValuePair <int, BrushCollection>(brushCollection.GetIndex(), brushCollection));
        }