This commit is contained in:
2025-05-16 23:31:59 +08:00
parent 9e4fef3f1e
commit d891e3f0ee
1198 changed files with 274242 additions and 1558 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 762505d68621d5b45956c2a6afefbdfe
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b79448a699ad4024dab3128ac29dced0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ad86275e12197b24ebecfe38f46e3fb1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,824 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace RapidIcon_1_7_2
{
//---ObjectPathPair Definition---//
public struct ObjectPathPair
{
public ObjectPathPair(UnityEngine.Object obj, string pth)
{
UnityEngine_object = obj;
path = pth;
}
public UnityEngine.Object UnityEngine_object;
public string path;
};
[Serializable]
public class AssetGrid
{
//---PUBLIC---//
//Icons
public Dictionary<UnityEngine.Object, IconSet> objectIconSets;
public Dictionary<string, IconSet> sortedIconSetsByPath;
public List<IconSet> visibleIconSets;
public List<IconSet> selectedIconSets;
//Textures
public Texture2D[] assetSelectionTextures;
//Other
public string rapidIconRootFolder;
public bool assetGridFocused;
public int previewSize;
//---INTERNAL---//
//GUI
Vector2 scrollPosition;
GUIStyle gridStyle, gridLabelStyle;
//Selection
int lastSelectedIconIndex;
int selectionMinIndex;
int selectionMaxIndex;
string lastSelectedIndividualFolder;
List<ObjectPathPair> objectsLoadedFromSelectedFolders;
//RapidIcon Window Elements
RapidIconWindow window;
AssetList assetList;
//Filter
int filterIdx;
string[] filters = new string[] { "t:model t:prefab", "t:prefab", "t:model" };
string[] filterNames = new string[] { "Prefabs & Models", "Prefabs Only", "Models Only" };
//Other
Rect rect;
bool iconsRefreshed;
public AssetGrid(AssetList assets)
{
//---Initialise AssetGrid---//
//Asset List
assetList = assets;
//Selection
objectsLoadedFromSelectedFolders = new List<ObjectPathPair>();
lastSelectedIconIndex = -1;
selectionMinIndex = int.MaxValue;
selectionMaxIndex = -1;
//Icons
objectIconSets = new Dictionary<UnityEngine.Object, IconSet>();
sortedIconSetsByPath = new Dictionary<string, IconSet>();
selectedIconSets = new List<IconSet>();
//Styles
previewSize = 128;
gridStyle = new GUIStyle();
gridStyle.fixedHeight = previewSize;
gridStyle.fixedWidth = previewSize;
gridStyle.margin.bottom = 16 + (int)EditorGUIUtility.singleLineHeight + 2;
gridStyle.margin.left = 16;
gridStyle.alignment = TextAnchor.MiddleCenter;
gridLabelStyle = new GUIStyle(gridStyle);
gridLabelStyle.margin.bottom = 16 + previewSize + 2;
gridLabelStyle.fixedHeight = EditorGUIUtility.singleLineHeight;
gridLabelStyle.alignment = TextAnchor.MiddleCenter;
if (EditorGUIUtility.isProSkin)
gridLabelStyle.normal.textColor = new Color32(192, 192, 192, 255);
else
gridLabelStyle.normal.textColor = Color.black;
//Filter
filterIdx = 0;
//Textures
assetSelectionTextures = new Texture2D[5];
string[] split = AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("RapidIconWindow")[0]).Split('/');
rapidIconRootFolder = "";
for (int i = 0; i < split.Length - 4; i++)
rapidIconRootFolder += split[i] + "/";
assetSelectionTextures[0] = (Texture2D)AssetDatabase.LoadMainAssetAtPath(rapidIconRootFolder + "Editor/UI/deselectedAsset.png");
assetSelectionTextures[1] = (Texture2D)AssetDatabase.LoadMainAssetAtPath(rapidIconRootFolder + "Editor/UI/selectedAssetActiveDark.png");
assetSelectionTextures[2] = (Texture2D)AssetDatabase.LoadMainAssetAtPath(rapidIconRootFolder + "Editor/UI/selectedAssetInactiveDark.png");
assetSelectionTextures[3] = (Texture2D)AssetDatabase.LoadMainAssetAtPath(rapidIconRootFolder + "Editor/UI/selectedAssetActiveLight.png");
assetSelectionTextures[4] = (Texture2D)AssetDatabase.LoadMainAssetAtPath(rapidIconRootFolder + "Editor/UI/selectedAssetInactiveLight.png");
assetSelectionTextures[0].hideFlags = HideFlags.DontSave;
assetSelectionTextures[1].hideFlags = HideFlags.DontSave;
assetSelectionTextures[2].hideFlags = HideFlags.DontSave;
assetList.lastNumberOfSelected = -1;
//Other
iconsRefreshed = true;
}
public void Draw(float width, RapidIconWindow w)
{
//---Check variables are set---//
CheckAndSetWindow(w);
//---Refresh icons after startup---//
if (!iconsRefreshed && EditorApplication.timeSinceStartup > 15)
{
RefreshAllIcons();
iconsRefreshed = true;
}
GUILayout.BeginVertical(GUILayout.Width(width));
GUILayout.Space(4);
//---Filter---//
GUILayout.BeginHorizontal();
GUILayout.Space(8);
if (GUILayout.Button("Refresh"))
ReloadObjects();
if (GUILayout.Button("Filter: " + filterNames[filterIdx]))
{
filterIdx++;
if (filterIdx == 3)
filterIdx = 0;
ReloadObjects();
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
//---Scroll view----//
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false, GUIStyle.none, GUI.skin.verticalScrollbar);
//---Draw icons---//
DrawIcons(width);
//---End GUI elements---//
GUILayout.EndScrollView();
GUILayout.EndVertical();
//---Get last rect and check focus---//
if (Event.current.type == EventType.Repaint)
rect = new Rect(GUILayoutUtility.GetLastRect());
CheckFocus(rect);
}
public void SaveData()
{
//---Save selected assets---//
string selectedAssetsString = "";
foreach (KeyValuePair<UnityEngine.Object, IconSet> iconSet in objectIconSets)
{
selectedAssetsString += "|-A-|" + iconSet.Value.assetPath + "|-S-|" + iconSet.Value.selected;
}
EditorPrefs.SetString(PlayerSettings.productName + "RapidIconSelectedAssets", selectedAssetsString);
//---Save other variables---//
EditorPrefs.SetFloat(PlayerSettings.productName + "RapidIconAssetGridScroll", scrollPosition.y);
EditorPrefs.SetBool(PlayerSettings.productName + "RapidIconIconsRefreshed", iconsRefreshed);
EditorPrefs.SetInt(PlayerSettings.productName + "RapidIconFilterIdx", filterIdx);
}
public void LoadData()
{
//---Close RapidIcon window if left open when Unity starts---//
if (!SessionState.GetBool("rapidicon_loaded", false))
{
SessionState.SetBool("rapidicon_forceclose", true);
SessionState.SetBool("rapidicon_loaded", true);
return;
}
//---Load objects in selected folders---//
objectsLoadedFromSelectedFolders = LoadObjectsInSelectedFolders();
CreateIconSets();
//---Load selected assets---//
string selectedAssetsString = EditorPrefs.GetString(PlayerSettings.productName + "RapidIconSelectedAssets");
string[] splitAssets = selectedAssetsString.Split(new string[] { "|-A-|" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in splitAssets)
{
string[] splitS = s.Split(new string[] { "|-S-|" }, StringSplitOptions.RemoveEmptyEntries);
string assetPath = splitS[0];
if (splitS[1] == "True")
{
IconSet iconSet = GetIconSetFromPath(assetPath);
if (iconSet != null)
{
iconSet.selected = true;
selectedIconSets.Add(GetIconSetFromPath(assetPath));
}
}
}
//---Load other variables---//
iconsRefreshed = EditorPrefs.GetBool(PlayerSettings.productName + "RapidIconIconsRefreshed");
scrollPosition = new Vector2(0, EditorPrefs.GetFloat(PlayerSettings.productName + "RapidIconAssetGridScroll"));
filterIdx = EditorPrefs.GetInt(PlayerSettings.productName + "RapidIconFilterIdx", 0);
}
void ReloadObjects()
{
//---Unload objects
EditorUtility.UnloadUnusedAssetsImmediate();
//---Reload the objects from selected folders---//
objectsLoadedFromSelectedFolders = LoadObjectsInSelectedFolders();
CreateIconSets();
//---Add loaded icons to list---///
sortedIconSetsByPath.Clear();
foreach (ObjectPathPair loadedObject in objectsLoadedFromSelectedFolders)
{
IconSet iconSet = objectIconSets[loadedObject.UnityEngine_object];
sortedIconSetsByPath.Add(iconSet.assetPath, iconSet);
}
//---Sort the list by path---//
sortedIconSetsByPath = SortIconSetsByFolder(sortedIconSetsByPath);
//---Update variables---//
assetList.lastNumberOfSelected = assetList.selectedFolders.Count;
lastSelectedIndividualFolder = assetList.selectedFolders[0];
}
public void RefreshAllIcons()
{
//---Loop through all icons---//
int index = 1;
foreach (IconSet iconSet in objectIconSets.Values)
{
//---Show a progress bar---//
EditorUtility.DisplayProgressBar("Updating Icons (" + index++ + "/" + objectIconSets.Count + ")", iconSet.assetPath, (float)(index) / (float)(objectIconSets.Count));
//---Update the icon renders---//
Vector2Int renderResolution = Utils.MutiplyVector2IntByFloat(iconSet.GetCurrentIcon().iconSettings.exportResolution, window.iconEditor.resMultiplyers[window.iconEditor.resMultiplyerIndex]);
iconSet.GetCurrentIcon().UpdateIcon(renderResolution, new Vector2Int(128, (int)(((float)renderResolution.y / (float)renderResolution.x) * 128)));
}
//---Clear the progress bar when done---//
EditorUtility.ClearProgressBar();
}
void CheckAndSetWindow(RapidIconWindow w)
{
if (!window)
window = w;
}
List<ObjectPathPair> LoadObjectsInSelectedFolders()
{
//---Get asset paths of all assets in selected folders---//
string[] assetGUIDs = AssetDatabase.FindAssets(filters[filterIdx], assetList.selectedFolders.ToArray());
string[] assetPaths = new string[assetGUIDs.Length];
for (int i = 0; i < assetGUIDs.Length; i++)
assetPaths[i] = AssetDatabase.GUIDToAssetPath(assetGUIDs[i]);
List<ObjectPathPair> loadedObjectPathPairs = new List<ObjectPathPair>();
foreach (string assetPath in assetPaths)
{
//---Get folder path from each of the asset paths---//
string[] split = assetPath.Split('/');
string folderPath = "";
for (int i = 0; i < split.Length - 1; i++)
folderPath += split[i] + (i < split.Length - 2 ? "/" : "");
//---Load the asset if the path is in the selected folders list---//
if (assetList.selectedFolders.Contains(folderPath))
{
ObjectPathPair objectPathPair = new ObjectPathPair();
UnityEngine.Object o = AssetDatabase.LoadMainAssetAtPath(assetPath);
objectPathPair.UnityEngine_object = o;
objectPathPair.path = assetPath;
loadedObjectPathPairs.Add(objectPathPair);
}
}
return loadedObjectPathPairs;
}
void CreateIconSets()
{
int index = 1;
foreach (ObjectPathPair loadedObject in objectsLoadedFromSelectedFolders)
{
if (!objectIconSets.ContainsKey(loadedObject.UnityEngine_object))
{
//---Create icon if doesn't already exist---//
EditorUtility.DisplayProgressBar("Generating Icon Previews (" + index + " / " + (objectsLoadedFromSelectedFolders.Count) + ")", loadedObject.path, (float)(index++) / (float)objectsLoadedFromSelectedFolders.Count);
objectIconSets.Add(loadedObject.UnityEngine_object, CreateIconSet(loadedObject));
}
else if (objectIconSets[loadedObject.UnityEngine_object].deleted)
{
objectIconSets[loadedObject.UnityEngine_object].deleted = false;
}
else
{
//---Update asset path if changed---//
IconSet iconSet = objectIconSets[loadedObject.UnityEngine_object];
string currentPath = AssetDatabase.GetAssetPath(loadedObject.UnityEngine_object);
string savedPath = iconSet.assetPath;
if (savedPath != currentPath)
{
Debug.LogWarning("Path updated for " + iconSet.assetName + " from " + savedPath + " to " + currentPath);
iconSet.assetPath = currentPath;
string[] split;
split = iconSet.assetPath.Split('/');
iconSet.assetName = split[split.Length - 1];
if (iconSet.assetName.Length > 19)
iconSet.assetShortenedName = iconSet.assetName.Substring(0, 16) + "...";
else
iconSet.assetShortenedName = iconSet.assetName;
split = iconSet.assetPath.Split('/');
iconSet.folderPath = "";
for (int i = 0; i < split.Length - 1; i++)
iconSet.folderPath += split[i] + (i < split.Length - 2 ? "/" : "");
}
}
}
EditorUtility.ClearProgressBar();
}
public IconSet CreateIconSet(ObjectPathPair objectPathPair)
{
//---Create a new icon set and icon objects---//
IconSet iconSet = new IconSet(this, objectPathPair);
return iconSet;
}
void DrawIcons(float gridWidth)
{
//---Draw margin---//
GUILayout.Space(14);
GUILayout.BeginHorizontal();
GUILayout.Space(16);
//---Create lists---//
List<Texture2D> visibleIconRenders = new List<Texture2D>();
List<Texture2D> visibleIconSelectionTextures = new List<Texture2D>();
List<string> visibleIconLabels = new List<string>();
visibleIconSets = new List<IconSet>();
//---Reload objects if needed---//
if (sortedIconSetsByPath.Count != objectsLoadedFromSelectedFolders.Count || assetList.selectedFolders.Count != assetList.lastNumberOfSelected || assetList.selectedFolders[0] != lastSelectedIndividualFolder)
{
ReloadObjects();
}
//---Deselect icons if no longer in selected folders / search (i.e. if not visible in the grid)---//
foreach (IconSet iconSet in objectIconSets.Values)
{
if (!assetList.selectedFolders.Contains(iconSet.folderPath) || (assetList.doSearch && !assetList.searchFolders.Contains(iconSet.folderPath + "/" + iconSet.assetName)))
{
iconSet.selected = false;
if (selectedIconSets.Contains(iconSet))
selectedIconSets.Remove(iconSet);
}
}
int index = 0;
foreach (KeyValuePair<string, IconSet> iconSet in sortedIconSetsByPath)
{
//---Skip this icon if it's flagged as deleted---//
if (iconSet.Value.deleted)
continue;
//---Flag the icon as deleted if asset object is null---//
else if (iconSet.Value.assetObject == null)
{
iconSet.Value.deleted = true;
iconSet.Value.assetObject = null;
selectedIconSets.Remove(iconSet.Value);
continue;
}
//---Render the icon preview if it is missing---//
if (iconSet.Value.GetCurrentIcon().previewRender == null)
{
EditorUtility.DisplayProgressBar("Generating Icon Previews (" + index + "/" + (sortedIconSetsByPath.Count) + ")", iconSet.Value.assetPath, ((float)index++ / sortedIconSetsByPath.Count));
iconSet.Value.GetCurrentIcon().previewRender = Utils.RenderIcon(iconSet.Value.GetCurrentIcon(), previewSize, (int)(((float)iconSet.Value.GetCurrentIcon().iconSettings.exportResolution.y / (float)iconSet.Value.GetCurrentIcon().iconSettings.exportResolution.x) * previewSize));
}
//---Set the selection texture---//
if (EditorGUIUtility.isProSkin)
iconSet.Value.selectionTexture = iconSet.Value.selected ? (assetGridFocused ? assetSelectionTextures[1] : assetSelectionTextures[2]) : assetSelectionTextures[0];
else
iconSet.Value.selectionTexture = iconSet.Value.selected ? (assetGridFocused ? assetSelectionTextures[3] : assetSelectionTextures[4]) : assetSelectionTextures[0];
//---Add the icon to visibleIcons if it's within the selected folders, or the search---//
if (assetList.selectedFolders.Contains(iconSet.Value.folderPath) && (!assetList.doSearch || assetList.searchFolders.Contains(iconSet.Value.folderPath + "/" + iconSet.Value.assetName)))
{
visibleIconSets.Add(iconSet.Value);
//Use warning image if animations enabled
visibleIconRenders.Add(iconSet.Value.GetCurrentIcon().previewRender);
visibleIconSelectionTextures.Add(iconSet.Value.selectionTexture);
visibleIconLabels.Add(iconSet.Value.assetShortenedName);
}
}
EditorUtility.ClearProgressBar();
//---Draw the grid of icons---///
int count = Mathf.FloorToInt((gridWidth - 16) / (previewSize + 16));
count = Mathf.Min(count, visibleIconSets.Count);
int clicked = GUILayout.SelectionGrid(-1, visibleIconRenders.ToArray(), count, gridStyle, GUILayout.Width(32 + count * (previewSize + 16)));
Rect r = GUILayoutUtility.GetLastRect();
r.y += previewSize + 2;
//---Draw the label background textures on the grid---//
int labelClicked = GUI.SelectionGrid(r, -1, visibleIconSelectionTextures.ToArray(), count, gridLabelStyle);
//---Draw the label texts on the grid---//
clicked = GUI.SelectionGrid(r, clicked, visibleIconLabels.ToArray(), count, gridLabelStyle);
if (clicked == -1 && labelClicked != -1)
clicked = labelClicked;
//---Draw margin and end GUI elements---//
GUILayout.Space(16);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
//---Check mouse clicks and arrow key presses for grid selection---//
CheckMouseClicks(clicked, visibleIconSets);
CheckArrowKeys(visibleIconSets, count);
}
void CheckMouseClicks(int clicked, List<IconSet> visibleIconSets)
{
if (clicked >= 0)
{
if (!Event.current.control && !Event.current.shift)
{
//---Regular click, no ctrl/shift - select the icon---//
foreach (KeyValuePair<UnityEngine.Object, IconSet> iconSet in objectIconSets)
iconSet.Value.selected = false;
visibleIconSets[clicked].selected = true;
visibleIconSets[clicked].assetGridIconIndex = clicked;
selectedIconSets.Clear();
selectionMinIndex = clicked;
selectionMaxIndex = clicked;
}
else if (Event.current.control)
{
//---Ctrl click - add icon to existing selection---//
visibleIconSets[clicked].selected = !visibleIconSets[clicked].selected;
visibleIconSets[clicked].assetGridIconIndex = clicked;
}
else if (Event.current.shift)
{
//---Shift click - add all icons between clicks---//
if (selectionMinIndex != -1 && selectionMaxIndex != -1 && clicked >= selectionMinIndex && clicked <= selectionMaxIndex)
{
for (int i = selectionMinIndex; i <= selectionMaxIndex; i++)
{
visibleIconSets[i].selected = false;
if (selectedIconSets.Contains(visibleIconSets[i]))
selectedIconSets.Remove(visibleIconSets[i]);
}
selectionMinIndex = Mathf.Min(lastSelectedIconIndex, clicked);
selectionMaxIndex = Math.Max(lastSelectedIconIndex, clicked);
}
int minI = Mathf.Min(lastSelectedIconIndex, clicked);
int maxI = Math.Max(lastSelectedIconIndex, clicked);
if (minI < 0) minI = 0;
if (maxI < 0) maxI = 0;
for (int i = minI; i <= maxI; i++)
{
visibleIconSets[i].selected = true;
visibleIconSets[i].assetGridIconIndex = i;
if (!selectedIconSets.Contains(visibleIconSets[i]))
selectedIconSets.Add(visibleIconSets[i]);
}
}
//---If not shift click then toggle the icon from the selection---//
if (!Event.current.shift)
{
if (visibleIconSets[clicked].selected && !selectedIconSets.Contains(visibleIconSets[clicked]))
selectedIconSets.Add(visibleIconSets[clicked]);
else if (selectedIconSets.Contains(visibleIconSets[clicked]))
selectedIconSets.Remove(visibleIconSets[clicked]);
}
//---Sort the selected icons by grid index---//
if (selectedIconSets.Count > 1)
selectedIconSets = selectedIconSets.OrderBy(a => a.assetGridIconIndex).ToList();
//---Update variables---//
selectionMinIndex = Mathf.Min(selectionMinIndex, clicked);
selectionMaxIndex = Mathf.Max(selectionMaxIndex, clicked);
lastSelectedIconIndex = clicked;
assetGridFocused = true;
window.Repaint();
}
else if (Event.current.rawType == EventType.MouseDown && !window.leftSeparator.mouseOver && !window.rightSeparator.mouseOver)
{
//---Clear selection if mouse clicked in empty space in asset grid region---//
Vector2 correctMousePos = Event.current.mousePosition + rect.position;
if (rect.Contains(correctMousePos))
{
selectedIconSets.Clear();
foreach (IconSet iconSet in visibleIconSets)
iconSet.selected = false;
}
}
}
void CheckArrowKeys(List<IconSet> iconSets, int gridXIcons)
{
//---Check if a key is pressed---//
if (assetGridFocused && Event.current.isKey && Event.current.type != EventType.KeyUp)
{
//---Right arrow key pressed---//
if (Event.current.keyCode == KeyCode.RightArrow && lastSelectedIconIndex < iconSets.Count - 1)
{
if (!Event.current.shift && !Event.current.control)
{
//---Select only this icon if no shift/ctrl pressed---//
foreach (IconSet iconSet in iconSets)
iconSet.selected = false;
selectedIconSets.Clear();
iconSets[lastSelectedIconIndex + 1].selected = true;
selectedIconSets.Add(iconSets[lastSelectedIconIndex + 1]);
}
else
{
//---Add to current selection if shift/ctrl pressed---///
if (!iconSets[lastSelectedIconIndex + 1].selected)
{
iconSets[lastSelectedIconIndex + 1].selected = true;
selectedIconSets.Add(iconSets[lastSelectedIconIndex + 1]);
}
else
{
iconSets[lastSelectedIconIndex].selected = false;
selectedIconSets.Remove(iconSets[lastSelectedIconIndex]);
}
}
lastSelectedIconIndex++;
}
//---Left arrow key pressed---//
else if (Event.current.keyCode == KeyCode.LeftArrow && lastSelectedIconIndex > 0)
{
if (!Event.current.shift && !Event.current.control)
{
//---Select only this icon if no shift/ctrl pressed---//
foreach (IconSet iconSet in iconSets)
iconSet.selected = false;
selectedIconSets.Clear();
iconSets[lastSelectedIconIndex - 1].selected = true;
selectedIconSets.Add(iconSets[lastSelectedIconIndex - 1]);
}
else
{
//---Add to current selection if shift/ctrl pressed---///
if (!iconSets[lastSelectedIconIndex - 1].selected)
{
iconSets[lastSelectedIconIndex - 1].selected = true;
selectedIconSets.Add(iconSets[lastSelectedIconIndex - 1]);
}
else
{
iconSets[lastSelectedIconIndex].selected = false;
selectedIconSets.Remove(iconSets[lastSelectedIconIndex]);
}
}
lastSelectedIconIndex--;
}
//---Down arrow key pressed---//
else if (Event.current.keyCode == KeyCode.DownArrow)
{
if (lastSelectedIconIndex < iconSets.Count - gridXIcons)
{
if (!Event.current.shift && !Event.current.control)
{
//---Select only this icon if no shift/ctrl pressed---//
foreach (IconSet iconSet in iconSets)
iconSet.selected = false;
selectedIconSets.Clear();
iconSets[lastSelectedIconIndex + gridXIcons].selected = true;
selectedIconSets.Add(iconSets[lastSelectedIconIndex + gridXIcons]);
}
else
{
//---Add to current selection if shift/ctrl pressed---///
if (!iconSets[lastSelectedIconIndex + gridXIcons].selected)
{
iconSets[lastSelectedIconIndex + gridXIcons].selected = true;
selectedIconSets.Add(iconSets[lastSelectedIconIndex + gridXIcons]);
for (int i = lastSelectedIconIndex; i < lastSelectedIconIndex + gridXIcons; i++)
{
iconSets[i].selected = true;
selectedIconSets.Add(iconSets[i]);
}
}
else
{
iconSets[lastSelectedIconIndex].selected = false;
selectedIconSets.Remove(iconSets[lastSelectedIconIndex]);
for (int i = lastSelectedIconIndex; i < lastSelectedIconIndex + gridXIcons; i++)
{
iconSets[i].selected = false;
selectedIconSets.Remove(iconSets[i]);
}
}
}
lastSelectedIconIndex += gridXIcons;
}
else if (lastSelectedIconIndex < Mathf.Floor((float)iconSets.Count / gridXIcons) * gridXIcons)
{
if (!Event.current.shift && !Event.current.control)
{
//---Select only this icon if no shift/ctrl pressed---//
foreach (IconSet iconSet in iconSets)
iconSet.selected = false;
selectedIconSets.Clear();
iconSets[iconSets.Count - 1].selected = true;
selectedIconSets.Add(iconSets[iconSets.Count - 1]);
}
else
{
//---Add to current selection if shift/ctrl pressed---///
if (!iconSets[iconSets.Count - 1].selected)
{
iconSets[iconSets.Count - 1].selected = true;
selectedIconSets.Add(iconSets[iconSets.Count - 1]);
for (int i = lastSelectedIconIndex; i < iconSets.Count; i++)
{
iconSets[i].selected = true;
selectedIconSets.Add(iconSets[i]);
}
}
else
{
iconSets[lastSelectedIconIndex].selected = false;
selectedIconSets.Remove(iconSets[lastSelectedIconIndex]);
for (int i = lastSelectedIconIndex; i < iconSets.Count - 1; i++)
{
iconSets[i].selected = false;
selectedIconSets.Remove(iconSets[i]);
}
}
}
lastSelectedIconIndex = iconSets.Count - 1;
}
}
//---Up arrow key pressed---//
else if (Event.current.keyCode == KeyCode.UpArrow && lastSelectedIconIndex >= gridXIcons)
{
if (!Event.current.shift && !Event.current.control)
{
//---Select only this icon if no shift/ctrl pressed---//
foreach (IconSet iconSet in iconSets)
iconSet.selected = false;
selectedIconSets.Clear();
iconSets[lastSelectedIconIndex - gridXIcons].selected = true;
selectedIconSets.Add(iconSets[lastSelectedIconIndex - gridXIcons]);
}
else
{
//---Add to current selection if shift/ctrl pressed---///
if (!iconSets[lastSelectedIconIndex - gridXIcons].selected)
{
iconSets[lastSelectedIconIndex - gridXIcons].selected = true;
selectedIconSets.Add(iconSets[lastSelectedIconIndex - gridXIcons]);
for (int i = lastSelectedIconIndex; i > lastSelectedIconIndex - gridXIcons; i--)
{
iconSets[i].selected = true;
selectedIconSets.Add(iconSets[i]);
}
}
else
{
iconSets[lastSelectedIconIndex].selected = false;
selectedIconSets.Remove(iconSets[lastSelectedIconIndex]);
for (int i = lastSelectedIconIndex; i > lastSelectedIconIndex - gridXIcons; i--)
{
iconSets[i].selected = false;
selectedIconSets.Remove(iconSets[i]);
}
}
}
lastSelectedIconIndex -= gridXIcons;
}
else if (Event.current.keyCode == KeyCode.A && Event.current.modifiers == EventModifiers.Control)
{
//---Select all if ctrl-A pressed---//
selectedIconSets.Clear();
foreach (KeyValuePair<string, IconSet> iconSet in sortedIconSetsByPath)
{
if (assetList.selectedFolders.Contains(iconSet.Value.folderPath))
{
iconSet.Value.selected = true;
selectedIconSets.Add(iconSet.Value);
}
}
}
}
}
Dictionary<string, IconSet> SortIconSetsByFolder(Dictionary<string, IconSet> data)
{
//---Get a string array of asset paths---//
string[] assetPaths = new string[data.Keys.Count];
data.Keys.CopyTo(assetPaths, 0);
//---Create a dictionary that will hold folder paths as keys, and a list of asset paths in the values (assets within the folder)---//
Dictionary<string, List<string>> folders = new Dictionary<string, List<string>>();
//---Create a list for just the folder names---//
List<string> folderNames = new List<string>();
foreach (string assetPath in assetPaths)
{
//---Get folder path from asset path---//
string[] split = assetPath.Split('/');
string folderPath = "";
for (int i = 0; i < split.Length - 1; i++)
folderPath += split[i] + (i < split.Length - 2 ? "/" : "");
//---Add folder to folders dictionary if not already in there---//
if (!folders.ContainsKey(folderPath))
{
folders.Add(folderPath, new List<string>());
folderNames.Add(folderPath);
}
//---Add asset path in the list at the [folderPath] index of the folders dictionary---//
folders[folderPath].Add(assetPath);
}
//---Sort the folder names---//
folderNames.Sort();
//---For each of the sorted folders, sort the assets within that folder---//
string[] sortedAssetPaths = new string[assetPaths.Length];
int index = 0;
foreach (string folder in folderNames)
{
folders[folder].Sort();
foreach (string assetPath in folders[folder])
{
//---Add the asset paths to the new list in sorted order---//
sortedAssetPaths[index++] = assetPath;
}
}
//---Use the sorted list of asset paths to create a dictionary of sorted icons---//
Dictionary<string, IconSet> sortedData = new Dictionary<string, IconSet>();
foreach (string assetPath in sortedAssetPaths)
{
sortedData.Add(assetPath, data[assetPath]);
}
return sortedData;
}
void CheckFocus(Rect checkRect)
{
//---Check if last mouse click was in the asset grid rect---//
if (Event.current.rawType == EventType.MouseDown)
{
assetGridFocused = checkRect.Contains(Event.current.mousePosition);
}
//---Check the RapidIcon window is in focus---//
if (EditorWindow.focusedWindow != null && EditorWindow.focusedWindow.GetType() != typeof(RapidIconWindow))
assetGridFocused = false;
}
IconSet GetIconSetFromPath(string path)
{
//---Loop through icons and check if the path matches---//
foreach (IconSet iconSet in objectIconSets.Values)
{
if (iconSet.assetPath == path)
return iconSet;
}
return null;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2c67b68295a3db64db12b09928f40b1f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,582 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace RapidIcon_1_7_2
{
[Serializable]
public class AssetList
{
//---PUBLIC---///
//Selected folders
public List<string> selectedFolders;
public int lastNumberOfSelected;
//Search
public bool doSearch;
public List<string> searchFolders;
//---INTERNAL---//
//Foldouts
bool foldoutColoursSet;
GUIStyle foldoutStyle, foldoutStyleSelected;
Dictionary<string, bool> foldoutStates;
bool foldoutsUpdated;
List<string> visibleFolders;
//Selection
string selectionMinFolder, selectionMaxFolder, firstSelectedFolder, lastSelectedFolder, selectFolder;
int arrowSelectedFolder;
//Textures
Texture2D[] selectionTextures;
Texture2D[] folderIcons;
//Search
string searchString;
//Other
RapidIconWindow window;
bool assetListFocused, initialised;
string rootFolder;
Vector2 scrollPosition;
public AssetList(string appDataPath)
{
//---Initialise AssetList---//
//Foldouts
foldoutColoursSet = false;
foldoutStyle = foldoutStyleSelected = new GUIStyle();
foldoutStates = new Dictionary<string, bool>();
visibleFolders = new List<string>();
foldoutsUpdated = false;
//Search
searchFolders = new List<string>();
searchString = "";
doSearch = false;
//Selection
selectionTextures = new Texture2D[2];
if (EditorGUIUtility.isProSkin)
{
selectionTextures[0] = Utils.CreateColourTexture(2, 2, new Color32(44, 93, 135, 255));
selectionTextures[1] = Utils.CreateColourTexture(2, 2, new Color32(77, 77, 77, 255));
}
else
{
selectionTextures[0] = Utils.CreateColourTexture(2, 2, new Color32(58, 114, 176, 255));
selectionTextures[1] = Utils.CreateColourTexture(2, 2, new Color32(174, 174, 174, 255));
}
selectionTextures[0].hideFlags = HideFlags.DontSave;
selectionTextures[1].hideFlags = HideFlags.DontSave;
arrowSelectedFolder = 0;
selectedFolders = new List<string>();
firstSelectedFolder = "";
lastSelectedFolder = "";
selectionMinFolder = "";
selectionMaxFolder = "";
selectFolder = "";
//Root Paths
string[] rootFolderSplit = appDataPath.Split('/');
rootFolder = rootFolderSplit[rootFolderSplit.Length - 1];
string[] split = AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("RapidIcon")[0]).Split('/');
string rapidIconRootFolder = "";
for (int i = 0; i < split.Length; i++)
rapidIconRootFolder += split[i] + "/";
//Folder Icons
folderIcons = new Texture2D[4];
folderIcons[0] = (Texture2D)AssetDatabase.LoadMainAssetAtPath(rapidIconRootFolder + "Editor/UI/folderIconClosedDark.png");
folderIcons[1] = (Texture2D)AssetDatabase.LoadMainAssetAtPath(rapidIconRootFolder + "Editor/UI/folderIconOpenDark.png");
folderIcons[2] = (Texture2D)AssetDatabase.LoadMainAssetAtPath(rapidIconRootFolder + "Editor/UI/folderIconClosedLight.png");
folderIcons[3] = (Texture2D)AssetDatabase.LoadMainAssetAtPath(rapidIconRootFolder + "Editor/UI/folderIconOpenLight.png");
//Other
assetListFocused = true;
}
public void Draw(float width, RapidIconWindow w)
{
//---Check variables are set---//
CheckAndSetWindow(w);
CheckAndSetFoldoutColours();
CheckArrowKeys();
//---Search Bar---//
GUILayout.BeginVertical(GUILayout.Width(width));
EditorGUI.BeginChangeCheck();
searchString = GUILayout.TextField(searchString);
if (searchString == "")
{
Rect r = GUILayoutUtility.GetLastRect();
GUI.Label(r, "Search Models and Prefabs");
searchFolders.Clear();
doSearch = false;
}
else if (EditorGUI.EndChangeCheck())
{
doSearch = true;
searchFolders.Clear();
string[] results = AssetDatabase.FindAssets(searchString);
if (results.Length > 0)
{
foreach (string guid in results)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if (AssetDatabase.GetMainAssetTypeAtPath(path) == typeof(GameObject))
{
searchFolders.Add(path);
}
}
}
}
//---Draw asset list folders---//
visibleFolders.Clear();
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false, GUIStyle.none, GUI.skin.verticalScrollbar, GUILayout.Width(width));
if (!foldoutsUpdated)
{
UpdateFoldoutStates(rootFolder, true);
foldoutsUpdated = true;
}
DrawAllSubFolders(rootFolder, 0, width);
if (selectFolder != "")
{
SelectFolder(selectFolder, 0);
selectFolder = "";
}
GUILayout.EndScrollView();
GUILayout.EndVertical();
//---Check if asset list is focused---//
CheckFocus(GUILayoutUtility.GetLastRect());
}
public void SaveData()
{
//---Save all opened folders---//
string openedFoldersString = "";
foreach (KeyValuePair<string, bool> foldoutState in foldoutStates)
{
if (foldoutState.Value)
openedFoldersString += "|-F-|" + foldoutState.Key;
}
EditorPrefs.SetString(PlayerSettings.productName + "RapidIconOpenedFolders", openedFoldersString);
//---Save all selected folders---//
string selectedFoldersString = "";
foreach (string folder in selectedFolders)
{
selectedFoldersString += "|-F-|" + folder;
}
EditorPrefs.SetString(PlayerSettings.productName + "RapidIconSelectedFolders", selectedFoldersString);
}
public void LoadData()
{
//---Load all opened folders---//
string openedFoldersString = EditorPrefs.GetString(PlayerSettings.productName + "RapidIconOpenedFolders");
string[] openedFoldersSplit = openedFoldersString.Split(new string[] { "|-F-|" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string folder in openedFoldersSplit)
foldoutStates.Add(folder, true);
//---Load all selected folders---//
string selectedFoldersString = EditorPrefs.GetString(PlayerSettings.productName + "RapidIconSelectedFolders");
string[] selectedFoldersSplit = selectedFoldersString.Split(new string[] { "|-F-|" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string folder in selectedFoldersSplit)
selectedFolders.Add(folder);
if (selectedFolders.Count == 0)
selectedFolders.Add(rootFolder);
selectedFolders.Sort();
}
void CheckAndSetWindow(RapidIconWindow w)
{
if (!window)
window = w;
}
void CheckAndSetFoldoutColours()
{
if (!foldoutColoursSet)
{
foldoutStyle = new GUIStyle(EditorStyles.foldout);
foldoutStyleSelected = new GUIStyle(EditorStyles.foldout);
Color txtCol = new Color32(192, 192, 192, 255);
if (EditorGUIUtility.isProSkin)
{
//---Set unselected foldout style---//
foldoutStyle.normal.textColor = txtCol;
foldoutStyle.onNormal.textColor = txtCol;
foldoutStyle.hover.textColor = txtCol;
foldoutStyle.onHover.textColor = txtCol;
foldoutStyle.focused.textColor = txtCol;
foldoutStyle.onFocused.textColor = txtCol;
foldoutStyle.active.textColor = txtCol;
foldoutStyle.onActive.textColor = txtCol;
//---Set selected foldout style---//
foldoutStyleSelected.normal.textColor = txtCol;
foldoutStyleSelected.onNormal.textColor = txtCol;
foldoutStyleSelected.hover.textColor = txtCol;
foldoutStyleSelected.onHover.textColor = txtCol;
foldoutStyleSelected.focused.textColor = txtCol;
foldoutStyleSelected.onFocused.textColor = txtCol;
foldoutStyleSelected.active.textColor = txtCol;
foldoutStyleSelected.onActive.textColor = txtCol;
}
else
{
//---Set unselected foldout style---//
foldoutStyle.normal.textColor = Color.black;
foldoutStyle.onNormal.textColor = Color.black;
foldoutStyle.hover.textColor = Color.black;
foldoutStyle.onHover.textColor = Color.black;
foldoutStyle.focused.textColor = Color.black;
foldoutStyle.onFocused.textColor = Color.black;
foldoutStyle.active.textColor = Color.black;
foldoutStyle.onActive.textColor = Color.black;
//---Set selected foldout style---//
foldoutStyleSelected.normal.textColor = Color.white;
foldoutStyleSelected.onNormal.textColor = Color.white;
foldoutStyleSelected.hover.textColor = Color.white;
foldoutStyleSelected.onHover.textColor = Color.white;
foldoutStyleSelected.focused.textColor = Color.white;
foldoutStyleSelected.onFocused.textColor = Color.white;
foldoutStyleSelected.active.textColor = Color.white;
foldoutStyleSelected.onActive.textColor = Color.white;
}
foldoutColoursSet = true;
}
}
void CheckArrowKeys()
{
//---Check if a key is pressed---//
if (assetListFocused && Event.current.isKey && Event.current.type != EventType.KeyUp)
{
//---Fold out folders if right arrow key pressed---//
if (Event.current.keyCode == KeyCode.RightArrow)
{
foreach (string f in selectedFolders)
{
//Fold out subfolders as well if alt pressed
if (Event.current.alt)
SetAllFoldoutChildren(f, true);
else
foldoutStates[f] = true;
}
GUIUtility.ExitGUI();
}
//---Collapse folders if left arrow key pressed---//
else if (Event.current.keyCode == KeyCode.LeftArrow)
{
foreach (string f in selectedFolders)
{
//Fold in subfolders as well if alt pressed
if (Event.current.alt)
SetAllFoldoutChildren(f, false);
else
foldoutStates[f] = false;
}
GUIUtility.ExitGUI();
}
//---Select folder below if down arrow key pressed---//
else if (Event.current.keyCode == KeyCode.DownArrow && arrowSelectedFolder < visibleFolders.Count - 1)
{
SelectFolder(visibleFolders[++arrowSelectedFolder], -1);
GUIUtility.ExitGUI();
}
//---Select folder above if up arrow key pressed---//
else if (Event.current.keyCode == KeyCode.UpArrow && arrowSelectedFolder > 0)
{
SelectFolder(visibleFolders[--arrowSelectedFolder], 1);
GUIUtility.ExitGUI();
}
}
}
void CheckFocus(Rect rect)
{
//---Check if last mouse click was in the asset list rect---//
if (Event.current.rawType == EventType.MouseDown)
assetListFocused = rect.Contains(Event.current.mousePosition);
if (assetListFocused)
window.assetGrid.assetGridFocused = false;
//---Check the RapidIcon window is in focus---//
if (EditorWindow.focusedWindow != null && EditorWindow.focusedWindow.GetType() != typeof(RapidIconWindow))
assetListFocused = false;
}
void SetAllFoldoutChildren(string folder, bool foldout)
{
//---Set foldout state of folder---//
if (!foldoutStates.ContainsKey(folder))
foldoutStates.Add(folder, foldout);
else
foldoutStates[folder] = foldout;
//---Set foldout state of sub folders---//
string[] subfolders = AssetDatabase.GetSubFolders(folder);
foreach (string subfolder in subfolders)
SetAllFoldoutChildren(subfolder, foldout);
}
void SelectFolder(string folder, int keyAdjust)
{
assetListFocused = true;
arrowSelectedFolder = visibleFolders.IndexOf(folder);
//---Select this folder only---//
if (!Event.current.control && !Event.current.shift)
{
selectedFolders.Clear();
selectedFolders.Add(folder);
firstSelectedFolder = folder;
lastSelectedFolder = folder;
selectionMinFolder = folder;
selectionMaxFolder = folder;
}
//---Control select, add folder to selection---//
else if (!Event.current.shift)
{
if (!selectedFolders.Contains(folder))
{
if (selectionMinFolder == "")
selectionMinFolder = folder;
if (selectionMaxFolder == "")
selectionMaxFolder = folder;
selectedFolders.Add(folder);
lastSelectedFolder = folder;
int lastSelectedFolderIndex = visibleFolders.IndexOf(lastSelectedFolder);
int selectionMinIndex = visibleFolders.IndexOf(selectionMinFolder);
if (selectionMinIndex == -1)
selectionMinIndex = lastSelectedFolderIndex;
int selectionMaxIndex = visibleFolders.IndexOf(selectionMaxFolder);
if (selectionMaxIndex == -1)
selectionMinIndex = lastSelectedFolderIndex;
selectionMinFolder = visibleFolders[Mathf.Min(lastSelectedFolderIndex, selectionMinIndex)];
selectionMaxFolder = visibleFolders[Mathf.Max(lastSelectedFolderIndex, selectionMaxIndex)];
}
else if (selectedFolders.Count > 1)
selectedFolders.Remove(visibleFolders[visibleFolders.IndexOf(folder) + keyAdjust]);
}
//---Shift select, select folder and folders inbetween---//
else
{
if (selectionMinFolder == "")
selectionMinFolder = folder;
if (selectionMaxFolder == "")
selectionMaxFolder = folder;
if (lastSelectedFolder == "")
lastSelectedFolder = folder;
if (firstSelectedFolder == "")
firstSelectedFolder = folder;
int thisFolderIndex = visibleFolders.IndexOf(folder);
int lastSelectedFolderIndex = visibleFolders.IndexOf(lastSelectedFolder);
int firstSelectedFolderIndex = visibleFolders.IndexOf(firstSelectedFolder);
int selectionMinIndex = visibleFolders.IndexOf(selectionMinFolder);
int selectionMaxIndex = visibleFolders.IndexOf(selectionMaxFolder);
if (selectionMinIndex == -1)
selectionMinIndex = int.MaxValue;
int minI = 0, maxI = -1;
if (thisFolderIndex >= selectionMinIndex && thisFolderIndex <= selectionMaxIndex)
{
selectedFolders.Clear();
minI = Mathf.Min(firstSelectedFolderIndex, thisFolderIndex);
maxI = Math.Max(firstSelectedFolderIndex, thisFolderIndex);
selectionMinFolder = visibleFolders[minI];
selectionMaxFolder = visibleFolders[maxI];
}
else
{
minI = Mathf.Min(lastSelectedFolderIndex, thisFolderIndex, selectionMinIndex);
maxI = Mathf.Max(lastSelectedFolderIndex, thisFolderIndex, selectionMaxIndex);
selectionMinFolder = visibleFolders[Mathf.Min(minI, selectionMinIndex)];
selectionMaxFolder = visibleFolders[Mathf.Max(maxI, selectionMaxIndex)];
}
lastSelectedFolder = visibleFolders[thisFolderIndex];
for (int i = minI; i <= maxI; i++)
{
if (!selectedFolders.Contains(visibleFolders[i]))
selectedFolders.Add(visibleFolders[i]);
}
}
}
void UpdateFoldoutStates(string folder, bool foldout)
{
//---Add this folder to the foldoutStates if it's not already added---//
if (!foldoutStates.ContainsKey(folder))
foldoutStates.Add(folder, foldout);
//---Get the subfolders and update those too---
string[] subfolders = AssetDatabase.GetSubFolders(folder);
foreach (string subfolder in subfolders)
{
UpdateFoldoutStates(subfolder, false);
}
}
void DrawAllSubFolders(string folder, int depth, float width)
{
//---If searching, check this folder is in the search results---//
bool inSearch = false;
foreach (string f in searchFolders)
{
if (f.Contains(folder))
{
inSearch = true;
break;
}
}
if (!inSearch && doSearch && depth > 0)
return;
visibleFolders.Add(folder);
//---Get display name and folder icon---//
string[] split = folder.Split('/');
string displayName = split[split.Length - 1];
displayName = " " + displayName;
GUIContent folderGuiContent;
if (!foldoutStates.ContainsKey(folder))
UpdateFoldoutStates(folder, false);
if (EditorGUIUtility.isProSkin || (selectedFolders.Contains(folder) && assetListFocused))
folderGuiContent = new GUIContent(displayName, foldoutStates[folder] ? folderIcons[1] : folderIcons[0]);
else
folderGuiContent = new GUIContent(displayName, foldoutStates[folder] ? folderIcons[3] : folderIcons[2]);
//---Use bold font for root "Assets" folder---//
if (depth == 0)
{
foldoutStyle.fontStyle = FontStyle.Bold;
foldoutStyleSelected.fontStyle = FontStyle.Bold;
}
else
{
foldoutStyle.fontStyle = FontStyle.Normal;
foldoutStyleSelected.fontStyle = FontStyle.Normal;
}
//---Get rect for this folder---//
Rect r = GUILayoutUtility.GetRect(folderGuiContent, GUI.skin.label);
r.position += new Vector2(15 * depth, 0);
r.yMin -= 1; r.yMax += 1;
//---Draw selection texture if folder is selected---//
if (selectedFolders.Contains(folder))
{
Rect selectRect = new Rect(r);
selectRect.position = new Vector2(0, r.position.y);
selectRect.width = width;
GUI.DrawTexture(selectRect, assetListFocused ? selectionTextures[0] : selectionTextures[1]);
if (window)
window.Repaint();
}
//---Get subfolders---//
string[] subfolders = AssetDatabase.GetSubFolders(folder);
if (subfolders.Length > 0)
{
//---Create clickArea rects---//
//There are two click areas, to the left and right of the foldout arrow button
Rect clickArea = new Rect(r);
Rect clickAreaLeft = new Rect(r);
clickArea.position += new Vector2(15, 0);
clickArea.width -= 15;
clickAreaLeft.width = 15 * depth;
clickAreaLeft.position = new Vector2(0, clickAreaLeft.position.y);
r.width = 15;
//---Check if either clickArea is clicked---//
if (GUI.Button(clickArea, "", GUIStyle.none) || GUI.Button(clickAreaLeft, "", GUIStyle.none))
{
selectFolder = folder;
window.assetGrid.assetGridFocused = false;
}
//---Draw the foldouts---//
//Store the original states before drawing so a change check can be done
bool chk = foldoutStates[folder];
foldoutStates[folder] = EditorGUI.Foldout(r, foldoutStates[folder], folderGuiContent, (selectedFolders.Contains(folder) && assetListFocused) ? foldoutStyleSelected : foldoutStyle);
//---If foldoutStates have changed---//
if (foldoutStates[folder] != chk)
{
//---Set focus true---//
assetListFocused = true;
GUI.FocusControl(null);
//---If alt key pressed, set all child folder states to match parent---//
if (Event.current.alt)
SetAllFoldoutChildren(folder, foldoutStates[folder]);
}
//---If foldout state is open---//
if (foldoutStates[folder])
{
//---Draw the sub folders (recursive)---
foreach (string subfolder in subfolders)
{
DrawAllSubFolders(subfolder, depth + 1, width);
}
}
}
else
{
//---If no subfolders, then draw a button (no style, i.e. clickable label) instead of a foldout---//
r.position += new Vector2(12, 0);
GUIStyle l = new GUIStyle(GUI.skin.label);
if (EditorGUIUtility.isProSkin)
l.normal.textColor = new Color32(192, 192, 192, 255);
else
l.normal.textColor = (selectedFolders.Contains(folder) && assetListFocused) ? Color.white : Color.black;
l.hover.textColor = l.normal.textColor;
l.active.textColor = l.normal.textColor;
Rect clickAreaLeft = new Rect(r);
clickAreaLeft.width = 15 * (depth + 1) + 4;
clickAreaLeft.position = new Vector2(0, clickAreaLeft.position.y);
if (GUI.Button(r, folderGuiContent, l) || GUI.Button(clickAreaLeft, "", GUIStyle.none))
{
selectFolder = folder;
window.assetGrid.assetGridFocused = false;
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 24f69c03ee5a76f4e8aae24472f18a45
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b6b314e68def01e4db28f252a736e048
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,721 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace RapidIcon_1_7_2
{
[Serializable]
public class IconEditor
{
//---PUBLIC---//
//Textures
public Texture2D previewBackgroundImage;
public Texture2D scrollAreaBackgroundImage;
public Texture2D scaleLinkOnImage;
public Texture2D scaleLinkOffImage;
public Texture2D separatorTex;
//Icon resolution
public Vector2Int renderResolution;
public Vector2Int renderSize;
public int resMultiplyerIndex;
public float[] resMultiplyers = new float[] { 0.25f, 0.5f, 1f };
//Icons
public Icon currentIcon;
public IconSet currentIconSet;
public bool updateFlag;
//Tabs
public bool linkScale;
public MaterialEditor materialEditor;
public Material mat;
public ReorderableList reorderableList;
public string lastPresetPath;
public string[] tabNames = new string[] { "Object", "Hierarchy", "Camera", "Lighting", "Animation", "Post-Processing", "Export" };
//RapidIcon Window Elements/Settings
public RapidIconWindow window;
public AssetGrid assetGrid;
public ReorderableListCallbacks reorderableListCallbacks;
public bool fullscreen;
public float fullWidth;
public float sepWidth;
public float oldMinWidth;
//Other
public bool replaceAll;
//---INTERNAL---//
//Preview zoom/resolution
int zoomScaleIndex;
float[] zoomScales = new float[] { 0.25f, 0.5f, 0.75f, 1f, 1.25f, 1.5f, 2f, 3f, 1f };
string[] zoomScalesStrings = new string[] { "25%", "50%", "75%", "100%", "125%", "150%", "200%", "300%", "Scale to Fit (num %)" };
string[] resMultiplyersStrings = new string[] { "Quarter", "Half", "Full" };
int zoomFitByWidthHeight; //0: height, 1: width
//Preview GUI
Vector2 previewScrollPos;
GUIStyle renderStyle;
GUIStyle scrollStyle;
Vector2 previewAreaSize;
Rect previewRect;
DraggableSeparator previewDraggableSeparator;
//Tabs
Vector2 controlsScrollPos;
public int tab;
//Icons
int currentIconIndex;
bool updateAllFlag;
//Other
bool undoHold;
bool sceneChangeUpdate = false;
public IconEditor(AssetGrid grid, RapidIconWindow w)
{
//---Initialise IconEditor---//
//Set RapidIcon elements
CheckAndSetWindow(w);
assetGrid = grid;
//Render resolution/style
renderResolution = new Vector2Int(256, 256);
renderSize = new Vector2Int(256, 256);
renderStyle = new GUIStyle();
renderStyle.stretchWidth = true;
renderStyle.stretchHeight = true;
renderStyle.stretchHeight = true;
renderStyle.stretchWidth = true;
//Set preview zoom/resolution setting
zoomScaleIndex = 8;
resMultiplyerIndex = 2;
//Create colour textures
scrollAreaBackgroundImage = Utils.CreateColourTexture(4, 4, new Color32(50, 50, 50, 255));
if (EditorGUIUtility.isProSkin)
separatorTex = Utils.CreateColourTexture(2, 2, new Color32(31, 31, 31, 255));
else
separatorTex = Utils.CreateColourTexture(2, 2, new Color32(153, 153, 153, 255));
//Load textures
previewBackgroundImage = (Texture2D)AssetDatabase.LoadMainAssetAtPath(assetGrid.rapidIconRootFolder + "Editor/UI/previewGrid.png");
scaleLinkOnImage = (Texture2D)AssetDatabase.LoadMainAssetAtPath(assetGrid.rapidIconRootFolder + "Editor/UI/linkOn.png");
scaleLinkOffImage = (Texture2D)AssetDatabase.LoadMainAssetAtPath(assetGrid.rapidIconRootFolder + "Editor/UI/linkOff.png");
//Create horizontal separator
previewDraggableSeparator = new DraggableSeparator(SeparatorTypes.Horizontal);
//Set bools
linkScale = true;
replaceAll = false;
//Create material editor
mat = new Material(Shader.Find("RapidIcon/ImgShader"));
materialEditor = (MaterialEditor)Editor.CreateEditor(mat);
//Create reorderable list for post-processing shaders
List<Material> blankList = new List<Material>();
reorderableList = new ReorderableList(blankList, typeof(Material), true, true, true, true);
reorderableListCallbacks = new ReorderableListCallbacks(this);
reorderableList.drawElementCallback = reorderableListCallbacks.DrawListItems;
reorderableList.drawHeaderCallback = reorderableListCallbacks.DrawHeader;
reorderableList.onSelectCallback = reorderableListCallbacks.SelectShader;
reorderableList.onAddCallback = reorderableListCallbacks.AddShader;
reorderableList.onRemoveCallback = reorderableListCallbacks.RemoveShader;
reorderableList.onReorderCallback = reorderableListCallbacks.ShadersReorded;
//Configure undo
undoHold = false;
Undo.undoRedoPerformed += OnUndo;
}
public void Draw(float width, RapidIconWindow w)
{
//---Check variables are set---//
CheckAndSetWindow(w);
//---On first update of new scene---//
if (!sceneChangeUpdate)
{
foreach (IconSet iconSet in assetGrid.objectIconSets.Values)
{
foreach (Icon icon in iconSet.icons)
{
if (icon.iconSettings.postProcessingMaterials.Count > 0 && icon.iconSettings.postProcessingMaterials[0] == null)
{
if (iconSet.saveData)
{
//---Load the MatInfo if icon has been saved---//
icon.LoadMatInfo();
}
else
{
//---Reset the icon if not saved---//
ObjectPathPair obj = new ObjectPathPair(iconSet.assetObject, iconSet.assetPath);
IconSet newIconSet = assetGrid.CreateIconSet(obj);
//----------TODO----------//
//Utils.CopyIconSettings(newIcon, currentIcon, -1);
//Utils.UpdateIcon(currentIcon, this);
}
//---Update all icons---//
updateAllFlag = true;
sceneChangeUpdate = true;
}
}
}
}
//---If icon(s) selected---//
if (assetGrid.selectedIconSets.Count > 0)
{
//---Get the currently selected icon---//
currentIconIndex = Mathf.Clamp(currentIconIndex, 0, assetGrid.selectedIconSets.Count - 1);
currentIconSet = assetGrid.selectedIconSets[currentIconIndex];
currentIcon = currentIconSet.GetCurrentIcon();
//---Check if the object asscoiated with the icon has been deleted---//
if (currentIconSet.assetObject == null)
{
//---Flag as deleted and remove from selection---//
currentIconSet.deleted = true;
assetGrid.selectedIconSets.Remove(currentIconSet);
//---If other icon(s) still selected, update currentIcon - otherwise return---//
if (assetGrid.selectedIconSets.Count > 0)
{
if (currentIconIndex > assetGrid.selectedIconSets.Count - 1)
currentIconIndex = assetGrid.selectedIconSets.Count - 1;
currentIconSet = assetGrid.selectedIconSets[currentIconIndex];
currentIcon = currentIconSet.GetCurrentIcon();
}
else
return;
}
//---Create a GUI area, prevents buggy behaviour when moving left separator---//
Rect r = new Rect(window.rightSeparator.rect);
if (fullscreen)
{
r.x = 0;
r.width = window.position.width;
}
else
{
r.width = width;
}
GUILayout.BeginArea(r);
GUILayout.BeginVertical();
//---Update icons if flag set---//
if (updateFlag)
{
Utils.UpdateIcon(currentIcon, this);
updateFlag = false;
}
if (updateAllFlag)
{
assetGrid.RefreshAllIcons();
updateAllFlag = false;
}
//---Check current icon has a full render---//
Utils.CheckCurrentIconRender(this);
//---Draw the icon preview---//
DrawPreview();
GUILayout.Space(2);
//---Draw the preview zoom/resolution controls---//
DrawPreviewResAndZoom();
//---Draw the draggable separator---//
previewDraggableSeparator.Draw(100, window.position.height - 100, window);
GUILayout.Space(8);
//---Draw the icon selector---//
DrawIconSelecter();
//---Draw the tab selector---//
tab = GUILayout.Toolbar(tab, tabNames);
sepWidth = width - 50;
//---Draw the tabs---//
DrawTabs(width);
//---Check mouse inputs to rotate/zoom the preview---//
CheckMouseMovement();
//---End GUI elements---//
GUILayout.EndVertical();
GUILayout.EndArea();
}
else if (Event.current.type == EventType.Layout || Event.current.type == EventType.Repaint)
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label("No Icons Selected");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
}
public void SaveData()
{
//---Save the separator---//
previewDraggableSeparator.SaveData("RapidIconSepPosPreview");
//---Add the icons to be saved to list---//
IconSetData iconSetData = new IconSetData();
foreach (KeyValuePair<UnityEngine.Object, IconSet> iconSet in assetGrid.objectIconSets)
{
if (iconSet.Value.saveData)
iconSetData.iconSets.Add(iconSet.Value);
}
//---Save the icon data---//
Utils.SaveIconSetData(iconSetData);
//---Save the preview zoom/resolution settings and current tab---//
EditorPrefs.SetInt(PlayerSettings.productName + "RapidIconPreviewResIdx", resMultiplyerIndex);
EditorPrefs.SetInt(PlayerSettings.productName + "RapidIconPreviewZoomIdx", zoomScaleIndex);
EditorPrefs.SetInt(PlayerSettings.productName + "RapidIconEditorTab", tab);
//---Save the window position and width if fullscreen mode set---//
if (fullscreen)
{
EditorPrefs.SetFloat(PlayerSettings.productName + "RapidIconWindowPosX", window.position.xMax - (fullWidth + window.position.width));
EditorPrefs.SetFloat(PlayerSettings.productName + "RapidIconWindowPosY", window.position.y);
EditorPrefs.SetFloat(PlayerSettings.productName + "RapidIconWindowWidth", fullWidth + window.position.width);
}
else
{
EditorPrefs.SetFloat(PlayerSettings.productName + "RapidIconWindowPosX", -1);
EditorPrefs.SetFloat(PlayerSettings.productName + "RapidIconWindowPosY", -1);
EditorPrefs.SetFloat(PlayerSettings.productName + "RapidIconWindowWidth", -1);
}
}
public void LoadData()
{
//---Load icon data---//
IconSetData iconData = new IconSetData();
iconData = Utils.LoadIconSetData();
assetGrid.objectIconSets = new Dictionary<UnityEngine.Object, IconSet>();
if (iconData != null)
{
foreach (IconSet iconSet in iconData.iconSets)
{
if (iconSet.assetObject != null)
assetGrid.objectIconSets.Add(iconSet.assetObject, iconSet);
}
}
//---Load the draggable separator data---//
previewDraggableSeparator.LoadData("RapidIconSepPosPreview", 650);
//---Load the preview zoom/resolution settings---//
resMultiplyerIndex = EditorPrefs.GetInt(PlayerSettings.productName + "RapidIconPreviewResIdx", -1);
zoomScaleIndex = EditorPrefs.GetInt(PlayerSettings.productName + "RapidIconPreviewZoomIdx", -1);
if (resMultiplyerIndex == -1)
resMultiplyerIndex = 2;
if (zoomScaleIndex == -1)
zoomScaleIndex = 8;
//---Load the current tab---//
tab = EditorPrefs.GetInt(PlayerSettings.productName + "RapidIconEditorTab", 0);
}
void OnUndo()
{
//---Need to update icon after undo---//
updateFlag = true;
//---Create new material editor---//
if (materialEditor == null)
{
reorderableList.index = reorderableList.count - 1;
materialEditor = (MaterialEditor)Editor.CreateEditor((UnityEngine.Object)reorderableList.list[reorderableList.index]);
}
//---Load materials---//
if (assetGrid.visibleIconSets != null)
{
foreach (IconSet iconSet in assetGrid.visibleIconSets)
{
foreach (Icon icon in iconSet.icons)
{
if (icon.iconSettings.matInfo != null && icon.iconSettings.matInfo.Count > 0)
icon.LoadMatInfo();
}
}
}
}
void CheckAndSetWindow(RapidIconWindow w)
{
if (!window)
window = w;
}
void DrawIconSelecter()
{
GUILayout.BeginHorizontal();
//---Draw previous icon select button---//
if (GUILayout.Button("←", GUILayout.Width(50)) && currentIconIndex > 0)
currentIconIndex--;
//---Draw dropdown list of selected assets---//
int idx = 0;
string[] iconNames = new string[assetGrid.selectedIconSets.Count];
foreach (IconSet iconSet in assetGrid.selectedIconSets)
{
string name = iconSet.assetName;
for (int i = 1; i <= 128; i++)
{
if (!iconNames.Contains(name))
break;
name = iconSet.assetName + " (" + i + ")";
}
iconNames[idx++] = (name);
}
currentIconIndex = EditorGUILayout.Popup(currentIconIndex, iconNames);
//---Draw next icon select button---//
if (GUILayout.Button("→", GUILayout.Width(50)) && currentIconIndex < assetGrid.selectedIconSets.Count - 1)
currentIconIndex++;
GUILayout.EndHorizontal();
//---Sub icon selector---//
GUILayout.BeginHorizontal();
idx = 0;
string[] subIconNames = new string[currentIconSet.icons.Count];
foreach (Icon icon in currentIconSet.icons)
{
string name = icon.iconSettings.exportName;
for (int i = 1; i <= 128; i++)
{
if (!subIconNames.Contains(name))
break;
name = icon.iconSettings.exportName + " (" + i + ")";
}
subIconNames[idx++] = (name);
}
float tmp = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 75;
currentIconSet.iconIndex = EditorGUILayout.Popup("Icon Variant", currentIconSet.iconIndex, subIconNames);
EditorGUIUtility.labelWidth = tmp;
if (GUILayout.Button("+", GUILayout.Width(20)))
{
Icon newIcon = currentIconSet.AddDefaultIcon(assetGrid, new ObjectPathPair { path = currentIconSet.assetPath, UnityEngine_object = currentIconSet.assetObject });
currentIconSet.iconIndex = currentIconSet.icons.Count - 1;
newIcon.iconSettings.exportName += " (" + currentIconSet.iconIndex + ")";
currentIconSet.saveData = true;
updateFlag = true;
}
GUI.enabled = currentIconSet.icons.Count > 1;
if (GUILayout.Button("-", GUILayout.Width(20)))
{
currentIconSet.icons.Remove(currentIcon);
currentIconSet.iconIndex = currentIconSet.icons.Count - 1;
currentIconSet.saveData = true;
updateFlag = true;
}
GUI.enabled = true;
GUILayout.EndHorizontal();
}
void CheckMouseMovement()
{
//---Detect right mouse button down---//
if (Event.current.button == 1 && Event.current.type == EventType.Layout)
{
//---Check if the mouse is over the preview render---//
if (previewRect.Contains(Event.current.mousePosition))
{
//---Record the object for undo, but only once until hold released---//
if (!undoHold)
{
Undo.RecordObject(currentIcon, "Camera Rotation");
undoHold = true;
}
//---Get rotation from mouse x movement---//
Quaternion camTurnAngle = Quaternion.AngleAxis(Event.current.delta.x * 0.2f, Vector3.up);
//---Combine with rotation from mouse y movement---//
Vector3 axis = Quaternion.LookRotation(currentIcon.iconSettings.cameraTarget - currentIcon.iconSettings.cameraPosition) * Vector3.right;
camTurnAngle *= Quaternion.AngleAxis(Event.current.delta.y * 0.2f, axis);
//---Rotate the camera by moving it---//
currentIcon.iconSettings.cameraPosition = camTurnAngle * currentIcon.iconSettings.cameraPosition;
//---Flag the icon to be saved and updated---//
currentIconSet.saveData = true;
updateFlag = true;
window.Repaint();
}
}
//---Detect scroll wheel movement---//
else if (Event.current.type == EventType.ScrollWheel)
{
//---Check if the mouse is over the preview render---//
if (previewRect.Contains(Event.current.mousePosition))
{
//---Record the object for undo, but only once until hold released---//
if (!undoHold)
{
Undo.RecordObject(currentIcon, "Camera Zoom");
undoHold = true;
}
//---Zoom the camra---//
if (Mathf.Sign(Event.current.delta.y) == 1)
currentIcon.iconSettings.camerasScaleFactor /= 1.1f;
else
currentIcon.iconSettings.camerasScaleFactor *= 1.1f;
//---Flag the icon to be saved and updated---//
currentIconSet.saveData = true;
updateFlag = true;
window.Repaint();
}
}
//--If no mouse inputs then release undo hold---//
else if (undoHold)
undoHold = false;
}
void DrawPreview()
{
//---Setup scroll style if null---//
if (scrollStyle == null)
{
scrollStyle = new GUIStyle(GUI.skin.scrollView);
scrollStyle.margin.left = 1;
scrollStyle.normal.background = scrollAreaBackgroundImage;
}
//---Begin GUI elements---//
previewScrollPos = GUILayout.BeginScrollView(previewScrollPos, scrollStyle, GUILayout.Height(previewDraggableSeparator.value));
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
//---Get the render rect---//
Rect renderRect = GUILayoutUtility.GetRect(renderSize.x, renderSize.y);
renderRect.size -= new Vector2(12, 12);
renderRect.center += new Vector2(6, 6);
//---Draw the background checkerboard texture---//
GUI.DrawTextureWithTexCoords(renderRect, previewBackgroundImage, new Rect(0, 0, renderRect.width / 32, renderRect.height / 32));
//---Draw the icon render---//
GUI.DrawTexture(renderRect, currentIcon.fullRender);
//---End GUI elements---//
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.EndScrollView();
if (Event.current.type == EventType.Repaint)
{
//---Get difference in pixels between export resolution and preview window resolution---//
previewRect = GUILayoutUtility.GetLastRect();
previewAreaSize = previewRect.size;
Vector2 delta = currentIcon.iconSettings.exportResolution - previewRect.size;
//---Normalise the delta to the export resolution---//
delta.x /= currentIcon.iconSettings.exportResolution.x;
delta.y /= currentIcon.iconSettings.exportResolution.y;
//---If export resolution is bigger than preview window (x and y)---//
if (delta.x > 0 && delta.y > 0)
{
//---If normalised delta is larger in y---//
if (Mathf.Abs(delta.x) < Mathf.Abs(delta.y))
zoomFitByWidthHeight = 0; //fit by height
else
zoomFitByWidthHeight = 1; //fit by width
}
//---If export resolution is smaller than preview window (x and y)---//
else if (delta.x <= 0 && delta.y <= 0)
{
//---If normalised delta is larger in x---//
if (Mathf.Abs(delta.x) < Mathf.Abs(delta.y))
zoomFitByWidthHeight = 1; //fit by width
else
zoomFitByWidthHeight = 0; //fit by height
}
//---If export resolution is bigger than preview window (y only)---//
else if (delta.y > 0)
zoomFitByWidthHeight = 0; //fit by height
//---If export resolution is bigger than preview window (x only)---//
else if (delta.x > 0)
zoomFitByWidthHeight = 1; //fit by width
}
}
void DrawPreviewResAndZoom()
{
//---Begin GUI elements---//
EditorGUI.BeginChangeCheck();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
//---Calculate zoom scale for 'Zoom to Fit'---//
switch (zoomFitByWidthHeight)
{
case 0: //fit by height
zoomScales[8] = previewAreaSize.y / (float)(currentIcon.iconSettings.exportResolution.y);
break;
case 1: //fit by width
zoomScales[8] = previewAreaSize.x / (float)(currentIcon.iconSettings.exportResolution.x);
break;
}
//---Set this zoom scale to 1 if not icons selected---//
if (assetGrid.selectedIconSets.Count == 0)
zoomScales[8] = 1;
//---Set the string for the zoom option---//
string s = "Scale to Fit (" + (100f * (float)zoomScales[8]).ToString("f1") + "%)";
zoomScalesStrings[8] = s;
//---Draw preview resolution selection dropdown---//
GUILayout.Label("Preview Resolution", GUILayout.Width(115));
resMultiplyerIndex = EditorGUILayout.Popup(resMultiplyerIndex, resMultiplyersStrings, GUILayout.Width(70));
renderResolution = Utils.MutiplyVector2IntByFloat(currentIcon.iconSettings.exportResolution, resMultiplyers[resMultiplyerIndex]);
//---If preview resolution changed then update the icon---//
if (EditorGUI.EndChangeCheck())
{
currentIconSet = assetGrid.selectedIconSets[currentIconIndex];
currentIcon = currentIconSet.GetCurrentIcon();
if (currentIcon != null)
{
updateFlag = true;
}
}
//---Draw the preview zoom selection dropdown---//
GUILayout.Space(32);
GUILayout.Label("Zoom", GUILayout.Width(40));
zoomScaleIndex = EditorGUILayout.Popup(zoomScaleIndex, zoomScalesStrings, GUILayout.Width(150));
renderSize = Utils.MutiplyVector2IntByFloat(currentIcon.iconSettings.exportResolution, zoomScales[zoomScaleIndex]);
//---End GUI elements---//
GUILayout.EndHorizontal();
}
void DrawTabs(float width)
{
//---Begin scroll view---//
controlsScrollPos = GUILayout.BeginScrollView(controlsScrollPos, GUILayout.Height(window.position.height - previewDraggableSeparator.value - 98));
//---Draw the controls for the selected tab---//
switch (tab)
{
case 0:
Tabs.DrawObjectControls(this);
break;
case 1:
Tabs.DrawHierarchyControls(this);
break;
case 2:
Tabs.DrawCameraControls(this);
break;
case 3:
Tabs.DrawLightingControls(this);
break;
case 4:
Tabs.DrawAnimationControls(this);
break;
case 5:
Tabs.DrawPostProcessingControls(this);
break;
case 6:
Tabs.DrawExportControls(this);
break;
}
//---If any tab other than export/hierarchy tab---//
if (tab != 1 && tab != 6)
{
//---Draw button to apply settings to all selected icons---//
GUILayout.Space(12);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Copy to Other Icons", GUILayout.Width(200)))
{
CopyWindow.Init(this);
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
//---Draw button to reset this icon's settings---//
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Reset Icon(s)", GUILayout.Width(200)))
{
ResetWindow.Init(this);
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
//---End scroll view---//
GUILayout.EndScrollView();
//---Draw fullscreen toggle button---//
if (GUILayout.Button(fullscreen ? "<" : ">", GUILayout.Width(20)))
{
//---Toggle fullscreen---//
fullscreen = !fullscreen;
//---Set window position and size---//
if (fullscreen)
{
fullWidth = window.position.width - width;
oldMinWidth = window.minSize.x;
window.minSize = new Vector2(400, window.minSize.y);
window.position = new Rect(window.position.xMax - width, window.position.y, width, window.position.height);
}
else
{
window.position = new Rect(window.position.xMax - (fullWidth + window.position.width), window.position.y, fullWidth + window.position.width, window.position.height);
window.minSize = new Vector2(oldMinWidth, window.minSize.y);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 18af1c8019c04c147852c58dd6f9894a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,209 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace RapidIcon_1_7_2
{
public class ReorderableListCallbacks
{
private IconEditor iconEditor;
public ReorderableListCallbacks(IconEditor iconEditor)
{
this.iconEditor = iconEditor;
}
private ReorderableListCallbacks()
{ }
public void DrawHeader(Rect rect)
{
//---Title label---//
EditorGUI.LabelField(rect, "Shaders");
//---Fullscreen check---//
float sw2 = iconEditor.sepWidth;
if (iconEditor.fullscreen)
sw2 += iconEditor.fullWidth;
rect.width = 100;
rect.x = sw2 - 154;
//---Draw Save preset button---//
if (GUI.Button(rect, "Save Preset"))
{
//---Get save path---//
string savePath = EditorUtility.SaveFilePanel("Save Preset", iconEditor.lastPresetPath == "" ? Application.dataPath : iconEditor.lastPresetPath, "PostProcessingPreset", "rippp");
//---If savepath is not empty then save preset---//
if (savePath != "")
{
//---Convert data to JSON string---//
iconEditor.currentIcon.SaveMatInfo();
string data = JsonUtility.ToJson(iconEditor.currentIcon);
//int pos = data.IndexOf("\"matInfo\":");
//data = "{\"iconSettings\":{" + data.Substring(pos);
//---Save bytes---//
File.WriteAllBytes(savePath, System.Text.Encoding.ASCII.GetBytes(data));
//---Store path as last preset path---//
iconEditor.lastPresetPath = savePath;
}
}
//---Draw Load Preset button---//
rect.x += 102;
if (GUI.Button(rect, "Load Preset"))
{
//---Get open path---//
string openPath = EditorUtility.OpenFilePanel("Open Preset", iconEditor.lastPresetPath == "" ? Application.dataPath : iconEditor.lastPresetPath, "rippp");
//---If open path is not empty then load the preset---//
if (openPath != "")
{
//---Read bytes and get JSON string---//
Byte[] bytes = File.ReadAllBytes(openPath);
iconEditor.lastPresetPath = openPath;
string data = System.Text.Encoding.ASCII.GetString(bytes);
//---Convert to icon from JSON---//
Icon tmp = JsonUtility.FromJson<Icon>(data);
//---Load mat info---//
iconEditor.currentIconSet.saveData = true;
iconEditor.currentIcon.iconSettings.matInfo = new List<Icon.MaterialInfo>(tmp.iconSettings.matInfo);
iconEditor.currentIcon.LoadMatInfo();
//---Update icon---//
Utils.UpdateIcon(iconEditor.currentIcon, iconEditor);
//---Update reorderable list---//
iconEditor.reorderableList.list = iconEditor.currentIcon.iconSettings.postProcessingMaterials;
iconEditor.reorderableList.index = 0;
//---Create new material editor---//
Editor.DestroyImmediate(iconEditor.materialEditor);
iconEditor.materialEditor = (MaterialEditor)Editor.CreateEditor((UnityEngine.Object)iconEditor.reorderableList.list[iconEditor.reorderableList.index]);
}
}
}
public void DrawListItems(Rect rect, int index, bool isActive, bool isFocused)
{
//---If index within bounds of the list---//
if (index >= 0 && index < iconEditor.reorderableList.list.Count)
{
//---Check and fix editor---//
if (iconEditor.materialEditor == null)
{
Editor.DestroyImmediate(iconEditor.materialEditor);
iconEditor.materialEditor = (MaterialEditor)Editor.CreateEditor((UnityEngine.Object)iconEditor.reorderableList.list[iconEditor.reorderableList.index]);
}
//---Check and fix materials---//
if (iconEditor.currentIcon.iconSettings.postProcessingMaterials[index] == null)
{
iconEditor.currentIcon.LoadMatInfo();
}
//---Check for fullscreen---//
float sw2 = iconEditor.sepWidth;
if (iconEditor.fullscreen)
sw2 += iconEditor.fullWidth;
//---Get widths of elements in list item - layer toggle, layer name, layer shader---//
float[] widths = new float[] { 16, (sw2 - 150) / 2, (sw2 + 100) / 2 };
//---Prevent error, close window if material toggles is null - reopening window should fix---//
if (iconEditor.currentIcon.iconSettings.materialToggles == null)
{
iconEditor.window.Close();
return;
}
//---Draw text field for layer name, this is draw first before the change check as changing the layer name doesn't need to update the icon---//
GUI.enabled = iconEditor.currentIcon.iconSettings.materialToggles[iconEditor.currentIcon.iconSettings.postProcessingMaterials[index]];
iconEditor.currentIcon.iconSettings.materialDisplayNames[iconEditor.currentIcon.iconSettings.postProcessingMaterials[index]] = EditorGUI.TextField(new Rect(rect.x + widths[0] + 4, rect.y + 3, widths[1], EditorGUIUtility.singleLineHeight), iconEditor.currentIcon.iconSettings.materialDisplayNames[iconEditor.currentIcon.iconSettings.postProcessingMaterials[index]]);
//---Draw the layer toggle---//
GUI.enabled = true;
EditorGUI.BeginChangeCheck();
iconEditor.currentIcon.iconSettings.materialToggles[iconEditor.currentIcon.iconSettings.postProcessingMaterials[index]] = EditorGUI.Toggle(new Rect(rect.x, rect.y + 3, widths[0], EditorGUIUtility.singleLineHeight), iconEditor.currentIcon.iconSettings.materialToggles[iconEditor.currentIcon.iconSettings.postProcessingMaterials[index]]);
//---Draw the shader selection field---//
GUI.enabled = iconEditor.currentIcon.iconSettings.materialToggles[iconEditor.currentIcon.iconSettings.postProcessingMaterials[index]];
iconEditor.currentIcon.iconSettings.postProcessingMaterials[index].shader = (Shader)EditorGUI.ObjectField(new Rect(rect.x + widths[0] + widths[1] + 8, rect.y + 3, widths[2], EditorGUIUtility.singleLineHeight), iconEditor.currentIcon.iconSettings.postProcessingMaterials[index].shader, typeof(Shader), true);
GUI.enabled = true;
//---If layer toggles/shaders changed then update the icon---//
if (EditorGUI.EndChangeCheck())
{
iconEditor.updateFlag = true;
Editor.DestroyImmediate(iconEditor.materialEditor);
iconEditor.materialEditor = (MaterialEditor)Editor.CreateEditor((UnityEngine.Object)iconEditor.reorderableList.list[iconEditor.reorderableList.index]);
}
}
}
public void SelectShader(ReorderableList l)
{
//---If selected shader changes, create a new material editor---//
Editor.DestroyImmediate(iconEditor.materialEditor);
iconEditor.materialEditor = (MaterialEditor)Editor.CreateEditor((UnityEngine.Object)iconEditor.reorderableList.list[iconEditor.reorderableList.index]);
}
public void AddShader(ReorderableList l)
{
//---Record object for undo---//
Undo.RecordObject(iconEditor.currentIcon, "Add New Shader");
//---Create new material with default shader---//
Material m = new Material(Shader.Find("RapidIcon/ObjectRender"));
//---Add the new material to the list and select it---//
l.list.Add(m);
l.index = l.list.Count - 1;
//---Add the material display name and toggle to the current icon---//
iconEditor.currentIcon.iconSettings.materialDisplayNames.Add(m, "Shader " + l.list.Count);
iconEditor.currentIcon.iconSettings.materialToggles.Add(m, true);
//---Create a new material editor---//
Editor.DestroyImmediate(iconEditor.materialEditor);
iconEditor.materialEditor = (MaterialEditor)Editor.CreateEditor((UnityEngine.Object)iconEditor.reorderableList.list[iconEditor.reorderableList.index]);
//---Update and save the current icon---//
iconEditor.currentIconSet.saveData = true;
iconEditor.updateFlag = true;
}
public void RemoveShader(ReorderableList l)
{
//---Record object for undo---//
Undo.RecordObject(iconEditor.currentIcon, "Remove Shader");
//---Remove the material from the list---//
l.list.Remove(l.list[l.index]);
l.index = (int)Mathf.Clamp(l.index, 0, l.list.Count - 1);
//---Create a new material editor, if any materials left in the list---//
Editor.DestroyImmediate(iconEditor.materialEditor);
if (l.list.Count > 0)
iconEditor.materialEditor = (MaterialEditor)Editor.CreateEditor((UnityEngine.Object)iconEditor.reorderableList.list[iconEditor.reorderableList.index]);
//---Update and save the current icon---//
iconEditor.currentIconSet.saveData = true;
iconEditor.updateFlag = true;
}
public void ShadersReorded(ReorderableList l)
{
//---Update and save the current icon if the list is reordered---//
iconEditor.currentIconSet.saveData = true;
iconEditor.updateFlag = true;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1395b5f87121a87409bf19e220e7d467
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,660 @@
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace RapidIcon_1_7_2
{
public static class Tabs
{
public static void DrawObjectControls(IconEditor iconEditor)
{
//---Begin change check---//
EditorGUI.BeginChangeCheck();
//---Draw position field---//
GUI.enabled = !iconEditor.currentIcon.iconSettings.autoPosition;
Vector3 tmpObjPos = EditorGUILayout.Vector3Field("Position", iconEditor.currentIcon.iconSettings.objectPosition);
Rect posR = GUILayoutUtility.GetLastRect();
posR.x += 50;
posR.height = 18;
posR.width = 50;
GUI.enabled = true;
//---Draw auto button for position---//
bool tmpAutoPos = GUI.Toggle(posR, iconEditor.currentIcon.iconSettings.autoPosition, "Auto", GUI.skin.button);
//---Draw object rotation and scale fields---//
Vector3 tmpObjRot = EditorGUILayout.Vector3Field("Rotation", iconEditor.currentIcon.iconSettings.objectRotation);
Vector3 tmpObjScale = EditorGUILayout.Vector3Field("Scale", iconEditor.currentIcon.iconSettings.objectScale);
//---Draw link scale toggle---//
Rect r = GUILayoutUtility.GetLastRect();
r.position += new Vector2(40, 0);
if (GUI.Button(r, iconEditor.linkScale ? iconEditor.scaleLinkOnImage : iconEditor.scaleLinkOffImage, GUIStyle.none))
{
iconEditor.linkScale = !iconEditor.linkScale;
}
//---If any fields changed---//
if (EditorGUI.EndChangeCheck())
{
//---Record object for undo---//
Undo.RecordObject(iconEditor.currentIcon, "Edit Icon Object");
//---Apply position and rotation---//
iconEditor.currentIcon.iconSettings.objectPosition = tmpObjPos;
iconEditor.currentIcon.iconSettings.objectRotation = tmpObjRot;
if (tmpAutoPos && !iconEditor.currentIcon.iconSettings.autoPosition)
{
iconEditor.currentIcon.iconSettings.objectPosition = Utils.GetObjectAutoOffset(iconEditor.currentIcon, Utils.GetObjectBounds(iconEditor.currentIconSet));
}
iconEditor.currentIcon.iconSettings.autoPosition = tmpAutoPos;
//---If link scale disabled, apply scale---//
if (!iconEditor.linkScale)
{
iconEditor.currentIcon.iconSettings.objectScale = tmpObjScale;
}
else
{
//---If link scale enabled, detect which axis changed and apply to all axes---//
if (tmpObjScale.x != iconEditor.currentIcon.iconSettings.objectScale.x)
{
iconEditor.currentIcon.iconSettings.objectScale = tmpObjScale.x * Vector3.one;
}
else if (tmpObjScale.y != iconEditor.currentIcon.iconSettings.objectScale.y)
{
iconEditor.currentIcon.iconSettings.objectScale = tmpObjScale.y * Vector3.one;
}
else if (tmpObjScale.z != iconEditor.currentIcon.iconSettings.objectScale.z)
{
iconEditor.currentIcon.iconSettings.objectScale = tmpObjScale.z * Vector3.one;
}
}
//---Save and update icon---//
iconEditor.currentIconSet.saveData = true;
iconEditor.updateFlag = true;
}
}
public static void DrawHierarchyControls(IconEditor iconEditor)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Object Hierarchy");
if (GUILayout.Button("Enable All"))
{
List<string> keys = iconEditor.currentIcon.iconSettings.subObjectEnables.Keys.ToList();
foreach (string s in keys)
iconEditor.currentIcon.iconSettings.subObjectEnables[s] = true;
iconEditor.updateFlag = true;
iconEditor.currentIconSet.saveData = true;
}
if (GUILayout.Button("Disable All"))
{
List<string> keys = iconEditor.currentIcon.iconSettings.subObjectEnables.Keys.ToList();
foreach (string s in keys)
iconEditor.currentIcon.iconSettings.subObjectEnables[s] = false;
iconEditor.updateFlag = true;
iconEditor.currentIconSet.saveData = true;
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GameObject obj = (GameObject)iconEditor.currentIconSet.assetObject;
Rect r = GUILayoutUtility.GetRect(new GUIContent(obj.name), GUI.skin.label);
bool active = iconEditor.currentIcon.iconSettings.subObjectEnables["/0"];
EditorGUI.BeginChangeCheck();
bool tmpToggle = GUI.Toggle(r, active, obj.name);
if (EditorGUI.EndChangeCheck())
{
iconEditor.currentIcon.iconSettings.subObjectEnables["/0"] = tmpToggle;
iconEditor.updateFlag = true;
iconEditor.currentIconSet.saveData = true;
}
DrawChildObjects(iconEditor, obj, 0, 0, "/0", !tmpToggle);
}
private static void DrawChildObjects(IconEditor iconEditor, GameObject obj, int depth, int childIdx, string path, bool parentDisabled)
{
for (int i = 0; i < obj.transform.childCount; i++)
{
GameObject child = obj.transform.GetChild(i).gameObject;
Rect r = GUILayoutUtility.GetRect(new GUIContent(child.name), GUI.skin.label);
r.x += (depth + 1) * 16;
string newPath = path + "/" + i;
bool active = iconEditor.currentIcon.iconSettings.subObjectEnables[newPath];
if (parentDisabled)
{
active = false;
GUI.enabled = false;
}
EditorGUI.BeginChangeCheck();
bool tmpToggle = GUI.Toggle(r, active, child.name);
if (EditorGUI.EndChangeCheck())
{
iconEditor.currentIcon.iconSettings.subObjectEnables[newPath] = tmpToggle;
iconEditor.updateFlag = true;
iconEditor.currentIconSet.saveData = true;
}
GUI.enabled = true;
DrawChildObjects(iconEditor, child, depth + 1, i, newPath, !tmpToggle);
}
}
public static void DrawCameraControls(IconEditor iconEditor)
{
//---Begin change check---//
EditorGUI.BeginChangeCheck();
//---Draw camera position field---//
Vector3 tmpCamPos = EditorGUILayout.Vector3Field("Position", iconEditor.currentIcon.iconSettings.cameraPosition);
//---Draw camera point of focus field---//
GUILayout.Space(8);
float tmpWdith = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 80;
Vector3 tmpCamTgt = iconEditor.currentIcon.iconSettings.cameraTarget;
tmpCamTgt = EditorGUILayout.Vector3Field("Point of Focus", iconEditor.currentIcon.iconSettings.cameraTarget);
//---Draw camera projection mode field---//
GUILayout.Space(8);
string[] listOptions = { "Perspective", "Orthographic" };
EditorGUIUtility.labelWidth = 80;
int tmpOrtho = EditorGUILayout.Popup("Projection", iconEditor.currentIcon.iconSettings.cameraOrtho ? 1 : 0, listOptions);
//---Temporary variables for undo---//
float tmpCamSize = iconEditor.currentIcon.iconSettings.cameraSize;
float tmpScaleFactor = iconEditor.currentIcon.iconSettings.camerasScaleFactor;
float tmpCamFov = iconEditor.currentIcon.iconSettings.cameraFov;
bool tmpCamAuto = iconEditor.currentIcon.iconSettings.autoScale;
//---If projection mode is ortho---//
if (tmpOrtho == 1)
{
GUILayout.BeginHorizontal();
GUI.enabled = !iconEditor.currentIcon.iconSettings.autoScale;
//---Draw camera size field---//
tmpCamSize = EditorGUILayout.FloatField("Size", iconEditor.currentIcon.iconSettings.cameraSize);
GUI.enabled = true;
//---Draw auto button---//
GUIStyle s = new GUIStyle(GUI.skin.button);
s.fixedWidth = 50;
tmpCamAuto = GUILayout.Toggle(iconEditor.currentIcon.iconSettings.autoScale, "Auto", s);
GUILayout.EndHorizontal();
}
else
{
//---Draw FOV field---//
tmpCamFov = EditorGUILayout.FloatField("Field of View", iconEditor.currentIcon.iconSettings.cameraFov);
}
//---Draw scale factor field---//
tmpScaleFactor = EditorGUILayout.FloatField("Scale Factor", iconEditor.currentIcon.iconSettings.camerasScaleFactor);
//---If perspective projection mode---//
EditorGUIUtility.labelWidth = tmpWdith;
//---If any field changed---//
if (EditorGUI.EndChangeCheck())
{
//---Record object for undo---//
Undo.RecordObject(iconEditor.currentIcon, "Edit Icon Camera");
//---Apply camera position, point of focus, and projection mode---//
iconEditor.currentIcon.iconSettings.cameraPosition = tmpCamPos;
iconEditor.currentIcon.iconSettings.cameraTarget = tmpCamTgt;
iconEditor.currentIcon.iconSettings.cameraOrtho = tmpOrtho == 1 ? true : false;
//---Apply size, fov, and scale factor---//
iconEditor.currentIcon.iconSettings.cameraSize = tmpCamSize;
iconEditor.currentIcon.iconSettings.cameraFov = tmpCamFov;
iconEditor.currentIcon.iconSettings.camerasScaleFactor = tmpScaleFactor;
//---Auto scale---//
if (tmpCamAuto && !iconEditor.currentIcon.iconSettings.autoScale)
{
iconEditor.currentIcon.iconSettings.cameraSize = Utils.GetCameraAuto(iconEditor.currentIcon, Utils.GetObjectBounds(iconEditor.currentIconSet));
}
iconEditor.currentIcon.iconSettings.autoScale = tmpCamAuto;
//---Save and update icon---//
iconEditor.currentIconSet.saveData = true;
iconEditor.updateFlag = true;
}
}
private static void ApplyScaleFactor(Icon icon, IconEditor iconEditor)
{
//---If not current icon then apply the scale factor---//
if (icon != iconEditor.currentIcon)
{
icon.iconSettings.camerasScaleFactor = iconEditor.currentIcon.iconSettings.camerasScaleFactor;
icon.iconSettings.perspLastScale = iconEditor.currentIcon.iconSettings.perspLastScale;
icon.parentIconSet.saveData = true;
Utils.UpdateIcon(icon, iconEditor);
}
}
public static void DrawLightingControls(IconEditor iconEditor)
{
//---Begin change check---//
EditorGUI.BeginChangeCheck();
//---Draw ambient light field---///
Color tmpAmbLight = EditorGUILayout.ColorField("Ambient Light Colour", iconEditor.currentIcon.iconSettings.ambientLightColour);
//---Draw diretional light fields---//
EditorGUILayout.Space(4);
EditorGUILayout.LabelField("Directional Light");
Color tmpLightColour = EditorGUILayout.ColorField("Colour", iconEditor.currentIcon.iconSettings.lightColour);
Vector3 tmpLightDir = EditorGUILayout.Vector3Field("Rotation", iconEditor.currentIcon.iconSettings.lightDir);
float tmpLightIntensity = EditorGUILayout.FloatField("Intensity", iconEditor.currentIcon.iconSettings.lightIntensity);
//---If any fields have changed---//
if (EditorGUI.EndChangeCheck())
{
//---Record object for undo---//
Undo.RecordObject(iconEditor.currentIcon, "Edit Icon Lighting");
//---Apply settings---//
iconEditor.currentIcon.iconSettings.ambientLightColour = tmpAmbLight;
iconEditor.currentIcon.iconSettings.lightColour = tmpLightColour;
iconEditor.currentIcon.iconSettings.lightDir = tmpLightDir;
iconEditor.currentIcon.iconSettings.lightIntensity = tmpLightIntensity;
//---Update and save icon---//
iconEditor.currentIconSet.saveData = true;
iconEditor.updateFlag = true;
}
}
public static void DrawAnimationControls(IconEditor iconEditor)
{
//---Begin change check---//
EditorGUI.BeginChangeCheck();
//---Draw animation clip field---//
AnimationClip c = (AnimationClip)EditorGUILayout.ObjectField("Animation Clip", iconEditor.currentIcon.iconSettings.animationClip, typeof(AnimationClip), false);
//---Draw animation offset field---//
Rect r = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
float offset = EditorGUI.Slider(r, "Animation Offset", iconEditor.currentIcon.iconSettings.animationOffset, 0, 1);
//---If any fields have changed---//
if (EditorGUI.EndChangeCheck())
{
//---Record object for undo---//
Undo.RecordObject(iconEditor.currentIcon, "Edit Icon Animations");
//---Apply settings---//
iconEditor.currentIcon.iconSettings.animationClip = c;
iconEditor.currentIcon.iconSettings.animationOffset = offset;
//---Update and save icon---//
iconEditor.updateFlag = true;
iconEditor.currentIconSet.saveData = true;
}
}
public static void DrawPostProcessingControls(IconEditor iconEditor)
{
//---Begin change check---//
EditorGUI.BeginChangeCheck();
//---Draw filter mode field---//
FilterMode tmpFilterMode = (FilterMode)EditorGUILayout.EnumPopup("Filter Mode", iconEditor.currentIcon.iconSettings.filterMode);
//---If filter mode changed---//
if (EditorGUI.EndChangeCheck())
{
//---Record object for undo---//
//---Apply sttings, update icon---//
Undo.RecordObject(iconEditor.currentIcon, "Change Filter Mode");
iconEditor.currentIcon.iconSettings.filterMode = tmpFilterMode;
iconEditor.updateFlag = true;
}
//---Draw reorderable list---//
iconEditor.reorderableList.list = iconEditor.currentIcon.iconSettings.postProcessingMaterials;
iconEditor.reorderableList.index = (int)Mathf.Clamp(iconEditor.reorderableList.index, 0, iconEditor.reorderableList.list.Count - 1);
GUILayout.Space(2);
iconEditor.reorderableList.DoLayoutList();
//---Begin change check---//
EditorGUI.BeginChangeCheck();
if (iconEditor.reorderableList.list.Count > 0)
{
//---Draw shader settings label---//
string shaderName = iconEditor.currentIcon.iconSettings.postProcessingMaterials[iconEditor.reorderableList.index].shader.name;
GUILayout.Label("Shader Settings (" + shaderName + ")");
GUILayout.BeginVertical(GUI.skin.box);
//---If not the default render shader---//
if (shaderName != "RapidIcon/ObjectRender")
{
//---Get the material properties---//
UnityEngine.Object[] obj = new UnityEngine.Object[1];
obj[0] = (UnityEngine.Object)iconEditor.reorderableList.list[iconEditor.reorderableList.index];
MaterialProperty[] props = MaterialEditor.GetMaterialProperties(obj);
//---If the shader doesn't have a custom GUI---//
if (iconEditor.materialEditor.customShaderGUI == null)
{
//---Draw the properties fields---//
foreach (MaterialProperty prop in props)
{
if (iconEditor.materialEditor == null)
{
Debug.LogWarning("null editor!!!");
continue;
}
if (prop.name != "_MainTex" && prop.flags != MaterialProperty.PropFlags.HideInInspector)
{
iconEditor.materialEditor.ShaderProperty(prop, prop.displayName);
}
}
}
else
//---If the shader does have a custom GUI---//
{
//---Get list of all properties---//
List<MaterialProperty> list = new List<MaterialProperty>(props);
//---Remove the property from list if it is _MainTex---//
foreach (MaterialProperty prop in list)
{
if (prop.name == "_MainTex")
{
list.Remove(prop);
break;
}
}
//---Draw the custom GUI---//
props = list.ToArray();
iconEditor.materialEditor.customShaderGUI.OnGUI(iconEditor.materialEditor, props);
}
}
//---If the default render shader---//
else
{
//---Begine change check---//
EditorGUI.BeginChangeCheck();
//---Draw fix alpha edges toggle---//
IconSettings.FixEdgesModes tmpFixEdges = (IconSettings.FixEdgesModes)EditorGUILayout.EnumPopup("Edge Fix Mode", iconEditor.currentIcon.iconSettings.fixEdgesMode);
//---If toggle changed---//
if (EditorGUI.EndChangeCheck())
{
//---Record object for undo and apply---//
Undo.RecordObject(iconEditor.currentIcon, "Toggle Icon Premultiplied Alpha");
iconEditor.currentIcon.iconSettings.fixEdgesMode = tmpFixEdges;
//---Update and save icon---//
iconEditor.currentIconSet.saveData = true;
iconEditor.updateFlag = true;
}
}
GUILayout.EndVertical();
}
//---If any fields changed---//
if (EditorGUI.EndChangeCheck())
{
//---Save material info and update icon---//
iconEditor.currentIcon.SaveMatInfo();
iconEditor.updateFlag = true;
}
}
public static void DrawExportControls(IconEditor iconEditor)
{
//---Begin change check---//
EditorGUI.BeginChangeCheck();
//---Draw export resolution field, limit to 8x8 - 2048x2048---//
Vector2Int tmpExportRes = EditorGUILayout.Vector2IntField("Export Resolution", iconEditor.currentIcon.iconSettings.exportResolution);
tmpExportRes.x = (int)Mathf.Clamp(tmpExportRes.x, 8, 2048);
tmpExportRes.y = (int)Mathf.Clamp(tmpExportRes.y, 8, 2048);
//---If resolution fields change---//
if (EditorGUI.EndChangeCheck())
{
//---Record object for undo---//
Undo.RecordObject(iconEditor.currentIcon, "Edit Icon Export Resolution");
//---Apply settings---//
iconEditor.currentIcon.iconSettings.exportResolution.x = (int)Mathf.Clamp(tmpExportRes.x, 8, 2048);
iconEditor.currentIcon.iconSettings.exportResolution.y = (int)Mathf.Clamp(tmpExportRes.y, 8, 2048);
//---Save and update icon---//
iconEditor.currentIconSet.saveData = true;
iconEditor.updateFlag = true;
}
//---Begin new change check---//
EditorGUI.BeginChangeCheck();
GUILayout.Space(2);
GUILayout.BeginHorizontal();
//---Add forward slash to end of export path if missing---//
if (iconEditor.currentIcon.iconSettings.exportFolderPath[iconEditor.currentIcon.iconSettings.exportFolderPath.Length - 1] != '/')
iconEditor.currentIcon.iconSettings.exportFolderPath += "/";
//---Draw export folder field---//
float tmpWdith = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 80;
iconEditor.currentIcon.iconSettings.exportFolderPath = EditorGUILayout.TextField("Export Folder", iconEditor.currentIcon.iconSettings.exportFolderPath);
//---If export path is blank, change it to default Export folder---//
string tmpFolder = iconEditor.currentIcon.iconSettings.exportFolderPath;
if (tmpFolder == "")
{
string[] split = AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("RapidIconWindow")[0]).Split('/');
string rapidIconRootFolder = "";
for (int i = 0; i < split.Length - 3; i++)
rapidIconRootFolder += split[i] + "/";
iconEditor.currentIcon.iconSettings.exportFolderPath = rapidIconRootFolder + "Exports/";
}
//---Draw button to open file explorer to select export folder---//
EditorGUIUtility.labelWidth = tmpWdith;
if (GUILayout.Button("Browse", GUILayout.Width(100)))
{
string folder = EditorUtility.OpenFolderPanel("Export Folder", iconEditor.currentIcon.iconSettings.exportFolderPath, "");
if (folder != "")
{
string dataPath = Application.dataPath;
dataPath = dataPath.Substring(0, dataPath.LastIndexOf('/') + 1);
folder = folder.Replace(dataPath, "");
iconEditor.currentIcon.iconSettings.exportFolderPath = folder;
}
}
GUILayout.EndHorizontal();
//---Draw export path prefix/suffix fields---//
tmpWdith = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 80;
string exportPrefix = EditorGUILayout.TextField("Export Prefix", iconEditor.currentIcon.iconSettings.exportPrefix);
string exportSuffix = EditorGUILayout.TextField("Export Suffix", iconEditor.currentIcon.iconSettings.exportSuffix);
//---If any fields changes---//
if (EditorGUI.EndChangeCheck())
{
//---Record object for undo---//
Undo.RecordObject(iconEditor.currentIcon, "Edit Icon Export Path");
//---Apply settings---//
iconEditor.currentIcon.iconSettings.exportResolution = tmpExportRes;
iconEditor.currentIcon.iconSettings.exportPrefix = exportPrefix;
iconEditor.currentIcon.iconSettings.exportSuffix = exportSuffix;
iconEditor.currentIconSet.saveData = true;
}
//---Add button apply to all selected icons---//
if (GUILayout.Button("Copy to Other Icons"))
CopyWindow.Init(iconEditor);
//---Draw a separator---//
GUILayout.Space(12);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
Rect r = GUILayoutUtility.GetRect(iconEditor.sepWidth, 1);
if (iconEditor.separatorTex == null)
{
if (EditorGUIUtility.isProSkin)
iconEditor.separatorTex = Utils.CreateColourTexture(2, 2, new Color32(31, 31, 31, 255));
else
iconEditor.separatorTex = Utils.CreateColourTexture(2, 2, new Color32(153, 153, 153, 255));
}
GUI.DrawTexture(r, iconEditor.separatorTex);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Space(12);
//---Begin change check---//
EditorGUI.BeginChangeCheck();
//---Draw export name field---//
string exportName = EditorGUILayout.TextField("Export Name", iconEditor.currentIcon.iconSettings.exportName);
//---Draw label showing full name with prefix/suffix---//
EditorGUIUtility.labelWidth = tmpWdith;
GUILayout.Label("Full Export Name: " + iconEditor.currentIcon.iconSettings.exportPrefix + iconEditor.currentIcon.iconSettings.exportName + iconEditor.currentIcon.iconSettings.exportSuffix + ".png");
//---If fields changesd, and export name is valid---//
if (EditorGUI.EndChangeCheck())
{
if (exportName.Length > 0)
{
//---Record object for undo---//
Undo.RecordObject(iconEditor.currentIcon, "Edit Icon Export Name");
//---Apply and save---//
iconEditor.currentIcon.iconSettings.exportName = exportName;
iconEditor.currentIconSet.saveData = true;
}
}
//---Draw button to export icon---//
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Export Icon", GUILayout.Width(160)))
{
int result = EditorUtility.DisplayDialogComplex("Export Icon", "Export All Variants?", "All Variants", "Cancel", "Currently Selected Variant");
//---Export icon---//
if (result != 1)
{
if (result == 2)
{
Utils.ExportIcon(iconEditor.currentIcon, false, iconEditor);
Utils.FinishExportIcon(iconEditor.currentIcon);
}
else
{
//---Start asset editing---//
AssetDatabase.StartAssetEditing();
foreach (Icon icon in iconEditor.currentIconSet.icons)
{
Utils.ExportIcon(icon, iconEditor.currentIconSet.icons.Count > 1 ? true : false, iconEditor);
}
AssetDatabase.StopAssetEditing();
Utils.FinishExportIconSet(iconEditor.currentIconSet);
}
//---Reset replaceAll---//
iconEditor.replaceAll = false;
}
}
//---Draw button to export all selected icons---//
if (GUILayout.Button("Export Selected Icons", GUILayout.Width(160)))
{
int result = EditorUtility.DisplayDialogComplex("Export Icon", "Export All Variants?", "All Variants", "Cancel", "Currently Selected Variant");
if (result != 1)
{
//---Loop through all selected icons---//
int index = 1;
List<string> exportPaths = new List<string>();
foreach (IconSet iconSet in iconEditor.assetGrid.selectedIconSets)
{
if (result == 2)
{
Icon icon = iconSet.GetCurrentIcon();
//--Show progress bar---//
EditorUtility.DisplayProgressBar("Exporting Icons (" + index + "/" + iconEditor.assetGrid.selectedIconSets.Count + ")", iconSet.assetPath, ((float)index++ / iconEditor.assetGrid.selectedIconSets.Count));
//---Export icon---//
Utils.ExportIcon(icon, iconEditor.assetGrid.selectedIconSets.Count > 1 ? true : false, iconEditor);
//---Stop asset editing and finish export---//
Utils.FinishExportIcon(icon);
}
else
{
//--Show progress bar---//
EditorUtility.DisplayProgressBar("Exporting Icons (" + index + "/" + iconEditor.assetGrid.selectedIconSets.Count + ")", iconSet.assetPath, ((float)index++ / iconEditor.assetGrid.selectedIconSets.Count));
//---Start asset editing---//
AssetDatabase.StartAssetEditing();
foreach (Icon icon in iconSet.icons)
{
//---Export icon---//
Utils.ExportIcon(icon, iconEditor.assetGrid.selectedIconSets.Count > 1 || iconSet.icons.Count > 1 ? true : false, iconEditor);
}
//---Stop asset editing and finish export---//
AssetDatabase.StopAssetEditing();
Utils.FinishExportIconSet(iconSet);
}
}
//---Clear progress bar---//
EditorUtility.ClearProgressBar();
//---Reset replaceAll---//
iconEditor.replaceAll = false;
}
}
GUILayout.EndHorizontal();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43277a6de4118d145a17df3c98e17ffd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b1f03a313234425499c9d0575ea0d1f8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,287 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace RapidIcon_1_7_2
{
[Serializable]
public class Icon : ScriptableObject
{
//---MatProperty Definition---//
[Serializable]
public struct MatProperty<T>
{
public string name;
public T value;
public MatProperty(string n, T v)
{
name = n;
value = v;
}
}
//---MaterialInfo Definition---//
[Serializable]
public struct MaterialInfo
{
public string shaderName;
public string displayName;
public bool toggle;
public List<MatProperty<int>> intProperties;
public List<MatProperty<float>> floatProperties;
public List<MatProperty<float>> rangeProperties;
public List<MatProperty<Color>> colourProperties;
public List<MatProperty<Vector4>> vectorProperties;
public List<MatProperty<string>> textureProperties;
//---Constructor---//
public MaterialInfo(string n)
{
shaderName = n;
displayName = n;
toggle = true;
intProperties = new List<MatProperty<int>>();
floatProperties = new List<MatProperty<float>>();
rangeProperties = new List<MatProperty<float>>();
colourProperties = new List<MatProperty<Color>>();
vectorProperties = new List<MatProperty<Vector4>>();
textureProperties = new List<MatProperty<string>>();
}
}
//---Variable Definitions---//
//Icon Set
[NonSerialized] public IconSet parentIconSet;
//Icon Settings
public IconSettings iconSettings;
//Renders
public Texture2D previewRender;
public Texture2D fullRender;
public void Init(Shader objRenderShader, string rapidIconRootFolder, GameObject rootObject)
{
iconSettings = new IconSettings(objRenderShader, rapidIconRootFolder, rootObject);
}
public void UpdateIcon(Vector2Int fullRenderSize)
{
fullRender = Utils.RenderIcon(this, fullRenderSize.x, fullRenderSize.y);
}
public void UpdateIcon(Vector2Int fullRenderSize, Vector2Int previewSize)
{
previewRender = Utils.RenderIcon(this, previewSize.x, previewSize.y);
fullRender = Utils.RenderIcon(this, fullRenderSize.x, fullRenderSize.y);
}
public void CompleteLoadData(IconSet iconSet, bool loadFixEdgesMode)
{
//---Set parent icon set---//
parentIconSet = iconSet;
//---Load animation from path---//
if (iconSettings.animationPath != string.Empty)
{
iconSettings.animationClip = (AnimationClip)AssetDatabase.LoadAssetAtPath(iconSettings.animationPath, typeof(AnimationClip));
}
//---Load the post-processing material info---//
LoadMatInfo(loadFixEdgesMode);
//---Load the sub object enables dictionary---//
iconSettings.subObjectEnables = new Dictionary<string, bool>();
int idx = 0;
foreach (string s in iconSettings.soeStrings)
{
iconSettings.subObjectEnables.Add(s, iconSettings.soeBools[idx++]);
}
}
public void PrepareForSaveData()
{
//---Get path of animation---//
iconSettings.animationPath = AssetDatabase.GetAssetPath(iconSettings.animationClip);
//---Clear the renders and assset object---//
previewRender = fullRender = null;
//---Save the post-processing material info---//
SaveMatInfo();
//---Clear the post-processing list/dictionaries---//
iconSettings.postProcessingMaterials.Clear();
iconSettings.materialDisplayNames.Clear();
iconSettings.materialToggles.Clear();
//---Save the sub object enables dictionary---//
iconSettings.soeStrings = iconSettings.subObjectEnables.Keys.ToList();
iconSettings.soeBools = iconSettings.subObjectEnables.Values.ToList();
}
public void LoadMatInfo(bool loadFixEdgesMode = true)
{
//---Initialise post-processing list/dictionaries---//
iconSettings.postProcessingMaterials = new List<Material>();
iconSettings.materialDisplayNames = new Dictionary<Material, string>();
iconSettings.materialToggles = new Dictionary<Material, bool>();
if (iconSettings.matInfo != null && iconSettings.matInfo.Count > 0)
{
//---For each material, load it's properties---//
foreach (MaterialInfo mi in iconSettings.matInfo)
{
//Create new material with the correct shader
Material m = new Material(Shader.Find(mi.shaderName));
//Set int properties (2021.1 or newer)
bool reg = false;
bool depthTex = false;
foreach (MatProperty<int> property in mi.intProperties)
{
//Custom property for default render shader
if (mi.shaderName == "RapidIcon/ObjectRender")
{
if (property.name == "custom_PreMulAlpha")
{
reg = (property.value == 1 ? true : false);
}
if (property.name == "custom_UseDepthTexture")
{
depthTex = (property.value == 1 ? true : false);
}
}
#if UNITY_2021_1_OR_NEWER //Not implemented in older versions of Unity
m.SetInt(property.name, property.value);
#endif
}
//---Handle default render shader---//
if (loadFixEdgesMode && mi.shaderName == "RapidIcon/ObjectRender")
{
if (reg && depthTex)
iconSettings.fixEdgesMode = IconSettings.FixEdgesModes.WithDepthTexture;
else if (reg)
iconSettings.fixEdgesMode = IconSettings.FixEdgesModes.Regular;
else
iconSettings.fixEdgesMode = IconSettings.FixEdgesModes.None;
}
//Set float properties
foreach (MatProperty<float> property in mi.floatProperties)
m.SetFloat(property.name, property.value);
//Set range properties
foreach (MatProperty<float> property in mi.rangeProperties)
m.SetFloat(property.name, property.value);
//Set colour properties
foreach (MatProperty<Color> property in mi.colourProperties)
m.SetColor(property.name, property.value);
//Set vector properties
foreach (MatProperty<Vector4> property in mi.vectorProperties)
m.SetVector(property.name, property.value);
//Set texture properties
foreach (MatProperty<string> property in mi.textureProperties)
{
//Load the texture from GUID, if not null
if (property.name != "null")
{
m.SetTexture(property.name, (Texture2D)AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GUIDToAssetPath(property.value)));
}
}
//Add the material to the post-processing stack
iconSettings.postProcessingMaterials.Add(m);
iconSettings.materialDisplayNames.Add(m, mi.displayName);
iconSettings.materialToggles.Add(m, mi.toggle);
}
}
}
public void SaveMatInfo()
{
//---Clear the matInfo and then store the info for each material in the post-processing stack---//
iconSettings.matInfo.Clear();
foreach (Material mat in iconSettings.postProcessingMaterials)
{
if (mat == null)
continue;
//---Create the new material info---//
MaterialInfo mi = new MaterialInfo(mat.shader.name);
//---Store all of the material's properties---//
int propCount = mat.shader.GetPropertyCount();
for (int i = 0; i < propCount; i++)
{
//---Get properties name and type---//
string propName = mat.shader.GetPropertyName(i);
UnityEngine.Rendering.ShaderPropertyType propType = mat.shader.GetPropertyType(i);
switch (propType)
{
//---Store int properties (2021.1 or newer)---///
#if UNITY_2021_1_OR_NEWER //Not implemented in older versions of Unity
case UnityEngine.Rendering.ShaderPropertyType.Int:
mi.intProperties.Add(new MatProperty<int>(propName, mat.GetInt(propName)));
break;
#endif
//---Store float properties---//
case UnityEngine.Rendering.ShaderPropertyType.Float:
mi.floatProperties.Add(new MatProperty<float>(propName, mat.GetFloat(propName)));
break;
//---Store range properties---//
case UnityEngine.Rendering.ShaderPropertyType.Range:
mi.rangeProperties.Add(new MatProperty<float>(propName, mat.GetFloat(propName)));
break;
//---Store colour properties---//
case UnityEngine.Rendering.ShaderPropertyType.Color:
mi.colourProperties.Add(new MatProperty<Color>(propName, mat.GetColor(propName)));
break;
//---Store vector properties---//
case UnityEngine.Rendering.ShaderPropertyType.Vector:
mi.vectorProperties.Add(new MatProperty<Vector4>(propName, mat.GetVector(propName)));
break;
//---Store texture properties---//
case UnityEngine.Rendering.ShaderPropertyType.Texture:
Texture t = mat.GetTexture(propName);
if (t != null)
//Store GUID of texture
mi.textureProperties.Add(new MatProperty<string>(propName, AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(t))));
else
mi.textureProperties.Add(new MatProperty<string>(propName, "null"));
break;
}
}
//---Add custom property for default render shader---//
if (mat.shader.name == "RapidIcon/ObjectRender")
{
bool enable = (iconSettings.fixEdgesMode == IconSettings.FixEdgesModes.Regular) || (iconSettings.fixEdgesMode == IconSettings.FixEdgesModes.WithDepthTexture);
mi.intProperties.Add(new MatProperty<int>("custom_PreMulAlpha", enable ? 1 : 0));
mi.intProperties.Add(new MatProperty<int>("custom_UseDepthTexture", (iconSettings.fixEdgesMode == IconSettings.FixEdgesModes.WithDepthTexture) ? 1 : 0));
}
//---Store the name and toggle state, then add the matInfo to the list of all matInfos to be save---//
mi.displayName = iconSettings.materialDisplayNames[mat];
mi.toggle = iconSettings.materialToggles[mat];
iconSettings.matInfo.Add(mi);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ba86e62c257f1bb4685f4f8aac8e5f37
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
namespace RapidIcon_1_7_2
{
[Serializable]
public class IconSet
{
public List<Icon> icons;
[SerializeField] List<string> serialisedIconSettings;
public int iconIndex;
//Asset
public string assetPath;
public string assetName;
public string assetShortenedName;
public string folderPath;
public UnityEngine.Object assetObject;
public string assetGUID;
public string[] GUIDs; //No longer used, but kept for backwards compatibility of old save data
//Misc
public Texture2D selectionTexture;
public bool selected;
public bool saveData;
public bool deleted;
public int assetGridIconIndex;
public IconSet(AssetGrid assetGrid, ObjectPathPair objectPathPair)
{
icons = new List<Icon>();
iconIndex = 0;
AddDefaultIcon(assetGrid, objectPathPair);
}
public Icon GetCurrentIcon()
{
return icons[iconIndex];
}
public Icon AddUninitialisedIcon()
{
Icon icon = ScriptableObject.CreateInstance<Icon>();
icon.iconSettings = new IconSettings();
icon.parentIconSet = this;
icons.Add(icon);
return icon;
}
public Icon AddDefaultIcon(AssetGrid assetGrid, ObjectPathPair objectPathPair)
{
Icon icon = ScriptableObject.CreateInstance<Icon>();
icon.Init(Shader.Find("RapidIcon/ObjectRender"), assetGrid.rapidIconRootFolder, (GameObject)objectPathPair.UnityEngine_object);
//---Add the new icon to the icon set---//
icon.parentIconSet = this;
icons.Add(icon);
//---Set the asset object and path of the icon---//
assetObject = objectPathPair.UnityEngine_object;
assetPath = objectPathPair.path;
//---Get the asset as a GameObject, zero the postion if it's very small in magnitude---//
GameObject go = (GameObject)assetObject;
if (icon.iconSettings.objectPosition.magnitude < 0.0001f)
icon.iconSettings.objectPosition = Vector3.zero;
//---Zero the GameObject euler angles if they're very small in magnitude---//
icon.iconSettings.objectRotation = go.transform.eulerAngles;
if (icon.iconSettings.objectRotation.magnitude < 0.0001f)
icon.iconSettings.objectRotation = Vector3.zero;
//---Set the object scale variable---//
icon.iconSettings.objectScale = go.transform.localScale;
//---Get default object position to centre it in the icon---//
Bounds bounds = Utils.GetObjectBounds(this);
icon.iconSettings.objectPosition = Utils.GetObjectAutoOffset(icon, bounds);
//---Get default camera settings to fit the object in the icon render---//
float camAuto = Utils.GetCameraAuto(icon, bounds);
icon.iconSettings.cameraSize = camAuto;
icon.iconSettings.cameraPosition = Vector3.one * camAuto;
//---Render the preview---//
icon.previewRender = Utils.RenderIcon(icon, assetGrid.previewSize, (int)(((float)icon.iconSettings.exportResolution.y / (float)icon.iconSettings.exportResolution.x) * assetGrid.previewSize));
icon.previewRender.hideFlags = HideFlags.DontSave;
//---Set asset name and shortened asset name---//
string[] split;
split = assetPath.Split('/');
assetName = split[split.Length - 1];
if (assetName.Length > 19)
assetShortenedName = assetName.Substring(0, 16) + "...";
else
assetShortenedName = assetName;
//---Set folder path---//
split = assetPath.Split('/');
folderPath = "";
for (int i = 0; i < split.Length - 1; i++)
folderPath += split[i] + (i < split.Length - 2 ? "/" : "");
//---Set export name---//
icon.iconSettings.exportName = assetName;
int extensionPos = icon.iconSettings.exportName.LastIndexOf('.');
icon.iconSettings.exportName = icon.iconSettings.exportName.Substring(0, extensionPos);
//---Set selection texture---//
selectionTexture = assetGrid.assetSelectionTextures[1];
//---Load animations---//
LoadDefaultAnimationClip(icon);
return icon;
}
public void LoadDefaultAnimationClip(Icon icon)
{
//---Load the animation included in the imported assset (if there is one)---//
AnimationClip clip = (AnimationClip)AssetDatabase.LoadAssetAtPath(assetPath, typeof(AnimationClip));
icon.iconSettings.animationClip = clip;
//---If no clip loaded, then try and get one from the Animator component (if there is one)---//
if (icon.iconSettings.animationClip == null)
{
//---Try to get animator component from prefab---//
GameObject gameObject = null;
Animator animator = null;
try
{
gameObject = PrefabUtility.LoadPrefabContents(assetPath);
animator = gameObject.GetComponent<Animator>();
}
catch
{ /*Not a prefab - don't need to do anything just catch the error*/ }
//---If prefab has Animator component, then try to get first animation clip---//
if (animator != null)
{
AnimatorController animatorController = animator.runtimeAnimatorController as AnimatorController;
if (animatorController != null && animatorController.animationClips != null && animatorController.animationClips.Length > 0)
icon.iconSettings.animationClip = animatorController.animationClips[0];
}
//---Unload the prefab---//
if (gameObject != null)
PrefabUtility.UnloadPrefabContents(gameObject);
}
}
public void CompleteLoadData(bool loadFixEdgesModeFromSave)
{
//---Load asset from GUID---//
if (assetGUID != string.Empty)
{
assetObject = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GUIDToAssetPath(assetGUID));
}
icons = new List<Icon>();
//---Complete load data of icons---//
foreach (string iconSettings in serialisedIconSettings)
{
Icon icon = AddUninitialisedIcon();
JsonUtility.FromJsonOverwrite(iconSettings, icon.iconSettings);
icon.CompleteLoadData(this, loadFixEdgesModeFromSave);
icon.LoadMatInfo();
}
}
public void PrepareForSaveData()
{
//---Get GUID of asset---//
assetGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(assetObject));
assetObject = null;
//---Prepare icons for save data---//
serialisedIconSettings = new List<string>();
foreach (Icon icon in icons)
{
icon.PrepareForSaveData();
serialisedIconSettings.Add(JsonUtility.ToJson(icon.iconSettings));
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7b4bd34b0d48a0e45a62ee32f5ee0805
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
namespace RapidIcon_1_7_2
{
[Serializable]
public class IconSetData
{
public List<IconSet> iconSets;
public IconSetData()
{
iconSets = new List<IconSet>();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 386ec4ab5b06b0e4fa8b220121084976
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace RapidIcon_1_7_2
{
[Serializable]
public class IconSettings
{
//Object Settings
public Vector3 objectPosition;
public Vector3 objectRotation;
public Vector3 objectScale;
//Hierarchy Settings
[NonSerialized] public Dictionary<string, bool> subObjectEnables;
public List<string> soeStrings;
public List<bool> soeBools;
//Camera Settings
public Vector3 cameraPosition;
public Vector3 cameraTarget;
public bool autoPosition;
public bool autoScale;
public bool cameraOrtho;
public float cameraFov;
public float cameraSize;
public float camerasScaleFactor;
public float perspLastScale;
//Lighting Settings
public Color lightColour;
public Vector3 lightDir;
public float lightIntensity;
public Color ambientLightColour;
//Animation Settings
public AnimationClip animationClip;
public float animationOffset;
public string animationPath;
//Post-Processing Settings
public List<Material> postProcessingMaterials;
public Dictionary<Material, String> materialDisplayNames;
public Dictionary<Material, bool> materialToggles;
public List<Icon.MaterialInfo> matInfo;
public enum FixEdgesModes { None, Regular, WithDepthTexture };
public FixEdgesModes fixEdgesMode;
public FilterMode filterMode;
//Export Settings
public string exportFolderPath;
public string exportName;
public string exportPrefix;
public string exportSuffix;
public Vector2Int exportResolution;
public IconSettings()
{
//Do nothing
}
public IconSettings(Shader objRenderShader, string rapidIconRootFolder, GameObject rootObject)
{
//---Initialise Icon---//
//Object Settings
objectPosition = Vector3.zero;
objectRotation = Vector3.zero;
objectScale = Vector3.one;
autoPosition = true;
//Hierarchy Settings
subObjectEnables = new Dictionary<string, bool>();
SetSubObjectEnables(rootObject, 0, "");
//Camera Settings
cameraPosition = new Vector3(1, Mathf.Sqrt(2), 1);
perspLastScale = 1;
cameraOrtho = true;
cameraFov = 60;
cameraSize = 5;
camerasScaleFactor = 1;
cameraTarget = Vector3.zero;
autoScale = true;
//Lighting Settings
ambientLightColour = Color.gray;
lightColour = Color.white;
lightDir = new Vector3(50, -30, 0);
lightIntensity = 1;
//Post-Processing Settings
postProcessingMaterials = new List<Material>();
matInfo = new List<Icon.MaterialInfo>();
materialDisplayNames = new Dictionary<Material, string>();
materialToggles = new Dictionary<Material, bool>();
filterMode = FilterMode.Point;
fixEdgesMode = FixEdgesModes.Regular;
Material defaultRender = new Material(objRenderShader);
postProcessingMaterials.Add(defaultRender);
materialDisplayNames.Add(defaultRender, "Object Render");
materialToggles.Add(defaultRender, true);
//Export Settings
exportResolution = new Vector2Int(256, 256);
exportFolderPath = rapidIconRootFolder;
exportFolderPath += "Exports/";
}
void SetSubObjectEnables(GameObject obj, int childIdx, string lastPath)
{
string path = lastPath + "/" + childIdx;
subObjectEnables.Add(path, true);
for (int i = 0; i < obj.transform.childCount; i++)
{
SetSubObjectEnables(obj.transform.GetChild(i).gameObject, i, path);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d03cd17ccaa51bc4b8894e36f7f888ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,150 @@
using System.Collections.Generic;
using System.Linq;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.Rendering.Universal; //URP only
namespace RapidIcon_1_7_2
{
public class RapidIconStage : PreviewSceneStage
{
//---INTERNAL---//
Camera cam;
Color ambientLightColour;
AmbientMode ambientMode;
bool fogEnabled;
public void SetScene(UnityEngine.SceneManagement.Scene scene_in)
{
this.scene = scene_in;
}
public void SetupScene(Icon icon)
{
icon.LoadMatInfo();
//---Create scene objects---//
GameObject obj = GameObject.Instantiate((GameObject)icon.parentIconSet.assetObject);
GameObject camGO = new GameObject("camera");
GameObject lightGO = new GameObject("light");
//---Place the objects in the scene---//
StageUtility.PlaceGameObjectInCurrentStage(camGO);
StageUtility.PlaceGameObjectInCurrentStage(lightGO);
StageUtility.PlaceGameObjectInCurrentStage(obj);
SceneManager.MoveGameObjectToScene(camGO, scene);
SceneManager.MoveGameObjectToScene(lightGO, scene);
SceneManager.MoveGameObjectToScene(obj, scene);
//---Apply the object settings---//
obj.transform.position = icon.iconSettings.objectPosition;
obj.transform.localScale = icon.iconSettings.objectScale;
obj.transform.eulerAngles = icon.iconSettings.objectRotation;
//---Apply hierarchy settings---//
List<string> keys = icon.iconSettings.subObjectEnables.Keys.ToList();
foreach (string key in keys)
{
var indicies = key.Split('/');
GameObject subObj = obj;
for (int i = 2; i < indicies.Length; i++)
{
int idx = int.Parse(indicies[i]);
subObj = subObj.transform.GetChild(idx).gameObject;
}
subObj.SetActive(icon.iconSettings.subObjectEnables[key]);
}
//---Add the camera component and apply camera settings---//
cam = camGO.AddComponent<Camera>();
cam.scene = this.scene;
cam.clearFlags = CameraClearFlags.Nothing;
cam.transform.position = icon.iconSettings.cameraPosition;
cam.transform.LookAt(icon.iconSettings.cameraTarget);
cam.orthographic = icon.iconSettings.cameraOrtho;
cam.orthographicSize = icon.iconSettings.cameraSize;
cam.orthographicSize /= icon.iconSettings.camerasScaleFactor;
cam.fieldOfView = icon.iconSettings.cameraFov;
float fov = 2 * Mathf.Rad2Deg * Mathf.Atan2(
Mathf.Tan(cam.fieldOfView * Mathf.Deg2Rad / 2), icon.iconSettings.camerasScaleFactor
);
if (fov < 0)
fov += 180;
cam.fieldOfView = fov;
cam.nearClipPlane = 0.001f;
cam.farClipPlane = 10000;
cam.depthTextureMode = DepthTextureMode.Depth;
cam.clearFlags = CameraClearFlags.Color;
cam.GetUniversalAdditionalCameraData().renderPostProcessing = false; //URP only
//---Add light componenet and apply lighting settings---//
Light dirLight = lightGO.AddComponent<Light>();
dirLight.type = LightType.Directional;
dirLight.color = icon.iconSettings.lightColour;
dirLight.transform.eulerAngles = icon.iconSettings.lightDir;
dirLight.intensity = icon.iconSettings.lightIntensity;
//---Store current environment settings---//
ambientLightColour = RenderSettings.ambientLight;
ambientMode = RenderSettings.ambientMode;
fogEnabled = RenderSettings.fog;
//---Apply environment settings---//
RenderSettings.ambientLight = icon.iconSettings.ambientLightColour;
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Flat;
RenderSettings.fog = false;
//---Apply animation settings---//
if (icon.iconSettings.animationClip != null)
{
float t = icon.iconSettings.animationClip.length * icon.iconSettings.animationOffset;
icon.iconSettings.animationClip.SampleAnimation(obj, t);
}
}
public Texture2D RenderIcon(int width, int height)
{
//---Setup render texture---//
var rtd = new RenderTextureDescriptor(width, height) { depthBufferBits = 24, msaaSamples = 8, useMipMap = false, sRGB = true };
var rt = new RenderTexture(rtd);
rt.Create();
//---Render camera to render texture---//
cam.targetTexture = rt;
cam.aspect = (float)width / (float)height;
cam.Render();
cam.targetTexture = null;
cam.ResetAspect();
//---Convert render texture to Texture2D---//
Texture2D render = new Texture2D(width, height, TextureFormat.RGBA32, false, false);
var oldActive = RenderTexture.active;
RenderTexture.active = rt;
render.ReadPixels(new Rect(0, 0, width, height), 0, 0);
render.Apply();
//---Cleanup render texture---//
RenderTexture.active = oldActive;
rt.Release();
//---Restore environment settings---//
RenderSettings.ambientLight = ambientLightColour;
RenderSettings.ambientMode = ambientMode;
RenderSettings.fog = fogEnabled;
return render;
}
protected override GUIContent CreateHeaderContent()
{
GUIContent headerContent = new GUIContent();
headerContent.text = "RapidIcon";
return headerContent;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fec9f379a6fe6654597cf7e06aacdb97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d298ccf3892278244b9c8337bb5b7153
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,163 @@
using System;
using UnityEditor;
using UnityEngine;
namespace RapidIcon_1_7_2
{
public enum SeparatorTypes { Vertical, Horizontal };
[Serializable]
public class DraggableSeparator
{
//---PUBLIC---//
public float value;
public Rect rect;
public bool mouseOver;
//---INTERNAL---//
SeparatorTypes separatorType;
bool dragging;
Texture2D separatorTex;
RapidIconWindow window;
public DraggableSeparator(SeparatorTypes sepType)
{
//---Initialise DraggableSeparator---//
//Set type (horizontal/vertical)
separatorType = sepType;
//Create texture, use correct colour for light/dark mode
if (EditorGUIUtility.isProSkin)
separatorTex = Utils.CreateColourTexture(2, 2, new Color32(31, 31, 31, 255));
else
separatorTex = Utils.CreateColourTexture(2, 2, new Color32(153, 153, 153, 255));
separatorTex.hideFlags = HideFlags.DontSave;
}
public void Draw(float minValue, float maxValue, RapidIconWindow w)
{
//---Check variables are set---//
CheckAndSetWindow(w);
CheckPosition(minValue, maxValue);
//---Set seperator length---//
if (separatorType == SeparatorTypes.Vertical)
SetLength(window.position.height);
else
SetLength(window.position.width - window.leftSeparator.value);
//---Draw the separator---//
float currentSepPos = value;
Rect drawRect = new Rect(rect);
if (separatorType == SeparatorTypes.Vertical)
drawRect.width = 1;
else if (separatorType == SeparatorTypes.Horizontal)
drawRect.height = 1;
GUI.DrawTexture(drawRect, separatorTex);
//---Create mouse area rect, slightly larger than the draw rect---//
Rect mouseArea = new Rect(rect);
if (separatorType == SeparatorTypes.Vertical)
mouseArea.position -= new Vector2(3, 0);
else if (separatorType == SeparatorTypes.Horizontal)
mouseArea.position -= new Vector2(0, 4);
//---Set cursor if mouse over mouse area---//
if (separatorType == SeparatorTypes.Vertical)
EditorGUIUtility.AddCursorRect(mouseArea, MouseCursor.ResizeHorizontal);
else if (separatorType == SeparatorTypes.Horizontal)
EditorGUIUtility.AddCursorRect(mouseArea, MouseCursor.ResizeVertical);
//---Detect dragging of separator---//
if (mouseArea.Contains(Event.current.mousePosition))
{
mouseOver = true;
if (Event.current.rawType == EventType.MouseDown)
dragging = true;
}
else
mouseOver = false;
//---Move the separator with mouse if dragging---//
if (dragging)
{
if (separatorType == SeparatorTypes.Vertical)
{
currentSepPos = Mathf.Clamp(Event.current.mousePosition.x, minValue, maxValue);
rect.Set(currentSepPos, rect.y, rect.width, rect.height);
}
else if (separatorType == SeparatorTypes.Horizontal)
{
currentSepPos = Mathf.Clamp(Event.current.mousePosition.y, minValue, maxValue);
rect.Set(rect.x, currentSepPos, rect.width, rect.height);
}
value = currentSepPos;
window.Repaint();
}
//---Detect dragging of seperator stopped---//
if (Event.current.rawType == EventType.MouseUp)
dragging = false;
}
public void SaveData(string name)
{
//---Save separator position value---//
EditorPrefs.SetFloat(PlayerSettings.productName + name, value);
}
public void LoadData(string name, int defaultValue)
{
//---Load separator position value---//
if (separatorType == SeparatorTypes.Vertical)
{
rect = new Rect(EditorPrefs.GetFloat(PlayerSettings.productName + name, defaultValue), 0, 8f, 600);
value = rect.position.x;
}
else if (separatorType == SeparatorTypes.Horizontal)
{
rect = new Rect(0, EditorPrefs.GetFloat(PlayerSettings.productName + name, defaultValue), 400, 6f);
value = rect.position.y;
}
}
void CheckAndSetWindow(RapidIconWindow w)
{
if (!window)
window = w;
}
void SetLength(float length)
{
if (window)
{
if (separatorType == SeparatorTypes.Vertical)
rect.height = length;
else if (separatorType == SeparatorTypes.Horizontal)
rect.width = length;
}
}
void CheckPosition(float min, float max)
{
//---Apply min/max limits to separator position---//
float chk = value;
if (separatorType == SeparatorTypes.Vertical)
{
rect.position = new Vector2(Mathf.Clamp(rect.position.x, min, max), rect.position.y);
value = rect.position.x;
}
else if (separatorType == SeparatorTypes.Horizontal)
{
rect.position = new Vector2(rect.position.x, Mathf.Clamp(rect.position.y, min, max));
value = rect.position.y;
}
//---Repaint if separator has been moved---//
if (window && value != chk)
window.Repaint();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1deafeb94c3e19347ab775f66a3564d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,530 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
namespace RapidIcon_1_7_2
{
static class Utils
{
public static Bounds GetObjectBounds(IconSet iconSet)
{
//---Get object---//
GameObject go = (GameObject)iconSet.assetObject;
//---Store the prefabs position before zero-ing it---//
Vector3 prefabPos = go.transform.position;
go.transform.position = Vector3.zero;
//---Create a bounds object and encapsulate the bounds of the object mesh---//
MeshRenderer mr = go.GetComponent<MeshRenderer>();
Bounds bounds = new Bounds(Vector3.zero, 0.000001f * Vector3.one);
if (mr != null)
bounds.Encapsulate(mr.bounds);
else
{
SkinnedMeshRenderer smr = go.GetComponent<SkinnedMeshRenderer>();
if (smr != null)
bounds.Encapsulate(smr.bounds);
}
//---Encapsulate the bounds of the object's children objects as well---//
Utils.EncapsulateChildBounds(go.transform, ref bounds);
//---Reset the prefab postion to the stored value---//
go.transform.position = prefabPos;
return bounds;
}
public static Vector3 GetObjectAutoOffset(Icon icon, Bounds bounds)
{
//Apply the offset to the icon object position
return -bounds.center;
}
public static float GetCameraAuto(Icon icon, Bounds bounds)
{
//---Scale camera size and position so that the object fits in the render---//
Matrix4x4 trs = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 45, 0), 1.05f * Vector3.one);
Vector3 corner = new Vector3(bounds.extents.x, bounds.extents.y, bounds.extents.z);
corner = trs * corner;
Vector2 refB2 = new Vector2(0.74f, 0.53f);
Vector2 b2 = refB2 * corner.magnitude;
return b2.magnitude;
}
public static void ExportIcon(Icon icon, bool inBatchExport, IconEditor iconEditor)
{
//---Create export folder if it doesn't already exist---//
if (!Directory.Exists(icon.iconSettings.exportFolderPath))
Directory.CreateDirectory(icon.iconSettings.exportFolderPath);
//---Get the full export file name---//
string fileName = icon.iconSettings.exportFolderPath + icon.iconSettings.exportPrefix + icon.iconSettings.exportName + icon.iconSettings.exportSuffix + ".png";
//---If it exists already, check if user want's to replace it---//
if (System.IO.File.Exists(fileName) && !iconEditor.replaceAll)
{
int result = 1;
if (inBatchExport)
result = EditorUtility.DisplayDialogComplex("Replace File?", fileName + " already exists, do you want to replace it?", "Replace", "Skip", "Replace All");
else
result = EditorUtility.DisplayDialog("Replace File?", fileName + " already exists, do you want to replace it?", "Replace", "Cancel") ? 0 : 1;
if (result == 1)
return;
else if (result == 2)
{
iconEditor.replaceAll = true;
}
}
//---Delete any existing file---//
if (AssetDatabase.IsValidFolder(icon.iconSettings.exportFolderPath))
AssetDatabase.DeleteAsset(fileName);
//---Render the icon---//
Texture2D exportRender = Utils.RenderIcon(icon, icon.iconSettings.exportResolution.x, icon.iconSettings.exportResolution.y);
//---Encode to png and save file---//
byte[] bytes = exportRender.EncodeToPNG();
File.WriteAllBytes(fileName, bytes);
}
public static void FinishExportIconSet(List<IconSet> iconSets)
{
//---Loop through all icons in list and finish export---//
foreach (IconSet iconSet in iconSets)
FinishExportIconSet(iconSet);
}
public static void FinishExportIcon(Icon icon)
{
//---Refresh asset database and get full filename---//
AssetDatabase.Refresh();
string fileName = icon.iconSettings.exportFolderPath + icon.iconSettings.exportPrefix + icon.iconSettings.exportName + icon.iconSettings.exportSuffix + ".png";
if (AssetDatabase.IsValidFolder(icon.iconSettings.exportFolderPath.Substring(0, icon.iconSettings.exportFolderPath.Length - 1)))
{
//---Set the importer settings---//
TextureImporter textureImporter = (TextureImporter)AssetImporter.GetAtPath(fileName);
textureImporter.alphaIsTransparency = true;
textureImporter.npotScale = TextureImporterNPOTScale.None;
textureImporter.textureCompression = TextureImporterCompression.Uncompressed;
textureImporter.SaveAndReimport();
textureImporter.filterMode = icon.iconSettings.filterMode;
}
//---Refresh asset database---//
AssetDatabase.Refresh();
}
public static void FinishExportIconSet(IconSet iconSet)
{
foreach (Icon icon in iconSet.icons)
{
//---Refresh asset database and get full filename---//
AssetDatabase.Refresh();
string fileName = icon.iconSettings.exportFolderPath + icon.iconSettings.exportPrefix + icon.iconSettings.exportName + icon.iconSettings.exportSuffix + ".png";
if (AssetDatabase.IsValidFolder(icon.iconSettings.exportFolderPath.Substring(0, icon.iconSettings.exportFolderPath.Length - 1)))
{
//---Set the importer settings---//
TextureImporter textureImporter = (TextureImporter)AssetImporter.GetAtPath(fileName);
textureImporter.alphaIsTransparency = true;
textureImporter.npotScale = TextureImporterNPOTScale.None;
textureImporter.textureCompression = TextureImporterCompression.Uncompressed;
textureImporter.SaveAndReimport();
textureImporter.filterMode = icon.iconSettings.filterMode;
}
}
//---Refresh asset database---//
AssetDatabase.Refresh();
}
public static void UpdateIcon(Icon icon, IconEditor iconEditor)
{
//---Get the render resolution---//
iconEditor.renderResolution = Utils.MutiplyVector2IntByFloat(iconEditor.currentIcon.iconSettings.exportResolution, iconEditor.resMultiplyers[iconEditor.resMultiplyerIndex]);
//---Update the icon render---//
icon.UpdateIcon(iconEditor.renderResolution, new Vector2Int(128, (int)(((float)iconEditor.renderResolution.y / (float)iconEditor.renderResolution.x) * 128)));
}
public static void ApplyToAllSelectedIcons(int tab, IconEditor iconEditor)
{
//---Display confirmation window---//
int result = EditorUtility.DisplayDialogComplex("Apply to All Selected Icons", "Would you like to apply only " + iconEditor.tabNames[tab] + " settings, or all settings?", iconEditor.tabNames[tab] + " Settings Only", "Cancel", "All Settings");
if (result == 1) //cancel
return;
else
{
//---Record object for undo---//
foreach (IconSet iconSet in iconEditor.assetGrid.selectedIconSets)
{
iconSet.GetCurrentIcon().SaveMatInfo();
Undo.RegisterCompleteObjectUndo(iconSet.GetCurrentIcon(), "Apply to all icons");
}
//---Loop through selected icons---//
int index = 1;
foreach (IconSet iconSet in iconEditor.assetGrid.selectedIconSets)
{
//---If not the current icon---//
if (iconSet.GetCurrentIcon() != iconEditor.currentIcon)
{
//---Display progress bar---//
EditorUtility.DisplayProgressBar("Updating Icons (" + index + "/" + (iconEditor.assetGrid.selectedIconSets.Count - 1) + ")", iconSet.assetPath, ((float)index++ / (iconEditor.assetGrid.selectedIconSets.Count - 1)));
Vector2Int oldExportRes = iconSet.GetCurrentIcon().iconSettings.exportResolution;
//---Copy icon settings from current icon to this icon---//
CopyIconSettings(iconEditor.currentIcon, iconSet.GetCurrentIcon(), result == 2 ? -1 : tab);
//--Save the icon---//
iconSet.GetCurrentIcon().SaveMatInfo();
iconSet.saveData = true;
//---Update icon if all settings copied, or if any tab other than hierarchy/export copied (or export resolution changed)---//
if (result == 2
|| (tab != 1 && tab != 6)
|| (tab == 6 && iconSet.GetCurrentIcon().iconSettings.exportResolution != oldExportRes))
{
Utils.UpdateIcon(iconSet.GetCurrentIcon(), iconEditor);
}
}
}
//---Clear the progress bar---//
EditorUtility.ClearProgressBar();
}
}
public static void CopyIconSettings(Icon from, Icon to, int tab)
{
if (from == to)
return;
//---Copy object settings---//
if (tab == 0 || tab == -1)
{
to.iconSettings.objectPosition = from.iconSettings.objectPosition;
to.iconSettings.objectRotation = from.iconSettings.objectRotation;
to.iconSettings.objectScale = from.iconSettings.objectScale;
if (from.iconSettings.autoPosition)
{
to.iconSettings.objectPosition = Utils.GetObjectAutoOffset(to, Utils.GetObjectBounds(to.parentIconSet));
}
to.iconSettings.autoPosition = from.iconSettings.autoPosition;
}
//---Copy camera settings---//
if (tab == 2 || tab == -1)
{
to.iconSettings.cameraPosition = from.iconSettings.cameraPosition;
to.iconSettings.cameraOrtho = from.iconSettings.cameraOrtho;
to.iconSettings.cameraFov = from.iconSettings.cameraFov;
to.iconSettings.cameraSize = from.iconSettings.cameraSize;
to.iconSettings.camerasScaleFactor = from.iconSettings.camerasScaleFactor;
to.iconSettings.perspLastScale = from.iconSettings.perspLastScale;
to.iconSettings.cameraTarget = from.iconSettings.cameraTarget;
if (from.iconSettings.autoScale)
{
to.iconSettings.cameraSize = Utils.GetCameraAuto(to, Utils.GetObjectBounds(to.parentIconSet));
}
to.iconSettings.autoScale = from.iconSettings.autoScale;
}
//--Copy lighting settings---//
if (tab == 3 || tab == -1)
{
to.iconSettings.ambientLightColour = from.iconSettings.ambientLightColour;
to.iconSettings.lightColour = from.iconSettings.lightColour;
to.iconSettings.lightDir = from.iconSettings.lightDir;
to.iconSettings.lightIntensity = from.iconSettings.lightIntensity;
}
//---Copy animation settings---//
if (tab == 4 || tab == -1)
{
to.iconSettings.animationClip = from.iconSettings.animationClip;
to.iconSettings.animationOffset = from.iconSettings.animationOffset;
}
//---Copy post-processing settings---//
if (tab == 5 || tab == -1)
{
foreach (Material mat in to.iconSettings.postProcessingMaterials)
Editor.DestroyImmediate(mat);
to.iconSettings.postProcessingMaterials.Clear();
foreach (Material mat in from.iconSettings.postProcessingMaterials)
{
Material newMat = new Material(mat);
to.iconSettings.postProcessingMaterials.Add(newMat);
to.iconSettings.materialDisplayNames.Add(newMat, from.iconSettings.materialDisplayNames[mat]);
to.iconSettings.materialToggles.Add(newMat, from.iconSettings.materialToggles[mat]);
}
to.iconSettings.fixEdgesMode = from.iconSettings.fixEdgesMode;
to.iconSettings.filterMode = from.iconSettings.filterMode;
}
//---Copy export settings---//
if (tab == 6 || tab == -1)
{
to.iconSettings.exportResolution = from.iconSettings.exportResolution;
to.iconSettings.exportFolderPath = from.iconSettings.exportFolderPath;
to.iconSettings.exportPrefix = from.iconSettings.exportPrefix;
to.iconSettings.exportSuffix = from.iconSettings.exportSuffix;
}
//---Save the icon---//
to.parentIconSet.saveData = true;
}
public static Texture2D CreateColourTexture(int width, int height, Color c)
{
//---Create new texture---//
Texture2D tex = new Texture2D(width, height);
//---Set pixel colours---//
Color[] pixels = Enumerable.Repeat(c, width * height).ToArray();
tex.SetPixels(pixels);
//---Apply changes and set filter mode---//
tex.Apply();
tex.filterMode = FilterMode.Point;
return tex;
}
public static Texture2D RenderIcon(Icon icon, int width = 128, int height = 128)
{
icon.SaveMatInfo();
//---Create stage and scene---//
var scene = EditorSceneManager.NewPreviewScene();
if (scene == null)
{
Debug.LogError("Error creating RapidIcon preview scene");
return Utils.CreateColourTexture(width, height, Color.clear);
}
var stage = ScriptableObject.CreateInstance<RapidIconStage>();
if (stage == null)
{
Debug.LogError("Error creating RapidIcon stage");
return Utils.CreateColourTexture(width, height, Color.clear);
}
stage.SetScene(scene);
//---Setup scene---//
stage.SetupScene(icon);
//and render icon---//
Texture2D render = stage.RenderIcon(width, height);
//---Fix alpha edges---//
if (icon.iconSettings.fixEdgesMode == IconSettings.FixEdgesModes.Regular || icon.iconSettings.fixEdgesMode == IconSettings.FixEdgesModes.WithDepthTexture)
render = Utils.FixAlphaEdges(render, icon.iconSettings.fixEdgesMode == IconSettings.FixEdgesModes.WithDepthTexture);
//---Known bug---//
if (icon.iconSettings.materialToggles == null)
{
icon.LoadMatInfo();
Debug.LogError("[RapidIcon] Undo Error: This is a known bug, if you \"Apply to All Selected Icons\" and then try to undo after changing your icon selection, the tool will not be able to undo the changes.");
}
//---Apply post-processing shaders---//
Texture2D img = CreateColourTexture(width, height, Color.clear);
foreach (Material m in icon.iconSettings.postProcessingMaterials)
{
if (icon.iconSettings.materialToggles != null)
{
if (icon.iconSettings.materialToggles[m])
{
var rtd = new RenderTextureDescriptor(img.width, img.height) { depthBufferBits = 24, msaaSamples = 8, useMipMap = false, sRGB = true };
var rt = new RenderTexture(rtd);
if (m == null)
continue;
if (m.shader.name == "RapidIcon/ObjectRender")
m.SetTexture("_Render", render);
Graphics.Blit(img, rt, m);
RenderTexture.active = rt;
img = new Texture2D(img.width, img.height);
img.ReadPixels(new Rect(0, 0, img.width, img.height), 0, 0);
img.Apply();
RenderTexture.active = null;
rt.Release();
}
}
}
//---Apply filter mode---//
img.filterMode = icon.iconSettings.filterMode;
EditorSceneManager.ClosePreviewScene(scene);
ScriptableObject.DestroyImmediate(stage);
icon.LoadMatInfo();
return img;
}
public static void CheckCurrentIconRender(IconEditor iconEditor)
{
//---If the current icon doesn't have a full render, then render one---//
if (!iconEditor.currentIcon.fullRender)
{
iconEditor.renderResolution = Utils.MutiplyVector2IntByFloat(iconEditor.currentIcon.iconSettings.exportResolution, iconEditor.resMultiplyers[iconEditor.resMultiplyerIndex]);
iconEditor.currentIcon.fullRender = Utils.RenderIcon(iconEditor.currentIcon, iconEditor.renderResolution.x, iconEditor.renderResolution.y);
iconEditor.currentIcon.fullRender.hideFlags = HideFlags.DontSave;
}
}
public static Texture2D FixAlphaEdges(Texture2D tex, bool useDepthTex)
{
//---Create render texture---//
var rtd = new RenderTextureDescriptor(tex.width, tex.height) { depthBufferBits = 24, msaaSamples = 8, useMipMap = false, sRGB = true };
var rt = new RenderTexture(rtd);
//---Blit texture to render texture using ImgShader---//
Material mat = new Material(Shader.Find("RapidIcon/ImgShader"));
mat.SetInt("_UseDepthTexture", useDepthTex ? 1 : 0);
Graphics.Blit(tex, rt, mat);
//---Copy the render texture to Texture2D---//
RenderTexture.active = rt;
Texture2D baked = new Texture2D(tex.width, tex.height);
baked.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);
baked.Apply();
//---Cleanup---//
RenderTexture.active = null;
rt.Release();
return baked;
}
public static void SaveIconSetData(IconSetData iconSetData)
{
//---Perpare each icon for saving---//
foreach (IconSet iconSet in iconSetData.iconSets)
{
iconSet.PrepareForSaveData();
}
//---Save the data---//
string data = JsonUtility.ToJson(iconSetData);
EditorPrefs.SetString(PlayerSettings.productName + "RapidIconData", data);
}
public static IconSetData LoadIconSetData()
{
//---Load the icon data---//
string data = EditorPrefs.GetString(PlayerSettings.productName + "RapidIconData");
IconSetData iconData = JsonUtility.FromJson<IconSetData>(data);
//---Complete the load data for each icon---//
if (iconData != null)
{
//---Handle version control---//
VersionControl.CheckUpdate(iconData.iconSets);
bool loadFixEdgesModeFromSave = !(VersionControl.GetStoredVersion() < new VersionControl.Version("1.6.2")); //Keep at 1.6.2, do not update to latest version
foreach (IconSet iconSet in iconData.iconSets)
{
iconSet.CompleteLoadData(loadFixEdgesModeFromSave);
}
}
//---Update current stored version---//
VersionControl.UpdateStoredVersion();
return iconData;
}
//---Extension method to convert Vector2 to Vector2Int---//
public static Vector2Int ToVector2Int(this Vector2 v)
{
return new Vector2Int((int)v.x, (int)v.y);
}
public static void EncapsulateChildBounds(Transform t, ref Bounds bounds)
{
//---For each child object, encapsulate its bounds---//
MeshRenderer mr;
for (int i = 0; i < t.childCount; i++)
{
mr = t.GetChild(i).GetComponent<MeshRenderer>();
if (mr != null)
bounds.Encapsulate(mr.bounds);
else
{
SkinnedMeshRenderer smr = t.GetChild(i).GetComponent<SkinnedMeshRenderer>();
if (smr != null)
bounds.Encapsulate(smr.bounds);
}
EncapsulateChildBounds(t.GetChild(i), ref bounds);
}
}
[MenuItem("Tools/RapidIcon Utilities/Delete All Saved Data")]
static void DeleteEditorPrefs()
{
if (EditorUtility.DisplayDialog("Confirm", "Are you sure you want to delete all RapidIcon data? This will delete all of your icon settings and cannot be undone", "Delete", "Cancel"))
{
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconOpenedFolders");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconSelectedFolders");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconSepPosLeft");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconSelectedAssets");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconAssetGridScroll");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconSepPosRight");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconSepPosPreview");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconPreviewResIdx");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconPreviewZoomIdx");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconEditorTab");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconData");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconIconsRefreshed");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconFilterIdx");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconVersion");
}
}
[MenuItem("Tools/RapidIcon Utilities/Don't Save On Close")]
static void DontSaveOnExit()
{
RapidIconWindow.dontSaveOnExit = true;
}
public static Vector2Int MutiplyVector2IntByFloat(Vector2Int vec, float f)
{
Vector2Int res = vec;
res.x = (int)(res.x * f);
res.y = (int)(res.y * f);
return res;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2e094dfc2ea2b6d42862e768ba911ca1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,170 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace RapidIcon_1_7_2
{
public static class VersionControl
{
static Version thisVersion = new Version("1.7.2");
public struct Version
{
public int major;
public int minor;
public int patch;
public Version(int major, int minor, int patch)
{
this.major = major;
this.minor = minor;
this.patch = patch;
}
public Version(string version)
{
this = ConvertFromString(version);
}
public static Version ConvertFromString(string s)
{
Version version = new Version(0, 0, 0);
string[] split = s.Split(".");
if (split != null)
{
if (split.Length >= 1)
int.TryParse(split[0], out version.major);
if (split.Length >= 2)
int.TryParse(split[1], out version.minor);
if (split.Length >= 3)
int.TryParse(split[2], out version.patch);
}
return version;
}
public static bool operator >(Version v1, Version v2)
{
if (v1.major > v2.major)
return true; //major is newer
else if (v1.major < v2.major)
return false; //major is older
//major is equal
if (v1.minor > v2.minor)
return true; //minor is newer
else if (v1.minor < v2.minor)
return false; //minor is older
//minor is equal
if (v1.patch > v2.patch)
return true; //patch is newer
else if (v1.patch < v2.patch)
return false; //patch is older
//patch is equal, versions are equal
return false;
}
public static bool operator <(Version v1, Version v2)
{
if (v1.major < v2.major)
return true; //major is older
else if (v1.major > v2.major)
return false; //major is newer
//major is equal
if (v1.minor < v2.minor)
return true; //minor is older
else if (v1.minor > v2.minor)
return false; //minor is newer
//minor is equal
if (v1.patch < v2.patch)
return true; //patch is older
else if (v1.patch > v2.patch)
return false; //patch is newer
//patch is equal, versions are equal
return false;
}
}
public static string ConvertToString(this Version version)
{
return version.major + "." + version.minor + "." + version.patch;
}
public static Version GetStoredVersion()
{
string s = EditorPrefs.GetString(PlayerSettings.productName + "RapidIconVersion", thisVersion.ConvertToString());
return Version.ConvertFromString(s);
}
public static void UpdateStoredVersion()
{
EditorPrefs.SetString(PlayerSettings.productName + "RapidIconVersion", thisVersion.ConvertToString());
}
public static bool IsStoredVersionOld()
{
Version version = GetStoredVersion();
if (thisVersion > version)
return true;
return false;
}
public static void CheckUpdate(List<IconSet> iconSets)
{
Version lastVersion = GetStoredVersion();
//---Pre 1.7.0 Updates---//
//Versions before 1.7.0 are no longer supported
if (lastVersion < new Version("1.7.0"))
{
Debug.LogWarning("RapidIcon versions prior to 1.7.0 are no longer supported");
return;
}
}
public static bool PreLoadCheck()
{
Version lastVersion = GetStoredVersion();
//---1.7.0 Updates---//
if (lastVersion < new Version("1.7.0"))
{
if (EditorUtility.DisplayDialog("Confirm", "Version 1.7.0 is not compatible with data from older version (" + lastVersion.ConvertToString() + "). Old data will be deleted, do you want to continue?", "Continue", "Cancel"))
{
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconOpenedFolders");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconSelectedFolders");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconSelectedAssets");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconAssetGridScroll");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconEditorTab");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconData");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconIconsRefreshed");
EditorPrefs.DeleteKey(PlayerSettings.productName + "RapidIconFilterIdx");
UpdateStoredVersion();
}
else
return false;
}
return true;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e8b6b50a5e61d7b47bdaed3b7a92e673
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 38c856e1df48832439f69da012f05ca0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,142 @@
using UnityEditor;
using UnityEngine;
namespace RapidIcon_1_7_2
{
public class CopyWindow : EditorWindow
{
public static CopyWindow window;
private static int option;
private static int subOption;
private static int selectedVariantIdx;
private static IconEditor iconEditor;
public static void Init(IconEditor editor)
{
window = (CopyWindow)GetWindow(typeof(CopyWindow), true, "Copy to other icons");
window.position = new Rect(Screen.currentResolution.width / 2 - 230, Screen.currentResolution.height / 2 - 64, 460, 128);
iconEditor = editor;
selectedVariantIdx = iconEditor.currentIconSet.icons.IndexOf(iconEditor.currentIcon);
window.Show();
}
void OnGUI()
{
GUILayout.Space(4);
GUILayout.Label("Copy to");
//---Draw dropdown list of selected assets---//
string[] options = new string[] { "All variants of this icon", "Currently selected variant of selected icons", "All variants of selected icons", "Specific variant of selected icons" };
option = EditorGUILayout.Popup(option, options);
string[] subOptions = new string[] { "Current tab only", "All tabs" };
subOption = EditorGUILayout.Popup(subOption, subOptions);
if (option == 3)
{
selectedVariantIdx = EditorGUILayout.IntField("Variant Index", selectedVariantIdx);
if (selectedVariantIdx < 0)
selectedVariantIdx = 0;
bool showWarning = false;
foreach (IconSet iconSet in iconEditor.assetGrid.selectedIconSets)
{
if (selectedVariantIdx >= iconSet.icons.Count)
{
showWarning = true;
break;
}
}
if (showWarning)
{
GUIStyle s = new GUIStyle(GUI.skin.label);
s.normal.textColor = new Color(1.0f, 0.5f, 0.0f, 1.0f);
GUILayout.Label("Not all selected icons have a variant at index " + selectedVariantIdx + ", a new variant will be created", s);
}
}
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Copy"))
{
DoCopy();
window.Close();
}
GUILayout.EndHorizontal();
}
private void DoCopy()
{
switch (option)
{
case 0:
int idx = 0;
int count = iconEditor.currentIconSet.icons.Count;
foreach (Icon icon in iconEditor.currentIconSet.icons)
{
EditorUtility.DisplayProgressBar("Copy to Other Icons", "Copying to icon (" + idx + "/" + count + ")", (float)(idx++)/count);
Utils.CopyIconSettings(iconEditor.currentIcon, icon, subOption == 0 ? iconEditor.tab : -1);
Utils.UpdateIcon(icon, iconEditor);
}
EditorUtility.ClearProgressBar();
break;
case 1:
idx = 0;
count = iconEditor.assetGrid.selectedIconSets.Count;
foreach (IconSet iconSet in iconEditor.assetGrid.selectedIconSets)
{
EditorUtility.DisplayProgressBar("Copy to Other Icons", "Copying to icon (" + idx + "/" + count + ")", (float)(idx++) / count);
Icon icon = iconSet.GetCurrentIcon();
Utils.CopyIconSettings(iconEditor.currentIcon, icon, subOption == 0 ? iconEditor.tab : -1);
Utils.UpdateIcon(icon, iconEditor);
}
EditorUtility.ClearProgressBar();
break;
case 2:
idx = 0;
count = iconEditor.assetGrid.selectedIconSets.Count;
foreach (IconSet iconSet in iconEditor.assetGrid.selectedIconSets)
{
EditorUtility.DisplayProgressBar("Copy to Other Icons", "Copying to icon (" + idx + "/" + count + ")", (float)(idx++) / count);
foreach (Icon icon in iconSet.icons)
{
Utils.CopyIconSettings(iconEditor.currentIcon, icon, subOption == 0 ? iconEditor.tab : -1);
Utils.UpdateIcon(icon, iconEditor);
}
}
EditorUtility.ClearProgressBar();
break;
case 3:
idx = 0;
count = iconEditor.assetGrid.selectedIconSets.Count;
foreach (IconSet iconSet in iconEditor.assetGrid.selectedIconSets)
{
EditorUtility.DisplayProgressBar("Copy to Other Icons", "Copying to icon (" + idx + "/" + count + ")", (float)(idx++) / count);
Icon icon;
if (iconSet.icons.Count > selectedVariantIdx)
icon = iconSet.icons[selectedVariantIdx];
else
{
icon = iconSet.AddDefaultIcon(iconEditor.assetGrid, new ObjectPathPair { path = iconSet.assetPath, UnityEngine_object = iconSet.assetObject });
iconSet.iconIndex = iconSet.icons.Count - 1;
icon.iconSettings.exportName += " (" + iconSet.iconIndex + ")";
}
Utils.CopyIconSettings(iconEditor.currentIcon, icon, subOption == 0 ? iconEditor.tab : -1);
Utils.UpdateIcon(icon, iconEditor);
}
EditorUtility.ClearProgressBar();
break;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2be791c4489377a4ca53adc5e9e2b9ee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,147 @@
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace RapidIcon_1_7_2
{
public class RapidIconWindow : EditorWindow
{
public static RapidIconWindow window;
public AssetList assetList;
public DraggableSeparator leftSeparator, rightSeparator;
public AssetGrid assetGrid;
public IconEditor iconEditor;
public static bool dontSaveOnExit;
public bool forceCloseDontSave;
[MenuItem("Tools/RapidIcon")]
public static void Init()
{
SessionState.SetBool("rapidicon_forceclose", false);
SessionState.SetBool("rapidicon_loaded", true);
if (!VersionControl.PreLoadCheck())
return;
/*--------------------------------------------------------------------------------
* Display RapidIcon window
*--------------------------------------------------------------------------------*/
dontSaveOnExit = false;
window = (RapidIconWindow)GetWindow(typeof(RapidIconWindow), false, "RapidIcon");
window.minSize = new Vector2(870, 600);
window.forceCloseDontSave = false;
window.Show();
float x = EditorPrefs.GetFloat(PlayerSettings.productName + "RapidIconWindowPosX", -1);
float y = EditorPrefs.GetFloat(PlayerSettings.productName + "RapidIconWindowPosY", -1);
float width = EditorPrefs.GetFloat(PlayerSettings.productName + "RapidIconWindowWidth", -1);
if (x != -1 && y != -1 && width != -1)
window.position = new Rect(x, y, width, window.position.height);
EditorSceneManager.sceneClosing += window.SceneClosing;
EditorSceneManager.sceneOpened += window.OpenScene;
EditorSceneManager.newSceneCreated += window.NewScene;
}
private void OnEnable()
{
/*--------------------------------------------------------------------------------
* Instantiate and initialise window elements
* Load data
*--------------------------------------------------------------------------------*/
assetList = new AssetList(Application.dataPath);
assetList.LoadData();
leftSeparator = new DraggableSeparator(SeparatorTypes.Vertical);
leftSeparator.LoadData("RapidIconSepPosLeft", 300);
rightSeparator = new DraggableSeparator(SeparatorTypes.Vertical);
rightSeparator.LoadData("RapidIconSepPosRight", 900);
assetGrid = new AssetGrid(assetList);
iconEditor = new IconEditor(assetGrid, window);
iconEditor.LoadData();
assetGrid.LoadData();
}
void SceneClosing(Scene s, bool removingScene)
{
foreach (IconSet iconSet in assetGrid.objectIconSets.Values)
{
foreach (Icon icon in iconSet.icons)
icon.SaveMatInfo();
}
}
void NewScene(Scene s, NewSceneSetup newSceneSetup, NewSceneMode newSceneMode)
{
window.Close();
}
void OpenScene(Scene s, OpenSceneMode openSceneMode)
{
window.Close();
}
private void OnDisable()
{
if (forceCloseDontSave)
return;
/*--------------------------------------------------------------------------------
* Save data
*--------------------------------------------------------------------------------*/
assetList.SaveData();
leftSeparator.SaveData("RapidIconSepPosLeft");
rightSeparator.SaveData("RapidIconSepPosRight");
assetGrid.SaveData();
if (dontSaveOnExit)
{
bool res = EditorUtility.DisplayDialog("Exit Without Save?", "You have selected to exit without saving, are you sure?", "Don't Save", "Save");
if (res)
return;
}
iconEditor.SaveData();
}
void OnGUI()
{
if (!window)
{
RapidIconWindow window = EditorWindow.GetWindow<RapidIconWindow>();
window.forceCloseDontSave = true;
window.Close();
return;
}
if (SessionState.GetBool("rapidicon_forceclose", false))
{
forceCloseDontSave = true;
SessionState.SetBool("rapidicon_forceclose", false);
window.Close();
}
/*--------------------------------------------------------------------------------
* Draw window elements
*--------------------------------------------------------------------------------*/
GUILayout.BeginHorizontal();
if (!iconEditor.fullscreen)
{
assetList.Draw(leftSeparator.value, window);
leftSeparator.Draw(150, rightSeparator.value - 320, window);
assetGrid.Draw(rightSeparator.value - leftSeparator.value, window);
rightSeparator.Draw(leftSeparator.value + 320, window.position.width - 400, window);
}
iconEditor.Draw(window.position.width - rightSeparator.value, window);
GUILayout.EndHorizontal();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1aaff905f87cc4c4bb8d3d29cdc687e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,144 @@
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace RapidIcon_1_7_2
{
public class ResetWindow : EditorWindow
{
public static ResetWindow window;
private static int option;
private static int subOption;
private static IconEditor iconEditor;
public static void Init(IconEditor editor)
{
window = (ResetWindow)GetWindow(typeof(ResetWindow), true, "Reset");
window.position = new Rect(Screen.currentResolution.width / 2 - 200, Screen.currentResolution.height / 2 - 50, 400, 100);
iconEditor = editor;
window.Show();
}
void OnGUI()
{
GUILayout.Space(4);
GUILayout.Label("Reset");
//---Draw dropdown list of selected assets---//
string[] options = new string[] { "Currently selected variant only", "All variants of currently selected icon", "Currently selected variant of all selected icons", "All variants of all selected icons", "Reset and delete all variants (this icon only)", "Reset and delete all variants (all selected icons)" };
option = EditorGUILayout.Popup(option, options);
if (option <= 3)
{
string[] subOptions = new string[] { "Current tab only", "All tabs" };
subOption = EditorGUILayout.Popup(subOption, subOptions);
}
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Reset"))
{
DoReset();
window.Close();
}
GUILayout.EndHorizontal();
}
private void DoReset()
{
switch (option)
{
case 0:
ResetIcon(iconEditor.currentIcon);
break;
case 1:
int idx = 0;
int count = iconEditor.currentIconSet.icons.Count;
foreach (Icon icon in iconEditor.currentIconSet.icons)
{
EditorUtility.DisplayProgressBar("Reset Icons", "Resetting icon (" + idx + "/" + count + ")", (float)(idx++) / count);
ResetIcon(icon);
}
EditorUtility.ClearProgressBar();
break;
case 2:
idx = 0;
count = iconEditor.assetGrid.selectedIconSets.Count;
foreach (IconSet iconSet in iconEditor.assetGrid.selectedIconSets)
{
EditorUtility.DisplayProgressBar("Reset Icons", "Resetting icon (" + idx + "/" + count + ")", (float)(idx++) / count);
Icon icon = iconSet.GetCurrentIcon();
ResetIcon(icon);
}
EditorUtility.ClearProgressBar();
break;
case 3:
idx = 0;
count = iconEditor.assetGrid.selectedIconSets.Count;
foreach (IconSet iconSet in iconEditor.assetGrid.selectedIconSets)
{
EditorUtility.DisplayProgressBar("Reset Icons", "Resetting icon (" + idx + "/" + count + ")", (float)(idx++) / count);
foreach (Icon icon in iconSet.icons)
{
ResetIcon(icon);
}
}
EditorUtility.ClearProgressBar();
break;
case 4:
iconEditor.currentIconSet.icons.Clear();
ObjectPathPair currrntSetObj = new ObjectPathPair(iconEditor.currentIconSet.assetObject, iconEditor.currentIconSet.assetPath);
iconEditor.currentIconSet.AddDefaultIcon(iconEditor.assetGrid, currrntSetObj);
iconEditor.currentIconSet.iconIndex = 0;
break;
case 5:
idx = 0;
count = iconEditor.assetGrid.selectedIconSets.Count;
foreach (IconSet iconSet in iconEditor.assetGrid.selectedIconSets)
{
EditorUtility.DisplayProgressBar("Reset Icons", "Resetting icon (" + idx + "/" + count + ")", (float)(idx++) / count);
iconSet.icons.Clear();
ObjectPathPair setObj = new ObjectPathPair(iconSet.assetObject, iconSet.assetPath);
iconSet.AddDefaultIcon(iconEditor.assetGrid, setObj);
iconSet.iconIndex = 0;
}
EditorUtility.ClearProgressBar();
break;
}
}
private void ResetIcon(Icon icon)
{
//---Create a reset icon---//
ObjectPathPair obj = new ObjectPathPair(icon.parentIconSet.assetObject, icon.parentIconSet.assetPath);
IconSet newIconSet = iconEditor.assetGrid.CreateIconSet(obj);
Utils.CopyIconSettings(newIconSet.GetCurrentIcon(), icon, subOption == 0 ? iconEditor.tab : -1);
ResetHierarchy(icon);
Utils.UpdateIcon(icon, iconEditor);
}
private void ResetHierarchy(Icon icon)
{
List<string> keys = icon.iconSettings.subObjectEnables.Keys.ToList();
foreach (string s in keys)
icon.iconSettings.subObjectEnables[s] = true;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8d4beb9accfc98843b04511a1978a612
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 954762a6a3282594aa92cadacac0ed67
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,106 @@
fileFormatVersion: 2
guid: 2c228a5b0451ee94286cb772ffdbd13b
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,110 @@
fileFormatVersion: 2
guid: ac814a384ed02864586bb115e2d633b3
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: a5e714f8a69c9e045ba052949185e1cf
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 13aa37db26a94d1469f83d1a77fd963d
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 09f1769391151b34f8a5d7b3c04e97b2
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: a114500a04d1ce64f937c28005a810f5
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 64bde91062bb95f45a9f4bcb01f23f72
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,120 @@
fileFormatVersion: 2
guid: 835127944badb174aa949d535c1684cd
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,106 @@
fileFormatVersion: 2
guid: 68ba632e4aeca6f4599e2f67d921c7d0
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: -1
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 7d97d81b00f4874488e8f1ed90493168
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 0dedd4889dcc6d44a8db00515bb6e94a
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 5f9f2f73f4839ca4198d5f51757e745a
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: ae4a2439dff069e479b4e4a39779500b
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 37ad0900422b207448885f6968382857
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9194eea3f3d5e6e4b8dcfe274045ebaf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
Shader "RapidIcon/ImgShader"
{
Properties
{
_MainTex("Tex", 2D) = "white" {}
_UseDepthTexture("UseDepthTexture", int) = 0
}
SubShader
{
Tags { "Queue" = "Transparent" "PreviewType" = "Plane" }
//LOD 100
ZWrite Off
Blend One OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
sampler2D _LastCameraDepthTexture;
int _UseDepthTexture;
v2f vert(appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
half4 frag(v2f i) : SV_Target
{
half4 col = tex2D(_MainTex, i.uv);
if (col.a > 0 && col.a < 1)
{
col.r /= col.a;
col.g /= col.a;
col.b /= col.a;
}
float depth = tex2D(_LastCameraDepthTexture, i.uv).r;
depth = Linear01Depth(depth);
depth = 1-depth;
if(depth > 0.01)
depth = 1;
if(_UseDepthTexture == 1)
{
col.a*=depth;
}
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: c8660893a3c43aa4fb36057a3973f713
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
Shader "RapidIcon/ObjectRender"
{
Properties
{
[NoScaleOffset]
_MainTex("Tex", 2D) = "black" {}
[NoScaleOffset]
_Render("Object Render", 2D) = "black" {}
}
SubShader
{
Blend One OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
sampler2D _Render;
fixed4 frag(v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
fixed4 render = tex2D(_Render, i.uv);
fixed4 output;
output.rgb = lerp(col.rgb, render.rgb, render.a);
output.a = 1 - ((1 - col.a)*(1 - render.a));
return output;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e533984b6c5c18a4087237c04964e9f0
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3462a04ea39fe2242896806769cbb73f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,85 @@
Shader "RapidIcon/PostProcessing/HSV"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_Hue("Hue", range(0,1)) = 0
_Saturation("Saturation", range(0,1)) = 1
_Value("Value", range(0,1)) = 1
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
float _Hue;
float _Saturation;
float _Value;
fixed4 frag(v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
float pi = 3.14159265359;
float U = cos(2*_Hue*pi);
float W = sin(2*_Hue*pi);
float4 newCol;
newCol.r = (.299 + .701*U + .168*W)*col.r
+ (.587 - .587*U + .330*W)*col.g
+ (.114 - .114*U - .497*W)*col.b;
newCol.g = (.299 - .299*U - .328*W)*col.r
+ (.587 + .413*U + .035*W)*col.g
+ (.114 - .114*U + .292*W)*col.b;
newCol.b = (.299 - .3*U + 1.25*W)*col.r
+ (.587 - .588*U - 1.05*W)*col.g
+ (.114 + .886*U - .203*W)*col.b;
float grayscale;
grayscale = dot(float3(0.222, 0.707, 0.071), newCol);
float3 desatCol;
desatCol = float3(grayscale, grayscale, grayscale);
col.rgb = lerp(desatCol, newCol.rgb, _Saturation)*_Value;
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: bbdf8525b70b0674b9fc5434a98da0ad
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
Shader "RapidIcon/PostProcessing/Mask" {
Properties{
[NoScaleOffset]
[MainTexture]
_MainTex("Tex", 2D) = "black" {}
[NoScaleOffset]
_MaskTex("Mask", 2D) = "white" {}
[Toggle]
_UseLuminance("Use Luminance", Int) = 1
}
SubShader
{
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" }
Blend One OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
sampler2D _MaskTex;
int _UseLuminance;
fixed4 frag(v2f_img i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
fixed3 maskCol = tex2D(_MaskTex, i.uv).rgb;
if (_UseLuminance == 1)
{
fixed maskLum = Luminance(maskCol).r;
col *= maskLum;
}
else
{
fixed maskLum = maskCol.r;
col *= maskLum;
}
return col;
}
ENDCG
}
}
FallBack "Diffuse"
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 0799f06535cf3f14991a4a50bcc4673c
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,113 @@
Shader "RapidIcon/PostProcessing/Overlay"
{
Properties
{
[NoScaleOffset]
_MainTex("Tex", 2D) = "black" {}
[NoScaleOffset]
_OverlayTex("Overlay Image", 2D) = "black" {}
[Toggle]
_MatchAspect("Match Image Aspect Ratio", Int) = 1
_Scale("Scale", Float) = 1
_OffsetX("X Offset", Float) = 0
_OffsetY("Y Offset", Float) = 0
}
SubShader
{
Blend One OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uvMain : TEXCOORD0;
float2 uvOverlay : TEXCOORD1;
};
struct v2f
{
float2 uvMain : TEXCOORD0;
float2 uvOverlay : TEXCOORD1;
float4 vertex : SV_POSITION;
};
float4 _MainTex_TexelSize;
float4 _OverlayTex_TexelSize;
int _MatchAspect;
float _Scale;
float _OffsetX;
float _OffsetY;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uvMain = v.uvMain;
o.uvOverlay = v.uvOverlay;
o.uvOverlay.x -= _OffsetX;
o.uvOverlay.y -= _OffsetY;
o.uvOverlay = (o.uvOverlay - 0.5) / _Scale + 0.5;
if (_OverlayTex_TexelSize.z > _OverlayTex_TexelSize.w)
{
float aspectScale = _OverlayTex_TexelSize.x / _OverlayTex_TexelSize.y;
o.uvOverlay.y = (o.uvOverlay.y - 0.5) / aspectScale + 0.5;
}
else
{
float aspectScale = _OverlayTex_TexelSize.y / _OverlayTex_TexelSize.x;
o.uvOverlay.x = (o.uvOverlay.x - 0.5) / aspectScale + 0.5;
}
if (!_MatchAspect) {
if (_MainTex_TexelSize.z > _MainTex_TexelSize.w)
{
float aspectScale = _MainTex_TexelSize.y / _MainTex_TexelSize.x;
o.uvOverlay.y = (o.uvOverlay.y - 0.5) / aspectScale + 0.5;
}
else
{
float aspectScale = _MainTex_TexelSize.x / _MainTex_TexelSize.y;
o.uvOverlay.x = (o.uvOverlay.x - 0.5) / aspectScale + 0.5;
}
}
return o;
}
sampler2D _MainTex;
sampler2D _OverlayTex;
fixed4 frag(v2f i) : SV_Target
{
fixed4 main = tex2D(_MainTex, i.uvMain);
fixed4 overlay = tex2D(_OverlayTex, i.uvOverlay);
fixed4 output;
if (i.uvOverlay.x < 0 || i.uvOverlay.x > 1 || i.uvOverlay.y < 0 || i.uvOverlay.y > 1)
output = main;
else
{
if (overlay.a > 0)
output.rgb = lerp(main.rgb, overlay.rgb, overlay.a);
else
output.rgb = main;
output.a = 1 - ((1 - main.a)*(1 - overlay.a));
}
return output;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 4ed84d029799b8b42bd7d4b9899db3b2
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
Shader "RapidIcon/PostProcessing/Transparency"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Transparency("Transparency", range(0, 1)) = 0
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
float _Transparency;
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
col *= 1-_Transparency;
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 4fbf5a470ce0bd341b7e867ab7ead320
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,112 @@
Shader "RapidIcon/PostProcessing/Underlay"
{
Properties
{
[NoScaleOffset]
_MainTex("Tex", 2D) = "black" {}
[NoScaleOffset]
_UnderlayTex("Underlay Image", 2D) = "black" {}
[Toggle]
_MatchAspect("Match Image Aspect Ratio", Int) = 1
_Scale("Scale", Float) = 1
_OffsetX("X Offset", Float) = 0
_OffsetY("Y Offset", Float) = 0
}
SubShader
{
Blend One OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uvMain : TEXCOORD0;
float2 uvUnderlay : TEXCOORD1;
};
struct v2f
{
float2 uvMain : TEXCOORD0;
float2 uvUnderlay : TEXCOORD1;
float4 vertex : SV_POSITION;
};
float4 _MainTex_TexelSize;
float4 _UnderlayTex_TexelSize;
int _MatchAspect;
float _Scale;
float _OffsetX;
float _OffsetY;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uvMain = v.uvMain;
o.uvUnderlay = v.uvUnderlay;
o.uvUnderlay.x -= _OffsetX;
o.uvUnderlay.y -= _OffsetY;
o.uvUnderlay = (o.uvUnderlay - 0.5) / _Scale + 0.5;
if (_UnderlayTex_TexelSize.z > _UnderlayTex_TexelSize.w)
{
float aspectScale = _UnderlayTex_TexelSize.x / _UnderlayTex_TexelSize.y;
o.uvUnderlay.y = (o.uvUnderlay.y - 0.5) / aspectScale + 0.5;
}
else
{
float aspectScale = _UnderlayTex_TexelSize.y / _UnderlayTex_TexelSize.x;
o.uvUnderlay.x = (o.uvUnderlay.x - 0.5) / aspectScale + 0.5;
}
if (!_MatchAspect) {
if (_MainTex_TexelSize.z > _MainTex_TexelSize.w)
{
float aspectScale = _MainTex_TexelSize.y / _MainTex_TexelSize.x;
o.uvUnderlay.y = (o.uvUnderlay.y - 0.5) / aspectScale + 0.5;
}
else
{
float aspectScale = _MainTex_TexelSize.x / _MainTex_TexelSize.y;
o.uvUnderlay.x = (o.uvUnderlay.x - 0.5) / aspectScale + 0.5;
}
}
return o;
}
sampler2D _MainTex;
sampler2D _UnderlayTex;
fixed4 frag(v2f i) : SV_Target
{
fixed4 main = tex2D(_MainTex, i.uvMain);
fixed4 underlay = tex2D(_UnderlayTex, i.uvUnderlay);
fixed4 output;
if (i.uvUnderlay.x < 0 || i.uvUnderlay.x > 1 || i.uvUnderlay.y < 0 || i.uvUnderlay.y > 1)
output = main;
else
{
if (underlay.a > 0)
output.rgb = lerp(underlay.rgb, main.rgb, main.a);
else
output.rgb = main;
output.a = 1 - ((1 - main.a)*(1 - underlay.a));
}
return output;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 3ddb549f2327e954b9e89f3dfd58593c
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: db4db75b709c3354081026d8313d7d20
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: