ECM2
This commit is contained in:
287
Assets/RapidIcon/Editor/Scripts/Icons/Icon.cs
Normal file
287
Assets/RapidIcon/Editor/Scripts/Icons/Icon.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/RapidIcon/Editor/Scripts/Icons/Icon.cs.meta
Normal file
11
Assets/RapidIcon/Editor/Scripts/Icons/Icon.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba86e62c257f1bb4685f4f8aac8e5f37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
194
Assets/RapidIcon/Editor/Scripts/Icons/IconSet.cs
Normal file
194
Assets/RapidIcon/Editor/Scripts/Icons/IconSet.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/RapidIcon/Editor/Scripts/Icons/IconSet.cs.meta
Normal file
11
Assets/RapidIcon/Editor/Scripts/Icons/IconSet.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b4bd34b0d48a0e45a62ee32f5ee0805
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/RapidIcon/Editor/Scripts/Icons/IconSetData.cs
Normal file
16
Assets/RapidIcon/Editor/Scripts/Icons/IconSetData.cs
Normal 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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/RapidIcon/Editor/Scripts/Icons/IconSetData.cs.meta
Normal file
11
Assets/RapidIcon/Editor/Scripts/Icons/IconSetData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 386ec4ab5b06b0e4fa8b220121084976
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
121
Assets/RapidIcon/Editor/Scripts/Icons/IconSettings.cs
Normal file
121
Assets/RapidIcon/Editor/Scripts/Icons/IconSettings.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/RapidIcon/Editor/Scripts/Icons/IconSettings.cs.meta
Normal file
11
Assets/RapidIcon/Editor/Scripts/Icons/IconSettings.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d03cd17ccaa51bc4b8894e36f7f888ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user