summaryrefslogtreecommitdiff
path: root/Assets/AmplifyShaderEditor/Plugins/Editor/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/AmplifyShaderEditor/Plugins/Editor/Utils')
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPPSHelperTool.cs460
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPPSHelperTool.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPackageManagerHelper.cs540
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPackageManagerHelper.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEStartScreen.cs495
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEStartScreen.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASETextureArrayCreator.cs686
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASETextureArrayCreator.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomMaterialInspector.cs509
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomMaterialInspector.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomShaderInspector.cs963
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomShaderInspector.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomTexture2DArrayInspector.cs132
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomTexture2DArrayInspector.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/EditorVariablesManager.cs254
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/EditorVariablesManager.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GeneratorUtils.cs1022
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GeneratorUtils.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GenericMessage.cs117
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GenericMessage.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/IOUtils.cs843
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/IOUtils.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InlineProperty.cs320
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InlineProperty.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InvalidDataChecker.cs172
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InvalidDataChecker.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/NodeExporterUtils.cs284
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/NodeExporterUtils.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/Preferences.cs135
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/Preferences.cs.meta11
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/RectExtension.cs40
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/RectExtension.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/SamplerStateAutoGenerator.cs203
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/SamplerStateAutoGenerator.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ShortcutsManager.cs215
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ShortcutsManager.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/TipsWindow.cs148
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/TipsWindow.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UIUtils.cs2839
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UIUtils.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UndoUtils.cs12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UndoUtils.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UpperLeftWidgetHelper.cs91
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UpperLeftWidgetHelper.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowHelper.cs250
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowHelper.cs.meta12
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowsUtil.cs148
-rw-r--r--Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowsUtil.cs.meta12
48 files changed, 0 insertions, 11165 deletions
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPPSHelperTool.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPPSHelperTool.cs
deleted file mode 100644
index e009c04f..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPPSHelperTool.cs
+++ /dev/null
@@ -1,460 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-using System;
-using UnityEngine;
-using UnityEditor;
-using System.Collections.Generic;
-//using UnityEngine.Rendering.PostProcessing;
-
-
-namespace AmplifyShaderEditor
-{
- public enum ASEPostProcessEvent
- {
- BeforeTransparent = 0,
- BeforeStack = 1,
- AfterStack = 2
- }
-
- [Serializable]
- public class ASEPPSHelperBuffer
- {
- public string Name;
- public string Tooltip;
- }
-
- [Serializable]
- public class ASEPPSHelperTool : EditorWindow
- {
- private const string PPSFullTemplate =
- "// Amplify Shader Editor - Visual Shader Editing Tool\n" +
- "// Copyright (c) Amplify Creations, Lda <info@amplify.pt>\n" +
- "#if UNITY_POST_PROCESSING_STACK_V2\n" +
- "using System;\n" +
- "using UnityEngine;\n" +
- "using UnityEngine.Rendering.PostProcessing;\n" +
- "\n" +
- "[Serializable]\n" +
- "[PostProcess( typeof( /*PPSRendererClass*/ ), PostProcessEvent./*PPSEventType*/, \"/*PPSMenuEntry*/\", /*AllowInSceneView*/ )]\n" +
- "public sealed class /*PPSSettingsClass*/ : PostProcessEffectSettings\n" +
- "{\n" +
- "/*PPSPropertiesDeclaration*/" +
- "}\n" +
- "\n" +
- "public sealed class /*PPSRendererClass*/ : PostProcessEffectRenderer</*PPSSettingsClass*/>\n" +
- "{\n" +
- "\tpublic override void Render( PostProcessRenderContext context )\n" +
- "\t{\n" +
- "\t\tvar sheet = context.propertySheets.Get( Shader.Find( \"/*PPSShader*/\" ) );\n" +
- "/*PPSPropertySet*/" +
- "\t\tcontext.command.BlitFullscreenTriangle( context.source, context.destination, sheet, 0 );\n" +
- "\t}\n" +
- "}\n" +
- "#endif\n";
-
- private const string PPSEventType = "/*PPSEventType*/";
- private const string PPSRendererClass = "/*PPSRendererClass*/";
- private const string PPSSettingsClass = "/*PPSSettingsClass*/";
- private const string PPSMenuEntry = "/*PPSMenuEntry*/";
- private const string PPSAllowInSceneView = "/*AllowInSceneView*/";
- private const string PPSShader = "/*PPSShader*/";
- private const string PPSPropertiesDecl = "/*PPSPropertiesDeclaration*/";
- private const string PPSPropertySet = "/*PPSPropertySet*/";
-
- public static readonly string PPSPropertySetFormat = "\t\tsheet.properties.{0}( \"{1}\", settings.{1} );\n";
- public static readonly string PPSPropertySetNullPointerCheckFormat = "\t\tif(settings.{1}.value != null) sheet.properties.{0}( \"{1}\", settings.{1} );\n";
- public static readonly string PPSPropertyDecFormat =
- "\t[{0}Tooltip( \"{1}\" )]\n" +
- "\tpublic {2} {3} = new {2} {{ {4} }};\n";
- public static readonly Dictionary<WirePortDataType, string> WireToPPSType = new Dictionary<WirePortDataType, string>()
- {
- { WirePortDataType.FLOAT,"FloatParameter"},
- { WirePortDataType.FLOAT2,"Vector4Parameter"},
- { WirePortDataType.FLOAT3,"Vector4Parameter"},
- { WirePortDataType.FLOAT4,"Vector4Parameter"},
- { WirePortDataType.COLOR,"ColorParameter"},
- { WirePortDataType.SAMPLER1D,"TextureParameter"},
- { WirePortDataType.SAMPLER2D,"TextureParameter"},
- { WirePortDataType.SAMPLER3D,"TextureParameter"},
- { WirePortDataType.SAMPLERCUBE,"TextureParameter"}
- };
-
- public static readonly Dictionary<WirePortDataType, string> WireToPPSValueSet = new Dictionary<WirePortDataType, string>()
- {
- { WirePortDataType.FLOAT,"SetFloat"},
- { WirePortDataType.FLOAT2,"SetVector"},
- { WirePortDataType.FLOAT3,"SetVector"},
- { WirePortDataType.FLOAT4,"SetVector"},
- { WirePortDataType.COLOR,"SetColor"},
- { WirePortDataType.SAMPLER1D, "SetTexture"},
- { WirePortDataType.SAMPLER2D, "SetTexture"},
- { WirePortDataType.SAMPLER3D, "SetTexture"},
- { WirePortDataType.SAMPLERCUBE,"SetTexture"}
- };
-
- public static readonly Dictionary<UnityEditor.ShaderUtil.ShaderPropertyType, string> ShaderPropertyToPPSType = new Dictionary<UnityEditor.ShaderUtil.ShaderPropertyType, string>()
- {
- { UnityEditor.ShaderUtil.ShaderPropertyType.Float,"FloatParameter"},
- { UnityEditor.ShaderUtil.ShaderPropertyType.Range,"FloatParameter"},
- { UnityEditor.ShaderUtil.ShaderPropertyType.Vector,"Vector4Parameter"},
- { UnityEditor.ShaderUtil.ShaderPropertyType.Color,"ColorParameter"},
- { UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv,"TextureParameter"}
- };
-
-
- public static readonly Dictionary<UnityEditor.ShaderUtil.ShaderPropertyType, string> ShaderPropertyToPPSSet = new Dictionary<UnityEditor.ShaderUtil.ShaderPropertyType, string>()
- {
- { UnityEditor.ShaderUtil.ShaderPropertyType.Float,"SetFloat"},
- { UnityEditor.ShaderUtil.ShaderPropertyType.Range,"SetFloat"},
- { UnityEditor.ShaderUtil.ShaderPropertyType.Vector,"SetVector"},
- { UnityEditor.ShaderUtil.ShaderPropertyType.Color,"SetColor"},
- { UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv,"SetTexture"}
- };
-
- private Dictionary<string, bool> m_excludedProperties = new Dictionary<string, bool>
- {
- { "_texcoord",true },
- { "__dirty",true}
- };
-
- private Material m_dummyMaterial = null;
-
- private DragAndDropTool m_dragAndDropTool;
- private Rect m_draggableArea;
-
- [SerializeField]
- private string m_rendererClassName = "PPSRenderer";
-
- [SerializeField]
- private string m_settingsClassName = "PPSSettings";
-
- [SerializeField]
- private string m_folderPath = "Assets/";
-
- [SerializeField]
- private string m_menuEntry = string.Empty;
-
- [SerializeField]
- private bool m_allowInSceneView = true;
-
- [SerializeField]
- private ASEPostProcessEvent m_eventType = ASEPostProcessEvent.AfterStack;
-
- [SerializeField]
- private Shader m_currentShader = null;
-
- [SerializeField]
- private List<ASEPPSHelperBuffer> m_tooltips = new List<ASEPPSHelperBuffer>();
-
- [SerializeField]
- private bool m_tooltipsFoldout = true;
-
- private GUIStyle m_contentStyle = null;
- private GUIStyle m_pathButtonStyle = null;
- private GUIContent m_pathButtonContent = new GUIContent();
- private Vector2 m_scrollPos = Vector2.zero;
-
- [MenuItem( "Window/Amplify Shader Editor/Post-Processing Stack Tool", false, 1001 )]
- static void ShowWindow()
- {
- ASEPPSHelperTool window = EditorWindow.GetWindow<ASEPPSHelperTool>();
- window.titleContent.text = "Post-Processing Stack Tool";
- window.minSize = new Vector2( 302, 350 );
- window.Show();
- }
-
- void FetchTooltips()
- {
- m_tooltips.Clear();
- int propertyCount = UnityEditor.ShaderUtil.GetPropertyCount( m_currentShader );
- for( int i = 0; i < propertyCount; i++ )
- {
- //UnityEditor.ShaderUtil.ShaderPropertyType type = UnityEditor.ShaderUtil.GetPropertyType( m_currentShader, i );
- string name = UnityEditor.ShaderUtil.GetPropertyName( m_currentShader, i );
- string description = UnityEditor.ShaderUtil.GetPropertyDescription( m_currentShader, i );
-
- if( m_excludedProperties.ContainsKey( name ))
- continue;
-
- m_tooltips.Add( new ASEPPSHelperBuffer { Name = name, Tooltip = description } );
- }
- }
-
- void OnGUI()
- {
- if( m_pathButtonStyle == null )
- m_pathButtonStyle = "minibutton";
-
- m_scrollPos = EditorGUILayout.BeginScrollView( m_scrollPos, GUILayout.Height( position.height ) );
-
- EditorGUILayout.BeginVertical( m_contentStyle );
- EditorGUI.BeginChangeCheck();
- m_currentShader = EditorGUILayout.ObjectField( "Shader", m_currentShader, typeof( Shader ), false ) as Shader;
- if( EditorGUI.EndChangeCheck() )
- {
- GetInitialInfo( m_currentShader );
- }
-
- EditorGUILayout.Separator();
- EditorGUILayout.LabelField( "Path and Filename" );
- EditorGUILayout.BeginHorizontal();
- m_pathButtonContent.text = m_folderPath;
- Vector2 buttonSize = m_pathButtonStyle.CalcSize( m_pathButtonContent );
- if( GUILayout.Button( m_pathButtonContent, m_pathButtonStyle, GUILayout.MaxWidth( Mathf.Min( position.width * 0.5f, buttonSize.x ) ) ) )
- {
- string folderpath = EditorUtility.OpenFolderPanel( "Save Texture Array to folder", "Assets/", "" );
- folderpath = FileUtil.GetProjectRelativePath( folderpath );
- if( string.IsNullOrEmpty( folderpath ) )
- m_folderPath = "Assets/";
- else
- m_folderPath = folderpath + "/";
- }
-
- m_settingsClassName = EditorGUILayout.TextField( m_settingsClassName, GUILayout.ExpandWidth( true ) );
-
- EditorGUILayout.LabelField( ".cs", GUILayout.MaxWidth( 40 ) );
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.Separator();
-
- m_menuEntry = EditorGUILayout.TextField( "Name", m_menuEntry );
-
- EditorGUILayout.Separator();
-
- m_allowInSceneView = EditorGUILayout.Toggle( "Allow In Scene View", m_allowInSceneView );
-
- EditorGUILayout.Separator();
-
- m_eventType = (ASEPostProcessEvent)EditorGUILayout.EnumPopup( "Event Type", m_eventType );
-
- EditorGUILayout.Separator();
-
- m_tooltipsFoldout = EditorGUILayout.Foldout( m_tooltipsFoldout, "Tooltips" );
- if( m_tooltipsFoldout )
- {
- EditorGUI.indentLevel++;
- for( int i = 0; i < m_tooltips.Count; i++ )
- {
- m_tooltips[ i ].Tooltip = EditorGUILayout.TextField( m_tooltips[ i ].Name, m_tooltips[ i ].Tooltip );
- }
- EditorGUI.indentLevel--;
- }
-
- EditorGUILayout.Separator();
-
- if( GUILayout.Button( "Build" ) )
- {
- System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
- string propertiesDecl = string.Empty;
- string propertiesSet = string.Empty;
- GetShaderInfoFromShaderAsset( ref propertiesDecl, ref propertiesSet );
- string template = PPSFullTemplate;
- template = template.Replace( PPSRendererClass, m_rendererClassName );
- template = template.Replace( PPSSettingsClass, m_settingsClassName );
- template = template.Replace( PPSEventType, m_eventType.ToString() );
- template = template.Replace( PPSPropertiesDecl, propertiesDecl );
- template = template.Replace( PPSPropertySet, propertiesSet );
- template = template.Replace( PPSMenuEntry, m_menuEntry );
- template = template.Replace( PPSAllowInSceneView, m_allowInSceneView?"true":"false" );
- template = template.Replace( PPSShader, m_currentShader.name );
- string path = m_folderPath + m_settingsClassName + ".cs";
- IOUtils.SaveTextfileToDisk( template, path, false );
- System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
- AssetDatabase.Refresh();
- }
-
- EditorGUILayout.EndVertical();
- EditorGUILayout.EndScrollView();
- m_draggableArea.size = position.size;
- m_dragAndDropTool.TestDragAndDrop( m_draggableArea );
- }
-
- public void GetShaderInfoFromASE( ref string propertiesDecl, ref string propertiesSet )
- {
- List<PropertyNode> properties = UIUtils.CurrentWindow.OutsideGraph.PropertyNodes.NodesList;
- int propertyCount = properties.Count;
- for( int i = 0; i < propertyCount; i++ )
- {
- properties[ i ].GeneratePPSInfo( ref propertiesDecl, ref propertiesSet );
- }
- }
-
- public void GetShaderInfoFromShaderAsset( ref string propertiesDecl, ref string propertiesSet )
- {
- bool fetchInitialInfo = false;
- if( m_currentShader == null )
- {
- Material mat = Selection.activeObject as Material;
- if( mat != null )
- {
- m_currentShader = mat.shader;
- }
- else
- {
- m_currentShader = Selection.activeObject as Shader;
- }
- fetchInitialInfo = true;
- }
-
- if( m_currentShader != null )
- {
- if( fetchInitialInfo )
- GetInitialInfo( m_currentShader );
-
- if( m_dummyMaterial == null )
- {
- m_dummyMaterial = new Material( m_currentShader );
- }
- else
- {
- m_dummyMaterial.shader = m_currentShader;
- }
-
- int propertyCount = UnityEditor.ShaderUtil.GetPropertyCount( m_currentShader );
- //string allProperties = string.Empty;
- int validIds = 0;
- for( int i = 0; i < propertyCount; i++ )
- {
- UnityEditor.ShaderUtil.ShaderPropertyType type = UnityEditor.ShaderUtil.GetPropertyType( m_currentShader, i );
- string name = UnityEditor.ShaderUtil.GetPropertyName( m_currentShader, i );
- //string description = UnityEditor.ShaderUtil.GetPropertyDescription( m_currentShader, i );
- if( m_excludedProperties.ContainsKey( name ))
- continue;
-
- string defaultValue = string.Empty;
- bool nullPointerCheck = false;
- switch( type )
- {
- case UnityEditor.ShaderUtil.ShaderPropertyType.Color:
- {
- Color value = m_dummyMaterial.GetColor( name );
- defaultValue = string.Format( "value = new Color({0}f,{1}f,{2}f,{3}f)", value.r, value.g, value.b, value.a );
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.Vector:
- {
- Vector4 value = m_dummyMaterial.GetVector( name );
- defaultValue = string.Format( "value = new Vector4({0}f,{1}f,{2}f,{3}f)", value.x, value.y, value.z, value.w );
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.Float:
- {
- float value = m_dummyMaterial.GetFloat( name );
- defaultValue = "value = " + value + "f";
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.Range:
- {
- float value = m_dummyMaterial.GetFloat( name );
- defaultValue = "value = " + value + "f";
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv:
- {
- nullPointerCheck = true;
- }
- break;
- }
-
- propertiesDecl += string.Format( PPSPropertyDecFormat, string.Empty, m_tooltips[ validIds ].Tooltip, ShaderPropertyToPPSType[ type ], name, defaultValue );
- propertiesSet += string.Format( nullPointerCheck ? PPSPropertySetNullPointerCheckFormat : PPSPropertySetFormat, ShaderPropertyToPPSSet[ type ], name );
- validIds++;
- }
-
- }
- }
-
- private void GetInitialInfo()
- {
- MasterNode masterNode = UIUtils.CurrentWindow.OutsideGraph.CurrentMasterNode;
- m_menuEntry = masterNode.ShaderName.Replace( "Hidden/", string.Empty ).Replace( ".shader", string.Empty );
- string name = m_menuEntry;
- m_rendererClassName = name + "PPSRenderer";
- m_settingsClassName = name + "PPSSettings";
- m_folderPath = "Assets/";
- }
-
- private void GetInitialInfo( Shader shader )
- {
- if( shader == null )
- {
- m_scrollPos = Vector2.zero;
- m_menuEntry = string.Empty;
- m_rendererClassName = "PPSRenderer";
- m_settingsClassName = "PPSSettings";
- m_folderPath = "Assets/";
- m_tooltips.Clear();
- return;
- }
-
- m_menuEntry = shader.name.Replace( "Hidden/", string.Empty ).Replace( ".shader", string.Empty );
- m_menuEntry = UIUtils.RemoveInvalidCharacters( m_menuEntry );
- string name = m_menuEntry.Replace( "/", string.Empty );
- m_rendererClassName = name + "PPSRenderer";
- m_settingsClassName = name + "PPSSettings";
- m_folderPath = AssetDatabase.GetAssetPath( shader );
- m_folderPath = m_folderPath.Replace( System.IO.Path.GetFileName( m_folderPath ), string.Empty );
-
- FetchTooltips();
- }
-
- public void OnValidObjectsDropped( UnityEngine.Object[] droppedObjs )
- {
- for( int objIdx = 0; objIdx < droppedObjs.Length; objIdx++ )
- {
- Material mat = droppedObjs[ objIdx ] as Material;
- if( mat != null )
- {
- m_currentShader = mat.shader;
- GetInitialInfo( mat.shader );
- return;
- }
- else
- {
- Shader shader = droppedObjs[ objIdx ] as Shader;
- if( shader != null )
- {
- m_currentShader = shader;
- GetInitialInfo( shader );
- return;
- }
- }
- }
- }
-
- private void OnEnable()
- {
- m_draggableArea = new Rect( 0, 0, 1, 1 );
- m_dragAndDropTool = new DragAndDropTool();
- m_dragAndDropTool.OnValidDropObjectEvt += OnValidObjectsDropped;
-
- if( m_contentStyle == null )
- {
- m_contentStyle = new GUIStyle( GUIStyle.none );
- m_contentStyle.margin = new RectOffset( 6, 4, 5, 5 );
- }
-
- m_pathButtonStyle = null;
-
- //GetInitialInfo();
- }
-
- private void OnDestroy()
- {
- if( m_dummyMaterial != null )
- {
- GameObject.DestroyImmediate( m_dummyMaterial );
- m_dummyMaterial = null;
- }
-
- m_dragAndDropTool.Destroy();
- m_dragAndDropTool = null;
-
- m_tooltips.Clear();
- m_tooltips = null;
-
- m_contentStyle = null;
- m_pathButtonStyle = null;
- m_currentShader = null;
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPPSHelperTool.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPPSHelperTool.cs.meta
deleted file mode 100644
index 581a6221..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPPSHelperTool.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: ccaa3765dae023d4b8657544c1aeef4a
-timeCreated: 1550254201
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPackageManagerHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPackageManagerHelper.cs
deleted file mode 100644
index 9336c150..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPackageManagerHelper.cs
+++ /dev/null
@@ -1,540 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-#if UNITY_2018_3_OR_NEWER
-using System;
-using UnityEngine;
-using UnityEditor;
-using UnityEditor.PackageManager.Requests;
-using System.Collections.Generic;
-using System.IO;
-using System.Reflection;
-
-namespace AmplifyShaderEditor
-{
- public enum ASESRPVersions
- {
- ASE_SRP_3_0_0 = 030000,
- ASE_SRP_3_1_0 = 030100,
- ASE_SRP_3_3_0 = 030300,
- ASE_SRP_4_1_0 = 040100,
- ASE_SRP_4_2_0 = 040200,
- ASE_SRP_4_3_0 = 040300,
- ASE_SRP_4_6_0 = 040600,
- ASE_SRP_4_8_0 = 040800,
- ASE_SRP_4_9_0 = 040900,
- ASE_SRP_4_10_0 = 041000,
- ASE_SRP_5_7_2 = 050702,
- ASE_SRP_5_8_2 = 050802,
- ASE_SRP_5_9_0 = 050900,
- ASE_SRP_5_10_0 = 051000,
- ASE_SRP_5_13_0 = 051300,
- ASE_SRP_5_16_1 = 051601,
- ASE_SRP_6_9_0 = 060900,
- ASE_SRP_6_9_1 = 060901,
- ASE_SRP_6_9_2 = 060902,
- ASE_SRP_7_0_1 = 070001,
- ASE_SRP_7_1_1 = 070101,
- ASE_SRP_7_1_2 = 070102,
- ASE_SRP_7_1_5 = 070105,
- ASE_SRP_7_1_6 = 070106,
- ASE_SRP_7_1_7 = 070107,
- ASE_SRP_7_1_8 = 070108,
- ASE_SRP_7_2_0 = 070200,
- ASE_SRP_7_2_1 = 070201,
- ASE_SRP_RECENT = 999999
- }
-
- public enum ASEImportState
- {
- None,
- Lightweight,
- HD,
- Both
- }
-
- public static class AssetDatabaseEX
- {
- private static System.Type type = null;
- public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEditor.AssetDatabase, UnityEditor" ) : type; } }
-
- public static void ImportPackageImmediately( string packagePath )
- {
- AssetDatabaseEX.Type.InvokeMember( "ImportPackageImmediately", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { packagePath } );
- }
- }
-
-
- [Serializable]
- public static class ASEPackageManagerHelper
- {
- private static string LightweightNewVersionDetected = "A new Lighweight RP version was detected and new templates are being imported.\n" +
- "Please hit the Update button on your ASE canvas to recompile your shader under the newest version.";
-
- private static string HDNewVersionDetected = "A new HD RP version was detected and new templates are being imported.\n" +
- "Please hit the Update button on your ASE canvas to recompile your shader under the newest version.";
-
- private static string HDPackageId = "com.unity.render-pipelines.high-definition";
- private static string LWPackageId = "com.unity.render-pipelines.lightweight";
- private static string UniversalPackageId = "com.unity.render-pipelines.universal";
- private static string HDEditorPrefsId = "ASEHDEditorPrefsId";
- private static string LWEditorPrefsId = "ASELightweigthEditorPrefsId ";
-
- private static string URPTemplateVersion = "ASEURPtemplate" + Application.productName;
- private static string HDRPTemplateVersion = "ASEHDRPtemplate" + Application.productName;
-
- private static string SPKeywordFormat = "ASE_SRP_VERSION {0}";
- private static ListRequest m_packageListRequest = null;
- private static UnityEditor.PackageManager.PackageInfo m_lwPackageInfo;
- private static UnityEditor.PackageManager.PackageInfo m_hdPackageInfo;
-
- // V4.8.0 and bellow
- // HD
- private static readonly string[] GetNormalWSFunc =
- {
- "inline void GetNormalWS( FragInputs input, float3 normalTS, out float3 normalWS, float3 doubleSidedConstants )\n",
- "{\n",
- "\tGetNormalWS( input, normalTS, normalWS );\n",
- "}\n"
- };
-
- // v4.6.0 and below
- private static readonly string[] BuildWordTangentFunc =
- {
- "float3x3 BuildWorldToTangent(float4 tangentWS, float3 normalWS)\n",
- "{\n",
- "\tfloat3 unnormalizedNormalWS = normalWS;\n",
- "\tfloat renormFactor = 1.0 / length(unnormalizedNormalWS);\n",
- "\tfloat3x3 worldToTangent = CreateWorldToTangent(unnormalizedNormalWS, tangentWS.xyz, tangentWS.w > 0.0 ? 1.0 : -1.0);\n",
- "\tworldToTangent[0] = worldToTangent[0] * renormFactor;\n",
- "\tworldToTangent[1] = worldToTangent[1] * renormFactor;\n",
- "\tworldToTangent[2] = worldToTangent[2] * renormFactor;\n",
- "\treturn worldToTangent;\n",
- "}\n"
- };
-
- private static bool m_requireUpdateList = false;
- private static ASEImportState m_importingPackage = ASEImportState.None;
-
-
- private static ASESRPVersions m_currentHDVersion = ASESRPVersions.ASE_SRP_RECENT;
- private static ASESRPVersions m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT;
-
- private static int m_urpTemplateVersion = 4;
- private static int m_hdrpTemplateVersion = 3;
-
- private static Dictionary<string, ASESRPVersions> m_srpVersionConverter = new Dictionary<string, ASESRPVersions>()
- {
- {"3.0.0-preview", ASESRPVersions.ASE_SRP_3_0_0},
- {"3.1.0-preview", ASESRPVersions.ASE_SRP_3_1_0},
- {"3.3.0-preview", ASESRPVersions.ASE_SRP_3_3_0},
- {"4.1.0-preview", ASESRPVersions.ASE_SRP_4_1_0},
- {"4.2.0-preview", ASESRPVersions.ASE_SRP_4_2_0},
- {"4.3.0-preview", ASESRPVersions.ASE_SRP_4_3_0},
- {"4.6.0-preview", ASESRPVersions.ASE_SRP_4_6_0},
- {"4.8.0-preview", ASESRPVersions.ASE_SRP_4_8_0},
- {"4.9.0-preview", ASESRPVersions.ASE_SRP_4_9_0},
- {"4.10.0-preview", ASESRPVersions.ASE_SRP_4_10_0},
- {"5.7.2-preview", ASESRPVersions.ASE_SRP_5_7_2},
- {"5.7.2", ASESRPVersions.ASE_SRP_5_7_2},
- {"5.8.2-preview", ASESRPVersions.ASE_SRP_5_8_2},
- {"5.8.2", ASESRPVersions.ASE_SRP_5_8_2},
- {"5.9.0-preview", ASESRPVersions.ASE_SRP_5_9_0},
- {"5.9.0", ASESRPVersions.ASE_SRP_5_9_0},
- {"5.10.0-preview", ASESRPVersions.ASE_SRP_5_10_0},
- {"5.10.0", ASESRPVersions.ASE_SRP_5_10_0},
- {"5.13.0-preview", ASESRPVersions.ASE_SRP_5_13_0},
- {"5.13.0", ASESRPVersions.ASE_SRP_5_13_0},
- {"5.16.1-preview", ASESRPVersions.ASE_SRP_5_16_1},
- {"5.16.1", ASESRPVersions.ASE_SRP_5_16_1},
- {"6.9.0", ASESRPVersions.ASE_SRP_6_9_0},
- {"6.9.0-preview", ASESRPVersions.ASE_SRP_6_9_0},
- {"6.9.1", ASESRPVersions.ASE_SRP_6_9_1},
- {"6.9.1-preview", ASESRPVersions.ASE_SRP_6_9_1},
- {"6.9.2", ASESRPVersions.ASE_SRP_6_9_2},
- {"6.9.2-preview", ASESRPVersions.ASE_SRP_6_9_2},
- {"7.0.1", ASESRPVersions.ASE_SRP_7_0_1},
- {"7.0.1-preview", ASESRPVersions.ASE_SRP_7_0_1},
- {"7.1.1", ASESRPVersions.ASE_SRP_7_1_1},
- {"7.1.1-preview", ASESRPVersions.ASE_SRP_7_1_1},
- {"7.1.2", ASESRPVersions.ASE_SRP_7_1_2},
- {"7.1.2-preview", ASESRPVersions.ASE_SRP_7_1_2},
- {"7.1.5", ASESRPVersions.ASE_SRP_7_1_5},
- {"7.1.5-preview", ASESRPVersions.ASE_SRP_7_1_5},
- {"7.1.6", ASESRPVersions.ASE_SRP_7_1_6},
- {"7.1.6-preview", ASESRPVersions.ASE_SRP_7_1_6},
- {"7.1.7", ASESRPVersions.ASE_SRP_7_1_7},
- {"7.1.7-preview", ASESRPVersions.ASE_SRP_7_1_7},
- {"7.1.8", ASESRPVersions.ASE_SRP_7_1_8},
- {"7.1.8-preview", ASESRPVersions.ASE_SRP_7_1_8},
- {"7.2.0", ASESRPVersions.ASE_SRP_7_2_0},
- {"7.2.0-preview", ASESRPVersions.ASE_SRP_7_2_0},
- {"7.2.1", ASESRPVersions.ASE_SRP_7_2_1},
- {"7.2.1-preview", ASESRPVersions.ASE_SRP_7_2_1},
- };
-
-
-
- private static Dictionary<ASESRPVersions, string> m_srpToASEPackageLW = new Dictionary<ASESRPVersions, string>()
- {
- {ASESRPVersions.ASE_SRP_3_0_0, "b53d2f3b156ff104f90d4d7693d769c8"},
- {ASESRPVersions.ASE_SRP_3_1_0, "b53d2f3b156ff104f90d4d7693d769c8"},
- {ASESRPVersions.ASE_SRP_3_3_0, "b53d2f3b156ff104f90d4d7693d769c8"},
- {ASESRPVersions.ASE_SRP_4_1_0, "3e8eabcfae1e5aa4397de89fedeb48db"},
- {ASESRPVersions.ASE_SRP_4_2_0, "3e8eabcfae1e5aa4397de89fedeb48db"},
- {ASESRPVersions.ASE_SRP_4_3_0, "3e8eabcfae1e5aa4397de89fedeb48db"},
- {ASESRPVersions.ASE_SRP_4_6_0, "3e8eabcfae1e5aa4397de89fedeb48db"},
- {ASESRPVersions.ASE_SRP_4_8_0, "3e8eabcfae1e5aa4397de89fedeb48db"},
- {ASESRPVersions.ASE_SRP_4_9_0, "3e8eabcfae1e5aa4397de89fedeb48db"},
- {ASESRPVersions.ASE_SRP_4_10_0, "3e8eabcfae1e5aa4397de89fedeb48db"},
- {ASESRPVersions.ASE_SRP_5_7_2, "4c816894a3147d343891060451241bfe"},
- {ASESRPVersions.ASE_SRP_5_8_2, "4c816894a3147d343891060451241bfe"},
- {ASESRPVersions.ASE_SRP_5_9_0, "4c816894a3147d343891060451241bfe"},
- {ASESRPVersions.ASE_SRP_5_10_0, "4c816894a3147d343891060451241bfe"},
- {ASESRPVersions.ASE_SRP_5_13_0, "4c816894a3147d343891060451241bfe"},
- {ASESRPVersions.ASE_SRP_5_16_1, "4c816894a3147d343891060451241bfe"},
- {ASESRPVersions.ASE_SRP_6_9_0, "4c816894a3147d343891060451241bfe"},
- {ASESRPVersions.ASE_SRP_6_9_1, "4c816894a3147d343891060451241bfe"},
- {ASESRPVersions.ASE_SRP_6_9_2, "4c816894a3147d343891060451241bfe"},
- {ASESRPVersions.ASE_SRP_7_0_1, "57fcea0ed8b5eb347923c4c21fa31b57"},
- {ASESRPVersions.ASE_SRP_7_1_1, "57fcea0ed8b5eb347923c4c21fa31b57"},
- {ASESRPVersions.ASE_SRP_7_1_2, "57fcea0ed8b5eb347923c4c21fa31b57"},
- {ASESRPVersions.ASE_SRP_7_1_5, "57fcea0ed8b5eb347923c4c21fa31b57"},
- {ASESRPVersions.ASE_SRP_7_1_6, "57fcea0ed8b5eb347923c4c21fa31b57"},
- {ASESRPVersions.ASE_SRP_7_1_7, "57fcea0ed8b5eb347923c4c21fa31b57"},
- {ASESRPVersions.ASE_SRP_7_1_8, "57fcea0ed8b5eb347923c4c21fa31b57"},
- {ASESRPVersions.ASE_SRP_7_2_0, "57fcea0ed8b5eb347923c4c21fa31b57"},
- {ASESRPVersions.ASE_SRP_7_2_1, "57fcea0ed8b5eb347923c4c21fa31b57"},
- {ASESRPVersions.ASE_SRP_RECENT, "57fcea0ed8b5eb347923c4c21fa31b57"}
- };
-
- private static Dictionary<ASESRPVersions, string> m_srpToASEPackageHD = new Dictionary<ASESRPVersions, string>()
- {
- {ASESRPVersions.ASE_SRP_3_0_0, "4dc1afbcc68875c4780502f5e6b80158"},
- {ASESRPVersions.ASE_SRP_3_1_0, "4dc1afbcc68875c4780502f5e6b80158"},
- {ASESRPVersions.ASE_SRP_3_3_0, "4dc1afbcc68875c4780502f5e6b80158"},
- {ASESRPVersions.ASE_SRP_4_1_0, "5d615bf612f33364e96fb9fd2959ae9c"},
- {ASESRPVersions.ASE_SRP_4_2_0, "5d615bf612f33364e96fb9fd2959ae9c"},
- {ASESRPVersions.ASE_SRP_4_3_0, "5d615bf612f33364e96fb9fd2959ae9c"},
- {ASESRPVersions.ASE_SRP_4_6_0, "5d615bf612f33364e96fb9fd2959ae9c"},
- {ASESRPVersions.ASE_SRP_4_8_0, "5d615bf612f33364e96fb9fd2959ae9c"},
- {ASESRPVersions.ASE_SRP_4_9_0, "5d615bf612f33364e96fb9fd2959ae9c"},
- {ASESRPVersions.ASE_SRP_4_10_0, "5d615bf612f33364e96fb9fd2959ae9c"},
- {ASESRPVersions.ASE_SRP_5_7_2, "f51b7b861facbc3429fcc5f1f6f91183"},
- {ASESRPVersions.ASE_SRP_5_8_2, "2d7fe4f7c19e90f41b893bc01fc17230"},
- {ASESRPVersions.ASE_SRP_5_9_0, "2d7fe4f7c19e90f41b893bc01fc17230"},
- {ASESRPVersions.ASE_SRP_5_10_0, "2d7fe4f7c19e90f41b893bc01fc17230"},
- {ASESRPVersions.ASE_SRP_5_13_0, "2d7fe4f7c19e90f41b893bc01fc17230"},
- {ASESRPVersions.ASE_SRP_5_16_1, "2d7fe4f7c19e90f41b893bc01fc17230"},
- {ASESRPVersions.ASE_SRP_6_9_0, "e137dba02f4d0f542ab09dcedea27314"},
- {ASESRPVersions.ASE_SRP_6_9_1, "e137dba02f4d0f542ab09dcedea27314"},
- {ASESRPVersions.ASE_SRP_6_9_2, "e137dba02f4d0f542ab09dcedea27314"},
- {ASESRPVersions.ASE_SRP_7_0_1, "e137dba02f4d0f542ab09dcedea27314"},
- {ASESRPVersions.ASE_SRP_7_1_1, "e137dba02f4d0f542ab09dcedea27314"},
- {ASESRPVersions.ASE_SRP_7_1_2, "e137dba02f4d0f542ab09dcedea27314"},
- {ASESRPVersions.ASE_SRP_7_1_5, "e137dba02f4d0f542ab09dcedea27314"},
- {ASESRPVersions.ASE_SRP_7_1_6, "e137dba02f4d0f542ab09dcedea27314"},
- {ASESRPVersions.ASE_SRP_7_1_7, "e137dba02f4d0f542ab09dcedea27314"},
- {ASESRPVersions.ASE_SRP_7_1_8, "9a5e61a8b3421b944863d0946e32da0a"},
- {ASESRPVersions.ASE_SRP_7_2_0, "9a5e61a8b3421b944863d0946e32da0a"},
- {ASESRPVersions.ASE_SRP_7_2_1, "9a5e61a8b3421b944863d0946e32da0a"},
- {ASESRPVersions.ASE_SRP_RECENT, "9a5e61a8b3421b944863d0946e32da0a"}
- };
-
- private static Shader m_lateShader;
- private static Material m_lateMaterial;
- private static AmplifyShaderFunction m_lateShaderFunction;
-
-
- public static void RequestInfo()
- {
- if( !m_requireUpdateList && m_importingPackage == ASEImportState.None )
- {
- m_requireUpdateList = true;
- m_packageListRequest = UnityEditor.PackageManager.Client.List( true );
- }
- }
-
- static void FailedPackageImport( string packageName, string errorMessage )
- {
- FinishImporter();
- }
-
- static void CancelledPackageImport( string packageName )
- {
- FinishImporter();
- }
-
- static void CompletedPackageImport( string packageName )
- {
- FinishImporter();
- }
-
- public static void StartImporting( string packagePath )
- {
- if( !Preferences.GlobalAutoSRP )
- {
- m_importingPackage = ASEImportState.None;
- return;
- }
- AssetDatabase.importPackageCancelled += CancelledPackageImport;
- AssetDatabase.importPackageCompleted += CompletedPackageImport;
- AssetDatabase.importPackageFailed += FailedPackageImport;
- AssetDatabase.ImportPackage( packagePath, false );
- //AssetDatabaseEX.ImportPackageImmediately( packagePath );
- }
-
- public static void FinishImporter()
- {
- m_importingPackage = ASEImportState.None;
- AssetDatabase.importPackageCancelled -= CancelledPackageImport;
- AssetDatabase.importPackageCompleted -= CompletedPackageImport;
- AssetDatabase.importPackageFailed -= FailedPackageImport;
- }
-
- public static void SetupLateShader( Shader shader )
- {
- RequestInfo();
- m_lateShader = shader;
- EditorApplication.delayCall += LateShaderOpener;
- }
-
- public static void LateShaderOpener()
- {
- Preferences.LoadDefaults();
- Update();
- if( IsProcessing )
- {
- EditorApplication.delayCall += LateShaderOpener;
- }
- else
- {
- AmplifyShaderEditorWindow.ConvertShaderToASE( m_lateShader );
- m_lateShader = null;
- }
- }
-
- public static void SetupLateMaterial( Material material )
- {
- RequestInfo();
- m_lateMaterial = material;
- EditorApplication.delayCall += LateMaterialOpener;
- }
-
- public static void LateMaterialOpener()
- {
- Preferences.LoadDefaults();
- Update();
- if( IsProcessing )
- {
- EditorApplication.delayCall += LateMaterialOpener;
- }
- else
- {
- AmplifyShaderEditorWindow.LoadMaterialToASE( m_lateMaterial );
- m_lateMaterial = null;
- }
- }
-
- public static void SetupLateShaderFunction( AmplifyShaderFunction shaderFunction )
- {
- RequestInfo();
- m_lateShaderFunction = shaderFunction;
- EditorApplication.delayCall += LateShaderFunctionOpener;
- }
-
- public static void LateShaderFunctionOpener()
- {
- Preferences.LoadDefaults();
- Update();
- if( IsProcessing )
- {
- EditorApplication.delayCall += LateShaderFunctionOpener;
- }
- else
- {
- AmplifyShaderEditorWindow.LoadShaderFunctionToASE( m_lateShaderFunction, false );
- m_lateShaderFunction = null;
- }
- }
-
- public static void Update()
- {
- //if( m_lwPackageInfo != null )
- //{
- // if( m_srpVersionConverter[ m_lwPackageInfo.version ] != m_currentLWVersion )
- // {
- // m_currentLWVersion = m_srpVersionConverter[ m_lwPackageInfo.version ];
- // EditorPrefs.SetInt( LWEditorPrefsId, (int)m_currentLWVersion );
- // m_importingPackage = ASEImportState.Lightweight;
- // string packagePath = AssetDatabase.GUIDToAssetPath( m_srpToASEPackageLW[ m_currentLWVersion ] );
- // StartImporting( packagePath );
- // }
- //}
-
- //if( m_hdPackageInfo != null )
- //{
- // if( m_srpVersionConverter[ m_hdPackageInfo.version ] != m_currentHDVersion )
- // {
- // m_currentHDVersion = m_srpVersionConverter[ m_hdPackageInfo.version ];
- // EditorPrefs.SetInt( HDEditorPrefsId, (int)m_currentHDVersion );
- // m_importingPackage = ASEImportState.HD;
- // string packagePath = AssetDatabase.GUIDToAssetPath( m_srpToASEPackageHD[ m_currentHDVersion ] );
- // StartImporting( packagePath );
- // }
- //}
-
- if( m_requireUpdateList && m_importingPackage == ASEImportState.None )
- {
- if( m_packageListRequest != null && m_packageListRequest.IsCompleted )
- {
- m_requireUpdateList = false;
- foreach( UnityEditor.PackageManager.PackageInfo pi in m_packageListRequest.Result )
- {
- if( pi.name.Equals( LWPackageId ) )
- {
- m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT;
- m_lwPackageInfo = pi;
- ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt( LWEditorPrefsId );
- if( m_srpVersionConverter.ContainsKey( pi.version ) )
- {
- m_currentLWVersion = m_srpVersionConverter[ pi.version ];
- }
- else
- {
- m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT;
- }
-
- EditorPrefs.SetInt( LWEditorPrefsId, (int)m_currentLWVersion );
- bool foundNewVersion = oldVersion != m_currentLWVersion;
- if( !File.Exists( AssetDatabase.GUIDToAssetPath( TemplatesManager.LightweigthPBRGUID ) ) ||
- !File.Exists( AssetDatabase.GUIDToAssetPath( TemplatesManager.LightweigthUnlitGUID ) ) ||
- foundNewVersion
- )
- {
- if( foundNewVersion )
- Debug.Log( LightweightNewVersionDetected );
-
- m_importingPackage = ASEImportState.Lightweight;
- string guid = m_srpToASEPackageLW.ContainsKey( m_currentLWVersion ) ? m_srpToASEPackageLW[ m_currentLWVersion ] : m_srpToASEPackageLW[ ASESRPVersions.ASE_SRP_RECENT ];
- string packagePath = AssetDatabase.GUIDToAssetPath( guid );
- StartImporting( packagePath );
- }
- }
-
- if( pi.name.Equals( UniversalPackageId ) )
- {
- m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT;
- m_lwPackageInfo = pi;
- ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt( LWEditorPrefsId );
- if( m_srpVersionConverter.ContainsKey( pi.version ) )
- {
- m_currentLWVersion = m_srpVersionConverter[ pi.version ];
- }
- else
- {
- m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT;
- }
-
- EditorPrefs.SetInt( LWEditorPrefsId, (int)m_currentLWVersion );
- bool foundNewVersion = oldVersion != m_currentLWVersion;
-
- int urpVersion = EditorPrefs.GetInt( URPTemplateVersion, m_urpTemplateVersion );
- if( urpVersion < m_urpTemplateVersion )
- foundNewVersion = true;
- EditorPrefs.SetInt( URPTemplateVersion, m_urpTemplateVersion );
-
- if( !File.Exists( AssetDatabase.GUIDToAssetPath( TemplatesManager.UniversalPBRGUID ) ) ||
- !File.Exists( AssetDatabase.GUIDToAssetPath( TemplatesManager.UniversalUnlitGUID ) ) ||
- foundNewVersion
- )
- {
- if( foundNewVersion )
- Debug.Log( LightweightNewVersionDetected );
-
- m_importingPackage = ASEImportState.Lightweight;
- string guid = m_srpToASEPackageLW.ContainsKey( m_currentLWVersion ) ? m_srpToASEPackageLW[ m_currentLWVersion ] : m_srpToASEPackageLW[ ASESRPVersions.ASE_SRP_RECENT ];
- string packagePath = AssetDatabase.GUIDToAssetPath( guid );
- StartImporting( packagePath );
- }
-
- }
-
- if( pi.name.Equals( HDPackageId ) )
- {
- m_currentHDVersion = ASESRPVersions.ASE_SRP_RECENT;
- m_hdPackageInfo = pi;
- ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt( HDEditorPrefsId );
- if( m_srpVersionConverter.ContainsKey( pi.version ) )
- {
- m_currentHDVersion = m_srpVersionConverter[ pi.version ];
- }
- else
- {
- m_currentHDVersion = ASESRPVersions.ASE_SRP_RECENT;
- }
-
- EditorPrefs.SetInt( HDEditorPrefsId, (int)m_currentHDVersion );
- bool foundNewVersion = oldVersion != m_currentHDVersion;
-
- int hdrpVersion = EditorPrefs.GetInt( HDRPTemplateVersion, m_hdrpTemplateVersion );
- if( hdrpVersion < m_hdrpTemplateVersion )
- foundNewVersion = true;
- EditorPrefs.SetInt( HDRPTemplateVersion, m_hdrpTemplateVersion );
-
-#if UNITY_2019_3_OR_NEWER
- if( !File.Exists( AssetDatabase.GUIDToAssetPath( TemplatesManager.HDNewLitGUID ) ) ||
- !File.Exists( AssetDatabase.GUIDToAssetPath( TemplatesManager.HDNewPBRGUID ) ) ||
- !File.Exists( AssetDatabase.GUIDToAssetPath( TemplatesManager.HDNewUnlitGUID ) ) ||
-#else
- if( !File.Exists( AssetDatabase.GUIDToAssetPath( TemplatesManager.HDLitGUID ) ) ||
- !File.Exists( AssetDatabase.GUIDToAssetPath( TemplatesManager.HDPBRGUID ) ) ||
- !File.Exists( AssetDatabase.GUIDToAssetPath( TemplatesManager.HDUnlitGUID ) ) ||
-#endif
- foundNewVersion
- )
- {
- if( foundNewVersion )
- Debug.Log( HDNewVersionDetected );
-
- m_importingPackage = m_importingPackage == ASEImportState.Lightweight ? ASEImportState.Both : ASEImportState.HD;
- string guid = m_srpToASEPackageHD.ContainsKey( m_currentHDVersion ) ? m_srpToASEPackageHD[ m_currentHDVersion ] : m_srpToASEPackageHD[ ASESRPVersions.ASE_SRP_RECENT ];
- string packagePath = AssetDatabase.GUIDToAssetPath( guid );
- StartImporting( packagePath );
- }
-
- }
- }
- }
- }
- }
-
- public static void SetSRPInfoOnDataCollector( ref MasterNodeDataCollector dataCollector )
- {
- Preferences.LoadDefaults();
- if( m_requireUpdateList )
- Update();
-
- if( dataCollector.CurrentSRPType == TemplateSRPType.HD )
- {
- dataCollector.AddToDirectives( string.Format( SPKeywordFormat, (int)m_currentHDVersion ) ,-1, AdditionalLineType.Define );
- if( m_currentHDVersion < ASESRPVersions.ASE_SRP_4_9_0 )
- {
- dataCollector.AddFunction( GetNormalWSFunc[ 0 ], GetNormalWSFunc, false );
- }
-
- if( m_currentHDVersion < ASESRPVersions.ASE_SRP_4_8_0 )
- {
- dataCollector.AddFunction( BuildWordTangentFunc[ 0 ], BuildWordTangentFunc, false );
- }
- }
-
- if( dataCollector.CurrentSRPType == TemplateSRPType.Lightweight )
- dataCollector.AddToDirectives( string.Format( SPKeywordFormat, (int)m_currentLWVersion ), -1, AdditionalLineType.Define );
- }
- public static ASESRPVersions CurrentHDVersion { get { return m_currentHDVersion; } }
- public static ASESRPVersions CurrentLWVersion { get { return m_currentLWVersion; } }
- public static bool CheckImporter { get { return m_importingPackage != ASEImportState.None; } }
- public static bool IsProcessing { get { return m_requireUpdateList && m_importingPackage == ASEImportState.None; } }
- }
-}
-#endif
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPackageManagerHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPackageManagerHelper.cs.meta
deleted file mode 100644
index 67f628aa..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEPackageManagerHelper.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: f48de3e34ed250945ba8c16d98b8ca0e
-timeCreated: 1548881060
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEStartScreen.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEStartScreen.cs
deleted file mode 100644
index c11cf8ba..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEStartScreen.cs
+++ /dev/null
@@ -1,495 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using UnityEngine;
-using UnityEditor;
-using System;
-using UnityEngine.Networking;
-using System.Collections;
-
-namespace AmplifyShaderEditor
-{
- public class ASEStartScreen : EditorWindow
- {
- [MenuItem( "Window/Amplify Shader Editor/Start Screen", false, 1999 )]
- public static void Init()
- {
- ASEStartScreen window = (ASEStartScreen)GetWindow( typeof( ASEStartScreen ), true, "Amplify Shader Editor Start Screen" );
- window.minSize = new Vector2( 650, 500 );
- window.maxSize = new Vector2( 650, 500 );
- window.Show();
- }
-
- private static readonly string ChangeLogGUID = "580cccd3e608b7f4cac35ea46d62d429";
- private static readonly string ResourcesGUID = "c0a0a980c9ba86345bc15411db88d34f";
- private static readonly string BuiltInGUID = "e00e6f90ab8233e46a41c5e33917c642";
- private static readonly string UniversalGUID = "a9d68dd8913f05d4d9ce75e7b40c6044";
- private static readonly string HighDefinitionGUID = "d1c0b77896049554fa4b635531caf741";
- private static readonly string OLDHighDefinitionGUID = "dff05fea7446d7b4e9029bfab77455d2";
- private static readonly string LightWeightGUID = "6ecbfd0a046659943a69328c98ff0442";
- private static readonly string OLDLightWeightGUID = "f7c4e22642de60d448f4e4809190f7b1";
-
- private static readonly string IconGUID = "2c6536772776dd84f872779990273bfc";
-
- public static readonly string ChangelogURL = "http://amplify.pt/Banner/ASEchangelog.json";
-
- private static readonly string ManualURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Manual";
- private static readonly string BasicURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Tutorials#Official_-_Basics";
- private static readonly string BeginnerURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Tutorials#Official_-_Beginner_Series";
- private static readonly string NodesURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Nodes";
- private static readonly string SRPURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Scriptable_Rendering_Pipeline";
- private static readonly string FunctionsURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Manual#Shader_Functions";
- private static readonly string TemplatesURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Templates";
- private static readonly string APIURL = "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/API";
-
- private static readonly string DiscordURL = "https://discordapp.com/invite/EdrVAP5";
- private static readonly string ForumURL = "https://forum.unity.com/threads/best-tool-asset-store-award-amplify-shader-editor-node-based-shader-creation-tool.430959/";
-
- private static readonly string SiteURL = "http://amplify.pt/download/";
- private static readonly string StoreURL = "https://assetstore.unity.com/packages/tools/visual-scripting/amplify-shader-editor-68570";
-
- private static readonly GUIContent SamplesTitle = new GUIContent( "Shader Samples", "Import samples according to you project rendering pipeline" );
- private static readonly GUIContent ResourcesTitle = new GUIContent( "Learning Resources", "Check the online wiki for various topics about how to use ASE with node examples and explanations" );
- private static readonly GUIContent CommunityTitle = new GUIContent( "Community", "Need help? Reach us through our discord server or the offitial support Unity forum" );
- private static readonly GUIContent UpdateTitle = new GUIContent( "Latest Update", "Check the lastest additions, improvements and bug fixes done to ASE" );
- private static readonly GUIContent ASETitle = new GUIContent( "Amplify Shader Editor", "Are you using the latest version? Now you know" );
-
- private static readonly string DownArrow = "\u25BC";
-#if UNITY_2019_3_OR_NEWER
- private int DownButtonSize = 22;
-#else
- private int DownButtonSize = 21;
-#endif
-
- Vector2 m_scrollPosition = Vector2.zero;
- Preferences.ShowOption m_startup = Preferences.ShowOption.Never;
- bool m_showLWRP = false;
- bool m_showHDRP = false;
-
- [NonSerialized]
- Texture packageIcon = null;
- [NonSerialized]
- Texture textIcon = null;
- [NonSerialized]
- Texture webIcon = null;
-
- GUIContent HDRPbutton = null;
- GUIContent HDRPOLDbutton = null;
- GUIContent URPbutton = null;
- GUIContent LWRPbutton = null;
- GUIContent LWRPOLDbutton = null;
- GUIContent BuiltInbutton = null;
-
- GUIContent Manualbutton = null;
- GUIContent Basicbutton = null;
- GUIContent Beginnerbutton = null;
- GUIContent Nodesbutton = null;
- GUIContent SRPusebutton = null;
- GUIContent Functionsbutton = null;
- GUIContent Templatesbutton = null;
- GUIContent APIbutton = null;
-
- GUIContent DiscordButton = null;
- GUIContent ForumButton = null;
-
- GUIContent ASEIcon = null;
- RenderTexture rt;
-
- [NonSerialized]
- GUIStyle m_buttonStyle = null;
- [NonSerialized]
- GUIStyle m_buttonLeftStyle = null;
- [NonSerialized]
- GUIStyle m_buttonRightStyle = null;
- [NonSerialized]
- GUIStyle m_minibuttonStyle = null;
- [NonSerialized]
- GUIStyle m_labelStyle = null;
- [NonSerialized]
- GUIStyle m_linkStyle = null;
-
- private ChangeLogInfo m_changeLog;
- private bool m_infoDownloaded = false;
- private string m_newVersion = string.Empty;
-
- private void OnEnable()
- {
- rt = new RenderTexture( 16, 16, 0 );
- rt.Create();
-
- m_startup = (Preferences.ShowOption)EditorPrefs.GetInt( Preferences.PrefStartUp, 0 );
-
- if( textIcon == null )
- {
- Texture icon = EditorGUIUtility.IconContent( "TextAsset Icon" ).image;
- var cache = RenderTexture.active;
- RenderTexture.active = rt;
- Graphics.Blit( icon, rt );
- RenderTexture.active = cache;
- textIcon = rt;
-
- Manualbutton = new GUIContent( " Manual", textIcon );
- Basicbutton = new GUIContent( " Basic use tutorials", textIcon );
- Beginnerbutton = new GUIContent( " Beginner Series", textIcon );
- Nodesbutton = new GUIContent( " Node List", textIcon );
- SRPusebutton = new GUIContent( " SRP HD/URP/LW use", textIcon );
- Functionsbutton = new GUIContent( " Shader Functions", textIcon );
- Templatesbutton = new GUIContent( " Shader Templates", textIcon );
- APIbutton = new GUIContent( " Node API", textIcon );
- }
-
- if( packageIcon == null )
- {
- packageIcon = EditorGUIUtility.IconContent( "BuildSettings.Editor.Small" ).image;
- HDRPbutton = new GUIContent( " HDRP Samples", packageIcon );
- HDRPOLDbutton = new GUIContent( " HDRP Samples 6.X.X", packageIcon );
- URPbutton = new GUIContent( " URP Samples", packageIcon );
- LWRPbutton = new GUIContent( " LWRP Samples 6.X.X", packageIcon );
- LWRPOLDbutton = new GUIContent( " LWRP Samples 3.X.X", packageIcon );
- BuiltInbutton = new GUIContent( " Built-In Samples", packageIcon );
- }
-
- if( webIcon == null )
- {
- webIcon = EditorGUIUtility.IconContent( "BuildSettings.Web.Small" ).image;
- DiscordButton = new GUIContent( " Discord", webIcon );
- ForumButton = new GUIContent( " Unity Forum", webIcon );
- }
-
- if( m_changeLog == null )
- {
- var changelog = AssetDatabase.LoadAssetAtPath<TextAsset>( AssetDatabase.GUIDToAssetPath( ChangeLogGUID ) );
- string lastUpdate = string.Empty;
- if(changelog != null )
- {
- lastUpdate = changelog.text.Substring( 0, changelog.text.IndexOf( "\nv", 50 ) );// + "\n...";
- lastUpdate = lastUpdate.Replace( " *", " \u25CB" );
- lastUpdate = lastUpdate.Replace( "* ", "\u2022 " );
- }
- m_changeLog = new ChangeLogInfo( VersionInfo.FullNumber, lastUpdate );
- }
-
- if( ASEIcon == null )
- {
- ASEIcon = new GUIContent( AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( IconGUID ) ) );
- }
- }
-
- private void OnDisable()
- {
- if( rt != null )
- {
- rt.Release();
- DestroyImmediate( rt );
- }
- }
-
- public void OnGUI()
- {
- if( !m_infoDownloaded )
- {
- m_infoDownloaded = true;
-
- StartBackgroundTask( StartRequest( ChangelogURL, () =>
- {
- var temp = ChangeLogInfo.CreateFromJSON( www.downloadHandler.text );
- if( temp != null && temp.Version >= m_changeLog.Version )
- {
- m_changeLog = temp;
- }
- // improve this later
- int major = m_changeLog.Version / 10000;
- int minor = ( m_changeLog.Version / 1000 ) - major * 10;
- int release = ( m_changeLog.Version / 100 ) - major * 100 - minor * 10;
- int revision = ( ( m_changeLog.Version / 10 ) - major * 1000 - minor * 100 - release * 10 ) + ( m_changeLog.Version - major * 10000 - minor * 1000 - release * 100 );
- m_newVersion = major + "." + minor + "." + release + "r" + revision;
- Repaint();
- } ) );
- }
-
- if( m_buttonStyle == null )
- {
- m_buttonStyle = new GUIStyle( GUI.skin.button );
- m_buttonStyle.alignment = TextAnchor.MiddleLeft;
- }
-
- if( m_buttonLeftStyle == null )
- {
- m_buttonLeftStyle = new GUIStyle( "ButtonLeft" );
- m_buttonLeftStyle.alignment = TextAnchor.MiddleLeft;
- m_buttonLeftStyle.margin = m_buttonStyle.margin;
- m_buttonLeftStyle.margin.right = 0;
- }
-
- if( m_buttonRightStyle == null )
- {
- m_buttonRightStyle = new GUIStyle( "ButtonRight" );
- m_buttonRightStyle.alignment = TextAnchor.MiddleLeft;
- m_buttonRightStyle.margin = m_buttonStyle.margin;
- m_buttonRightStyle.margin.left = 0;
- }
-
- if( m_minibuttonStyle == null )
- {
- m_minibuttonStyle = new GUIStyle( "MiniButton" );
- m_minibuttonStyle.alignment = TextAnchor.MiddleLeft;
- m_minibuttonStyle.margin = m_buttonStyle.margin;
- m_minibuttonStyle.margin.left = 20;
- m_minibuttonStyle.normal.textColor = m_buttonStyle.normal.textColor;
- m_minibuttonStyle.hover.textColor = m_buttonStyle.hover.textColor;
- }
-
- if( m_labelStyle == null )
- {
- m_labelStyle = new GUIStyle( "BoldLabel" );
- m_labelStyle.margin = new RectOffset( 4, 4, 4, 4 );
- m_labelStyle.padding = new RectOffset( 2, 2, 2, 2 );
- m_labelStyle.fontSize = 13;
- }
-
- if( m_linkStyle == null )
- {
- var inv = AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( "1004d06b4b28f5943abdf2313a22790a" ) ); // find a better solution for transparent buttons
- m_linkStyle = new GUIStyle();
- m_linkStyle.normal.textColor = new Color( 0.2980392f, 0.4901961f, 1f );
- m_linkStyle.hover.textColor = Color.white;
- m_linkStyle.active.textColor = Color.grey;
- m_linkStyle.margin.top = 3;
- m_linkStyle.margin.bottom = 2;
- m_linkStyle.hover.background = inv;
- m_linkStyle.active.background = inv;
- }
-
- EditorGUILayout.BeginHorizontal( GUIStyle.none, GUILayout.ExpandWidth( true ) );
- {
- // left column
- EditorGUILayout.BeginVertical( GUILayout.Width( 175 ) );
- {
- GUILayout.Label( SamplesTitle, m_labelStyle );
- EditorGUILayout.BeginHorizontal();
- if( GUILayout.Button( HDRPbutton, m_buttonLeftStyle ) )
- ImportSample( HDRPbutton.text, HighDefinitionGUID );
-
- if( GUILayout.Button( DownArrow, m_buttonRightStyle, GUILayout.Width( DownButtonSize ), GUILayout.Height( DownButtonSize ) ) )
- {
- m_showHDRP = !m_showHDRP;
- m_showLWRP = false;
- }
- EditorGUILayout.EndHorizontal();
- if( m_showHDRP )
- {
- if( GUILayout.Button( HDRPOLDbutton, m_minibuttonStyle ) )
- ImportSample( HDRPOLDbutton.text, OLDHighDefinitionGUID );
- }
- EditorGUILayout.BeginHorizontal();
- if( GUILayout.Button( URPbutton, m_buttonLeftStyle ) )
- ImportSample( URPbutton.text, UniversalGUID );
-
- if( GUILayout.Button( DownArrow, m_buttonRightStyle, GUILayout.Width( DownButtonSize ), GUILayout.Height( DownButtonSize ) ) )
- {
- m_showLWRP = !m_showLWRP;
- m_showHDRP = false;
- }
- EditorGUILayout.EndHorizontal();
- if( m_showLWRP )
- {
- EditorGUILayout.BeginVertical();
- if( GUILayout.Button( LWRPbutton, m_minibuttonStyle ) )
- ImportSample( LWRPbutton.text, LightWeightGUID );
- if( GUILayout.Button( LWRPOLDbutton, m_minibuttonStyle ) )
- ImportSample( LWRPOLDbutton.text, OLDLightWeightGUID );
- EditorGUILayout.EndVertical();
- }
- if( GUILayout.Button( BuiltInbutton, m_buttonStyle ) )
- ImportSample( BuiltInbutton.text, BuiltInGUID );
-
- GUILayout.Space( 10 );
-
- GUILayout.Label( ResourcesTitle, m_labelStyle );
- if( GUILayout.Button( Manualbutton, m_buttonStyle ) )
- Application.OpenURL( ManualURL );
-
- if( GUILayout.Button( Basicbutton, m_buttonStyle ) )
- Application.OpenURL( BasicURL );
-
- if( GUILayout.Button( Beginnerbutton, m_buttonStyle ) )
- Application.OpenURL( BeginnerURL );
-
- if( GUILayout.Button( Nodesbutton, m_buttonStyle ) )
- Application.OpenURL( NodesURL );
-
- if( GUILayout.Button( SRPusebutton, m_buttonStyle ) )
- Application.OpenURL( SRPURL );
-
- if( GUILayout.Button( Functionsbutton, m_buttonStyle ) )
- Application.OpenURL( FunctionsURL );
-
- if( GUILayout.Button( Templatesbutton, m_buttonStyle ) )
- Application.OpenURL( TemplatesURL );
-
- if( GUILayout.Button( APIbutton, m_buttonStyle ) )
- Application.OpenURL( APIURL );
- }
- EditorGUILayout.EndVertical();
-
- // right column
- EditorGUILayout.BeginVertical( GUILayout.Width( 650 - 175 - 9 ), GUILayout.ExpandHeight( true ) );
- {
- GUILayout.Label( CommunityTitle, m_labelStyle );
- EditorGUILayout.BeginHorizontal( GUILayout.ExpandWidth( true ) );
- {
- if( GUILayout.Button( DiscordButton, GUILayout.ExpandWidth( true ) ) )
- {
- Application.OpenURL( DiscordURL );
- }
- if( GUILayout.Button( ForumButton, GUILayout.ExpandWidth( true ) ) )
- {
- Application.OpenURL( ForumURL );
- }
- }
- EditorGUILayout.EndHorizontal();
- GUILayout.Label( UpdateTitle, m_labelStyle );
- m_scrollPosition = GUILayout.BeginScrollView( m_scrollPosition, "ProgressBarBack", GUILayout.ExpandHeight( true ), GUILayout.ExpandWidth( true ) );
- GUILayout.Label( m_changeLog.LastUpdate, "WordWrappedMiniLabel", GUILayout.ExpandHeight( true ) );
- GUILayout.EndScrollView();
-
- EditorGUILayout.BeginHorizontal( GUILayout.ExpandWidth( true ) );
- {
- EditorGUILayout.BeginVertical();
- GUILayout.Label( ASETitle, m_labelStyle );
-
- GUILayout.Label( "Installed Version: " + VersionInfo.StaticToString() );
-
- if( m_changeLog.Version > VersionInfo.FullNumber )
- {
- var cache = GUI.color;
- GUI.color = Color.red;
- GUILayout.Label( "New version available: " + m_newVersion, "BoldLabel" );
- GUI.color = cache;
- }
- else
- {
- var cache = GUI.color;
- GUI.color = Color.green;
- GUILayout.Label( "You are using the latest version", "BoldLabel" );
- GUI.color = cache;
- }
-
- EditorGUILayout.BeginHorizontal();
- GUILayout.Label( "Download links:" );
- if( GUILayout.Button( "Amplify", m_linkStyle ) )
- Application.OpenURL( SiteURL );
- GUILayout.Label( "-" );
- if( GUILayout.Button( "Asset Store", m_linkStyle ) )
- Application.OpenURL( StoreURL );
- EditorGUILayout.EndHorizontal();
- GUILayout.Space( 7 );
- EditorGUILayout.EndVertical();
-
- GUILayout.FlexibleSpace();
- EditorGUILayout.BeginVertical();
- GUILayout.Space( 7 );
- GUILayout.Label( ASEIcon );
- EditorGUILayout.EndVertical();
- }
- EditorGUILayout.EndHorizontal();
- }
- EditorGUILayout.EndVertical();
- }
- EditorGUILayout.EndHorizontal();
-
-
- EditorGUILayout.BeginHorizontal( "ProjectBrowserBottomBarBg", GUILayout.ExpandWidth( true ), GUILayout.Height(22) );
- {
- GUILayout.FlexibleSpace();
- EditorGUI.BeginChangeCheck();
- var cache = EditorGUIUtility.labelWidth;
- EditorGUIUtility.labelWidth = 100;
- m_startup = (Preferences.ShowOption)EditorGUILayout.EnumPopup( "Show At Startup", m_startup, GUILayout.Width( 220 ) );
- EditorGUIUtility.labelWidth = cache;
- if( EditorGUI.EndChangeCheck() )
- {
- EditorPrefs.SetInt( Preferences.PrefStartUp, (int)m_startup );
- }
- }
- EditorGUILayout.EndHorizontal();
-
- // Find a better way to update link buttons without repainting the window
- Repaint();
- }
-
- void ImportSample( string pipeline, string guid )
- {
- if( EditorUtility.DisplayDialog( "Import Sample", "This will import the samples for" + pipeline.Replace( " Samples", "" ) + ", please make sure the pipeline is properly installed and/or selected before importing the samples.\n\nContinue?", "Yes", "No" ) )
- {
- AssetDatabase.ImportPackage( AssetDatabase.GUIDToAssetPath( ResourcesGUID ), false );
- AssetDatabase.ImportPackage( AssetDatabase.GUIDToAssetPath( guid ), false );
- }
- }
-
- UnityWebRequest www;
-
- IEnumerator StartRequest( string url, Action success = null )
- {
- using( www = UnityWebRequest.Get( url ) )
- {
-#if UNITY_2017_2_OR_NEWER
- yield return www.SendWebRequest();
-#else
- yield return www.Send();
-#endif
-
- while( www.isDone == false )
- yield return null;
-
- if( success != null )
- success();
- }
- }
-
- public static void StartBackgroundTask( IEnumerator update, Action end = null )
- {
- EditorApplication.CallbackFunction closureCallback = null;
-
- closureCallback = () =>
- {
- try
- {
- if( update.MoveNext() == false )
- {
- if( end != null )
- end();
- EditorApplication.update -= closureCallback;
- }
- }
- catch( Exception ex )
- {
- if( end != null )
- end();
- Debug.LogException( ex );
- EditorApplication.update -= closureCallback;
- }
- };
-
- EditorApplication.update += closureCallback;
- }
- }
-
- [Serializable]
- internal class ChangeLogInfo
- {
- public int Version;
- public string LastUpdate;
-
- public static ChangeLogInfo CreateFromJSON( string jsonString )
- {
- return JsonUtility.FromJson<ChangeLogInfo>( jsonString );
- }
-
- public ChangeLogInfo( int version, string lastUpdate )
- {
- Version = version;
- LastUpdate = lastUpdate;
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEStartScreen.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEStartScreen.cs.meta
deleted file mode 100644
index b9441e35..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASEStartScreen.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 3e7433fb42db4d9428571bfcd0da64f3
-timeCreated: 1585827066
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASETextureArrayCreator.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASETextureArrayCreator.cs
deleted file mode 100644
index e33afdcb..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASETextureArrayCreator.cs
+++ /dev/null
@@ -1,686 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-//#define NEW_TEXTURE_3D_METHOD
-
-using UnityEngine;
-using UnityEditor;
-using System.Collections.Generic;
-using UnityEditorInternal;
-using System;
-using System.IO;
-
-namespace AmplifyShaderEditor
-{
- public class ASETextureArrayCreator : EditorWindow
- {
- [MenuItem( "Window/Amplify Shader Editor/Texture Array Creator", false, 1001 )]
- static void ShowWindow()
- {
- ASETextureArrayCreator window = EditorWindow.GetWindow<ASETextureArrayCreator>();
- window.titleContent.text = "Texture Array";
- window.minSize = new Vector2( 302, 350 );
- window.Show();
- }
-
- private const string ClearButtonStr = "Clear";
- private const string TextureFilter = "t:Texture2D";
- private const string BuildArrayMessage = "Build Array";
- private const string BuildTexture3DMessage = "Build Texture 3D";
- private const string ArrayFilename = "NewTextureArray";
- private const string Texture3DFilename = "NewTexture3D";
-
- private DragAndDropTool m_dragAndDropTool;
- private Rect m_draggableArea;
-
- [SerializeField]
- private List<Texture2D> m_allTextures;
-
- [SerializeField]
- private ReorderableList m_listTextures = null;
-
- [SerializeField]
- private bool m_tex3DMode = false;
-
- [SerializeField]
- private bool m_linearMode = false;
-
- [SerializeField]
- private string m_folderPath = "Assets/";
-
- [SerializeField]
- private string m_fileName = "NewTextureArray";
-
- [SerializeField]
- private bool m_filenameChanged = false;
-
- [SerializeField]
- private TextureWrapMode m_wrapMode = TextureWrapMode.Repeat;
-
- [SerializeField]
- private FilterMode m_filterMode = FilterMode.Bilinear;
-
- [SerializeField]
- private int m_anisoLevel = 1;
-
- [SerializeField]
- private int m_previewSize = 16;
-
- [SerializeField]
- private bool m_mipMaps = true;
-
- [SerializeField]
- private int m_selectedSizeX = 4;
-
- [SerializeField]
- private int m_selectedSizeY = 4;
-
- [SerializeField]
- private TextureFormat m_selectedFormatEnum = TextureFormat.ARGB32;
-
- [SerializeField]
- private int m_quality = 100;
-
- private int[] m_sizes = { 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
- private string[] m_sizesStr = { "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192" };
- private static Dictionary<int, int> MipCount = new Dictionary<int, int>() { { 32, 6 }, { 64, 7 }, { 128, 8 }, { 256, 9 }, { 512, 10 }, { 1024, 11 }, { 2048, 12 }, { 4096, 13 }, { 8192, 14 } };
- private static List<TextureFormat> UncompressedFormats = new List<TextureFormat>() { TextureFormat.ARGB32, TextureFormat.RGBA32, TextureFormat.RGB24, TextureFormat.Alpha8 };
-
- private GUIStyle m_contentStyle = null;
- private GUIStyle m_pathButtonStyle = null;
- private GUIContent m_pathButtonContent = new GUIContent();
-
- private Vector2 m_scrollPos;
- private Texture m_lastSaved;
- private bool m_lockRatio = true;
- private string m_message = string.Empty;
-
- private void OnEnable()
- {
- m_draggableArea = new Rect( 0, 0, 1, 1 );
- m_dragAndDropTool = new DragAndDropTool();
- m_dragAndDropTool.OnValidDropObjectEvt += OnValidObjectsDropped;
-
- if( m_contentStyle == null )
- {
- m_contentStyle = new GUIStyle( GUIStyle.none );
- m_contentStyle.margin = new RectOffset( 6, 4, 5, 5 );
- }
-
- m_pathButtonStyle = null;
-
- if( m_allTextures == null )
- m_allTextures = new List<Texture2D>();
-
- if( m_listTextures == null )
- {
- m_listTextures = new ReorderableList( m_allTextures, typeof( Texture2D ), true, true, true, true );
- m_listTextures.elementHeight = 16;
-
- m_listTextures.drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) =>
- {
- m_allTextures[ index ] = (Texture2D)EditorGUI.ObjectField( rect, "Texture " + index, m_allTextures[ index ], typeof( Texture2D ), false );
- };
-
- m_listTextures.drawHeaderCallback = ( Rect rect ) =>
- {
- m_previewSize = EditorGUI.IntSlider( rect, "Texture List", m_previewSize, 16, 64 );
- if( (float)m_previewSize != m_listTextures.elementHeight )
- m_listTextures.elementHeight = m_previewSize;
- };
- m_listTextures.onAddCallback = ( list ) =>
- {
- m_allTextures.Add( null );
- };
-
- m_listTextures.onRemoveCallback = ( list ) =>
- {
- m_allTextures.RemoveAt( list.index );
- };
- }
- }
-
- private void OnDestroy()
- {
- m_dragAndDropTool.Destroy();
- m_dragAndDropTool = null;
-
- if( m_allTextures != null )
- {
- m_allTextures.Clear();
- m_allTextures = null;
- }
- }
-
- void OnGUI()
- {
- if( m_pathButtonStyle == null )
- m_pathButtonStyle = "minibutton";
-
- m_scrollPos = EditorGUILayout.BeginScrollView( m_scrollPos, GUILayout.Height( position.height ) );
- float cachedWidth = EditorGUIUtility.labelWidth;
- EditorGUIUtility.labelWidth = 100;
- EditorGUILayout.BeginVertical( m_contentStyle );
-
- string buildButtonStr = m_tex3DMode ? BuildTexture3DMessage : BuildArrayMessage;
- // build button
- EditorGUILayout.BeginHorizontal();
- EditorGUI.BeginDisabledGroup( m_allTextures.Count <= 0 );
- if( GUILayout.Button( buildButtonStr, "prebutton", GUILayout.Height( 20 ) ) )
- {
- bool showWarning = false;
- for( int i = 0; i < m_allTextures.Count; i++ )
- {
- if( m_allTextures[ i ].width != m_sizes[ m_selectedSizeX ] || m_allTextures[ i ].height != m_sizes[ m_selectedSizeY ] )
- {
- showWarning = true;
- }
- }
-
- if( !showWarning )
- {
- m_message = string.Empty;
- if( m_tex3DMode )
- BuildTexture3D();
- else
- BuildArray();
- }
- else if( EditorUtility.DisplayDialog( "Warning!", "Some textures need to be resized to fit the selected size. Do you want to continue?", "Yes", "No" ) )
- {
- m_message = string.Empty;
- if( m_tex3DMode )
- BuildTexture3D();
- else
- BuildArray();
- }
- }
- EditorGUI.EndDisabledGroup();
- EditorGUI.BeginDisabledGroup( m_lastSaved == null );
- GUIContent icon = EditorGUIUtility.IconContent( "icons/d_ViewToolZoom.png" );
- if( GUILayout.Button( icon, "prebutton", GUILayout.Width( 28 ), GUILayout.Height( 20 ) ) )
- {
- EditorGUIUtility.PingObject( m_lastSaved );
- }
- EditorGUI.EndDisabledGroup();
- EditorGUILayout.EndHorizontal();
-
- // message
- if( !string.IsNullOrEmpty( m_message ) )
- if( GUILayout.Button( "BUILD REPORT (click to hide):\n\n" + m_message, "helpbox" ) )
- m_message = string.Empty;
-
- // options
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PrefixLabel( "Size" );
- EditorGUIUtility.labelWidth = 16;
- m_selectedSizeX = EditorGUILayout.Popup( "X", m_selectedSizeX, m_sizesStr );
- EditorGUI.BeginDisabledGroup( m_lockRatio );
- m_selectedSizeY = EditorGUILayout.Popup( "Y", m_lockRatio ? m_selectedSizeX : m_selectedSizeY, m_sizesStr );
- EditorGUI.EndDisabledGroup();
- EditorGUIUtility.labelWidth = 100;
- m_lockRatio = GUILayout.Toggle( m_lockRatio, "L", "minibutton", GUILayout.Width( 18 ) );
- EditorGUILayout.EndHorizontal();
- EditorGUI.BeginChangeCheck();
- m_tex3DMode = EditorGUILayout.Toggle( "Texture 3D", m_tex3DMode );
- if( EditorGUI.EndChangeCheck() )
- {
- if( !m_filenameChanged )
- {
- m_fileName = m_tex3DMode ? Texture3DFilename:ArrayFilename;
- }
- }
-
- m_linearMode = EditorGUILayout.Toggle( "Linear", m_linearMode );
- m_mipMaps = EditorGUILayout.Toggle( "Mip Maps", m_mipMaps );
- m_wrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup( "Wrap Mode", m_wrapMode );
- m_filterMode = (FilterMode)EditorGUILayout.EnumPopup( "Filter Mode", m_filterMode );
- m_anisoLevel = EditorGUILayout.IntSlider( "Aniso Level", m_anisoLevel, 0, 16 );
-
- m_selectedFormatEnum = (TextureFormat)EditorGUILayout.EnumPopup( "Format", m_selectedFormatEnum );
- if( m_selectedFormatEnum == TextureFormat.DXT1Crunched )
- {
- m_selectedFormatEnum = TextureFormat.DXT1;
- Debug.Log( "Texture Array does not support crunched DXT1 format. Changing to DXT1..." );
- }
- else if( m_selectedFormatEnum == TextureFormat.DXT5Crunched )
- {
- m_selectedFormatEnum = TextureFormat.DXT5;
- Debug.Log( "Texture Array does not support crunched DXT5 format. Changing to DXT5..." );
- }
-
- m_quality = EditorGUILayout.IntSlider( "Format Quality", m_quality, 0, 100 );
- EditorGUILayout.Separator();
- EditorGUILayout.LabelField( "Path and Name" );
- EditorGUILayout.BeginHorizontal();
- m_pathButtonContent.text = m_folderPath;
- Vector2 buttonSize = m_pathButtonStyle.CalcSize( m_pathButtonContent );
- if( GUILayout.Button( m_pathButtonContent, m_pathButtonStyle, GUILayout.MaxWidth( Mathf.Min( position.width * 0.5f, buttonSize.x ) ) ) )
- {
- string folderpath = EditorUtility.OpenFolderPanel( "Save Texture Array to folder", "Assets/", "" );
- folderpath = FileUtil.GetProjectRelativePath( folderpath );
- if( string.IsNullOrEmpty( folderpath ) )
- m_folderPath = "Assets/";
- else
- m_folderPath = folderpath + "/";
- }
- EditorGUI.BeginChangeCheck();
- m_fileName = EditorGUILayout.TextField( m_fileName, GUILayout.ExpandWidth( true ) );
- if( EditorGUI.EndChangeCheck() )
- {
- m_filenameChanged = true;
- }
- EditorGUILayout.LabelField( ".asset", GUILayout.MaxWidth( 40 ) );
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.Separator();
-
- // list
- EditorGUILayout.Separator();
- if( GUILayout.Button( ClearButtonStr ) )
- {
- m_allTextures.Clear();
- }
-
- if( m_listTextures != null )
- m_listTextures.DoLayoutList();
-
- GUILayout.Space( 20 );
- EditorGUILayout.EndVertical();
- EditorGUIUtility.labelWidth = cachedWidth;
- EditorGUILayout.EndScrollView();
- m_draggableArea.size = position.size;
- m_dragAndDropTool.TestDragAndDrop( m_draggableArea );
- }
-
- public void OnValidObjectsDropped( UnityEngine.Object[] droppedObjs )
- {
- for( int objIdx = 0; objIdx < droppedObjs.Length; objIdx++ )
- {
- Texture2D tex = droppedObjs[ objIdx ] as Texture2D;
- if( tex != null )
- {
- m_allTextures.Add( tex );
- }
- else
- {
- DefaultAsset asset = droppedObjs[ objIdx ] as DefaultAsset;
- if( asset != null )
- {
- string path = AssetDatabase.GetAssetPath( asset );
- if( AssetDatabase.IsValidFolder( path ) )
- {
- string[] pathArr = { path };
- string[] texInDir = AssetDatabase.FindAssets( TextureFilter, pathArr );
- for( int texIdx = 0; texIdx < texInDir.Length; texIdx++ )
- {
- Texture2D internalTex = AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( texInDir[ texIdx ] ));
- if( internalTex != null )
- {
- m_allTextures.Add( internalTex );
- }
- }
- }
- }
- }
- }
-
- m_allTextures.Sort( ( x, y ) => string.Compare( x.name, y.name ) );
- }
-
- private void CopyToArray( ref Texture2D from, ref Texture2DArray to, int arrayIndex, int mipLevel, bool compressed = true )
- {
- if( compressed )
- {
- Graphics.CopyTexture( from, 0, mipLevel, to, arrayIndex, mipLevel );
- }
- else
- {
- to.SetPixels( from.GetPixels(), arrayIndex, mipLevel );
- to.Apply();
- }
- }
-
-#if NEW_TEXTURE_3D_METHOD
- private void BuildTexture3D()
- {
- int sizeX = m_sizes[ m_selectedSizeX ];
- int sizeY = m_sizes[ m_selectedSizeY ];
-
- Texture3D texture3D = new Texture3D( sizeX, sizeY, m_allTextures.Count, m_selectedFormatEnum, m_mipMaps );
- texture3D.wrapMode = m_wrapMode;
- texture3D.filterMode = m_filterMode;
- texture3D.anisoLevel = m_anisoLevel;
- //texture3D.Apply( false );
- RenderTexture cache = RenderTexture.active;
- RenderTexture rt = new RenderTexture( sizeX, sizeY, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default );
- rt.Create();
- List<Texture2D> textures = new List<Texture2D>( m_allTextures.Count );
-
- for( int i = 0; i < m_allTextures.Count; i++ )
- {
- // build report
- int widthChanges = m_allTextures[ i ].width < sizeX ? -1 : m_allTextures[ i ].width > sizeX ? 1 : 0;
- int heightChanges = m_allTextures[ i ].height < sizeY ? -1 : m_allTextures[ i ].height > sizeY ? 1 : 0;
- if( ( widthChanges < 0 && heightChanges <= 0 ) || ( widthChanges <= 0 && heightChanges < 0 ) )
- m_message += m_allTextures[ i ].name + " was upscaled\n";
- else if( ( widthChanges > 0 && heightChanges >= 0 ) || ( widthChanges >= 0 && heightChanges > 0 ) )
- m_message += m_allTextures[ i ].name + " was downscaled\n";
- else if( ( widthChanges > 0 && heightChanges < 0 ) || ( widthChanges < 0 && heightChanges > 0 ) )
- m_message += m_allTextures[ i ].name + " changed dimensions\n";
-
- // blit image to upscale or downscale the image to any size
- RenderTexture.active = rt;
-
- bool cachedsrgb = GL.sRGBWrite;
- GL.sRGBWrite = !m_linearMode;
- Graphics.Blit( m_allTextures[ i ], rt );
- GL.sRGBWrite = cachedsrgb;
-
- textures.Add( new Texture2D( sizeX, sizeY, TextureFormat.ARGB32, m_mipMaps, m_linearMode ));
- textures[ i ].ReadPixels( new Rect( 0, 0, sizeX, sizeY ), 0, 0, m_mipMaps );
- RenderTexture.active = null;
-
- bool isCompressed = UncompressedFormats.FindIndex( x => x.Equals( m_selectedFormatEnum ) ) < 0;
- if( isCompressed )
- {
- EditorUtility.CompressTexture( textures[ i ], m_selectedFormatEnum, m_quality );
- // t2d.Apply( false );
- }
- textures[ i ].Apply( false );
- }
-
- rt.Release();
- RenderTexture.active = cache;
-
- if( m_message.Length > 0 )
- m_message = m_message.Substring( 0, m_message.Length - 1 );
-
- int sizeZ = textures.Count;
- Color[] colors = new Color[ sizeX * sizeY * sizeZ ];
- int idx = 0;
- for( int z = 0; z < sizeZ; z++ )
- {
- for( int y = 0; y < sizeY; y++ )
- {
- for( int x = 0; x < sizeX; x++, idx++ )
- {
- colors[ idx ] = textures[ z ].GetPixel(x,y);
- }
- }
- }
-
- texture3D.SetPixels( colors );
- texture3D.Apply();
-
- string path = m_folderPath + m_fileName + ".asset";
- Texture3D outfile = AssetDatabase.LoadMainAssetAtPath( path ) as Texture3D;
- if( outfile != null )
- {
- EditorUtility.CopySerialized( texture3D, outfile );
- AssetDatabase.SaveAssets();
- EditorGUIUtility.PingObject( outfile );
- m_lastSaved = outfile;
- }
- else
- {
- AssetDatabase.CreateAsset( texture3D, path );
- EditorGUIUtility.PingObject( texture3D );
- m_lastSaved = texture3D;
- }
- }
-#else
- private void BuildTexture3D()
- {
- int sizeX = m_sizes[ m_selectedSizeX ];
- int sizeY = m_sizes[ m_selectedSizeY ];
- int mipCount = m_mipMaps ? MipCount[ Mathf.Max( sizeX, sizeY ) ] : 1;
-
- Texture3D texture3D = new Texture3D( sizeX, sizeY, m_allTextures.Count, m_selectedFormatEnum, m_mipMaps );
- texture3D.wrapMode = m_wrapMode;
- texture3D.filterMode = m_filterMode;
- texture3D.anisoLevel = m_anisoLevel;
- texture3D.Apply( false );
- RenderTexture cache = RenderTexture.active;
- RenderTexture rt = new RenderTexture( sizeX, sizeY, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default );
- rt.Create();
- List<List<Color>> mipColor = new List<List<Color>>();
- if( m_mipMaps )
- {
- for( int i = 0; i < mipCount; i++ )
- {
- mipColor.Add( new List<Color>() );
- }
- }
- else
- {
- mipColor.Add( new List<Color>() );
- }
-
- for( int i = 0; i < m_allTextures.Count; i++ )
- {
- // build report
- int widthChanges = m_allTextures[ i ].width < sizeX ? -1 : m_allTextures[ i ].width > sizeX ? 1 : 0;
- int heightChanges = m_allTextures[ i ].height < sizeY ? -1 : m_allTextures[ i ].height > sizeY ? 1 : 0;
- if( ( widthChanges < 0 && heightChanges <= 0 ) || ( widthChanges <= 0 && heightChanges < 0 ) )
- m_message += m_allTextures[ i ].name + " was upscaled\n";
- else if( ( widthChanges > 0 && heightChanges >= 0 ) || ( widthChanges >= 0 && heightChanges > 0 ) )
- m_message += m_allTextures[ i ].name + " was downscaled\n";
- else if( ( widthChanges > 0 && heightChanges < 0 ) || ( widthChanges < 0 && heightChanges > 0 ) )
- m_message += m_allTextures[ i ].name + " changed dimensions\n";
-
- // blit image to upscale or downscale the image to any size
- RenderTexture.active = rt;
-
- bool cachedsrgb = GL.sRGBWrite;
- GL.sRGBWrite = !m_linearMode;
- Graphics.Blit( m_allTextures[ i ], rt );
- GL.sRGBWrite = cachedsrgb;
-
- Texture2D t2d = new Texture2D( sizeX, sizeY, TextureFormat.ARGB32, m_mipMaps, m_linearMode );
- t2d.ReadPixels( new Rect( 0, 0, sizeX, sizeY ), 0, 0, m_mipMaps );
- RenderTexture.active = null;
-
- bool isCompressed = UncompressedFormats.FindIndex( x => x.Equals( m_selectedFormatEnum ) ) < 0;
- if( isCompressed )
- {
- EditorUtility.CompressTexture( t2d, m_selectedFormatEnum, m_quality );
- // t2d.Apply( false );
- }
- t2d.Apply( false );
-
- if( m_mipMaps )
- {
- for( int mip = 0; mip < mipCount; mip++ )
- {
- mipColor[ mip ].AddRange( t2d.GetPixels( mip ) );
- }
- }
- else
- {
- mipColor[ 0 ].AddRange( t2d.GetPixels( 0 ) );
- }
- }
-
- rt.Release();
- RenderTexture.active = cache;
-
- if( m_message.Length > 0 )
- m_message = m_message.Substring( 0, m_message.Length - 1 );
-
- for( int i = 0; i < mipCount; i++ )
- {
- texture3D.SetPixels( mipColor[ i ].ToArray(), i );
- }
-
- texture3D.Apply( false );
-
- string path = m_folderPath + m_fileName + ".asset";
- Texture3D outfile = AssetDatabase.LoadMainAssetAtPath( path ) as Texture3D;
- if( outfile != null )
- {
- EditorUtility.CopySerialized( texture3D, outfile );
- AssetDatabase.SaveAssets();
- EditorGUIUtility.PingObject( outfile );
- m_lastSaved = outfile;
- }
- else
- {
- AssetDatabase.CreateAsset( texture3D, path );
- EditorGUIUtility.PingObject( texture3D );
- m_lastSaved = texture3D;
- }
- }
-#endif
- private void BuildTexture3DAutoMips()
- {
- int sizeX = m_sizes[ m_selectedSizeX ];
- int sizeY = m_sizes[ m_selectedSizeY ];
-
- Texture3D texture3D = new Texture3D( sizeX, sizeY, m_allTextures.Count, m_selectedFormatEnum, m_mipMaps );
- texture3D.wrapMode = m_wrapMode;
- texture3D.filterMode = m_filterMode;
- texture3D.anisoLevel = m_anisoLevel;
- texture3D.Apply( false );
- RenderTexture cache = RenderTexture.active;
- RenderTexture rt = new RenderTexture( sizeX, sizeY, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default );
- rt.Create();
- List<Color> texColors = new List<Color>();
-
- for( int i = 0; i < m_allTextures.Count; i++ )
- {
- // build report
- int widthChanges = m_allTextures[ i ].width < sizeX ? -1 : m_allTextures[ i ].width > sizeX ? 1 : 0;
- int heightChanges = m_allTextures[ i ].height < sizeY ? -1 : m_allTextures[ i ].height > sizeY ? 1 : 0;
- if( ( widthChanges < 0 && heightChanges <= 0 ) || ( widthChanges <= 0 && heightChanges < 0 ) )
- m_message += m_allTextures[ i ].name + " was upscaled\n";
- else if( ( widthChanges > 0 && heightChanges >= 0 ) || ( widthChanges >= 0 && heightChanges > 0 ) )
- m_message += m_allTextures[ i ].name + " was downscaled\n";
- else if( ( widthChanges > 0 && heightChanges < 0 ) || ( widthChanges < 0 && heightChanges > 0 ) )
- m_message += m_allTextures[ i ].name + " changed dimensions\n";
-
- // blit image to upscale or downscale the image to any size
- RenderTexture.active = rt;
-
- bool cachedsrgb = GL.sRGBWrite;
- GL.sRGBWrite = !m_linearMode;
- Graphics.Blit( m_allTextures[ i ], rt );
- GL.sRGBWrite = cachedsrgb;
-
- Texture2D t2d = new Texture2D( sizeX, sizeY, TextureFormat.ARGB32, m_mipMaps, m_linearMode );
- t2d.ReadPixels( new Rect( 0, 0, sizeX, sizeY ), 0, 0, m_mipMaps );
- RenderTexture.active = null;
-
- bool isCompressed = UncompressedFormats.FindIndex( x => x.Equals( m_selectedFormatEnum ) ) < 0;
- if( isCompressed )
- {
- EditorUtility.CompressTexture( t2d, m_selectedFormatEnum, m_quality );
- t2d.Apply( false );
- }
- texColors.AddRange( t2d.GetPixels() );
- }
-
- rt.Release();
- RenderTexture.active = cache;
-
- if( m_message.Length > 0 )
- m_message = m_message.Substring( 0, m_message.Length - 1 );
-
- texture3D.SetPixels( texColors.ToArray() );
- texture3D.Apply();
-
- string path = m_folderPath + m_fileName + ".asset";
- Texture3D outfile = AssetDatabase.LoadMainAssetAtPath( path ) as Texture3D;
- if( outfile != null )
- {
- EditorUtility.CopySerialized( texture3D, outfile );
- AssetDatabase.SaveAssets();
- EditorGUIUtility.PingObject( outfile );
- m_lastSaved = outfile;
- }
- else
- {
- AssetDatabase.CreateAsset( texture3D, path );
- EditorGUIUtility.PingObject( texture3D );
- m_lastSaved = texture3D;
- }
- }
-
- private void BuildArray()
- {
- int sizeX = m_sizes[ m_selectedSizeX ];
- int sizeY = m_sizes[ m_selectedSizeY ];
-
- Texture2DArray textureArray = new Texture2DArray( sizeX, sizeY, m_allTextures.Count, m_selectedFormatEnum, m_mipMaps, m_linearMode );
- textureArray.wrapMode = m_wrapMode;
- textureArray.filterMode = m_filterMode;
- textureArray.anisoLevel = m_anisoLevel;
- textureArray.Apply( false );
- RenderTexture cache = RenderTexture.active;
- RenderTexture rt = new RenderTexture( sizeX, sizeY, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default );
- rt.Create();
- for( int i = 0; i < m_allTextures.Count; i++ )
- {
- // build report
- int widthChanges = m_allTextures[ i ].width < sizeX ? -1 : m_allTextures[ i ].width > sizeX ? 1 : 0;
- int heightChanges = m_allTextures[ i ].height < sizeY ? -1 : m_allTextures[ i ].height > sizeY ? 1 : 0;
- if( ( widthChanges < 0 && heightChanges <= 0 ) || ( widthChanges <= 0 && heightChanges < 0 ) )
- m_message += m_allTextures[ i ].name + " was upscaled\n";
- else if( ( widthChanges > 0 && heightChanges >= 0 ) || ( widthChanges >= 0 && heightChanges > 0 ) )
- m_message += m_allTextures[ i ].name + " was downscaled\n";
- else if( ( widthChanges > 0 && heightChanges < 0 ) || ( widthChanges < 0 && heightChanges > 0 ) )
- m_message += m_allTextures[ i ].name + " changed dimensions\n";
-
- // blit image to upscale or downscale the image to any size
- RenderTexture.active = rt;
-
- bool cachedsrgb = GL.sRGBWrite;
- GL.sRGBWrite = !m_linearMode;
- Graphics.Blit( m_allTextures[ i ], rt );
- GL.sRGBWrite = cachedsrgb;
-
- Texture2D t2d = new Texture2D( sizeX, sizeY, TextureFormat.ARGB32, m_mipMaps, m_linearMode );
- t2d.ReadPixels( new Rect( 0, 0, sizeX, sizeY ), 0, 0, m_mipMaps );
- RenderTexture.active = null;
-
- bool isCompressed = UncompressedFormats.FindIndex( x => x.Equals( m_selectedFormatEnum ) ) < 0;
- if( isCompressed )
- {
- EditorUtility.CompressTexture( t2d, m_selectedFormatEnum, m_quality );
- t2d.Apply( false );
- }
-
- if( m_mipMaps )
- {
- int maxSize = Mathf.Max( sizeX, sizeY );
- for( int mip = 0; mip < MipCount[ maxSize ]; mip++ )
- {
- CopyToArray( ref t2d, ref textureArray, i, mip, isCompressed );
- }
- }
- else
- {
- CopyToArray( ref t2d, ref textureArray, i, 0, isCompressed );
- }
- }
-
- rt.Release();
- RenderTexture.active = cache;
- if( m_message.Length > 0 )
- m_message = m_message.Substring( 0, m_message.Length - 1 );
-
- string path = m_folderPath + m_fileName + ".asset";
- Texture2DArray outfile = AssetDatabase.LoadMainAssetAtPath( path ) as Texture2DArray;
- if( outfile != null )
- {
- EditorUtility.CopySerialized( textureArray, outfile );
- AssetDatabase.SaveAssets();
- EditorGUIUtility.PingObject( outfile );
- m_lastSaved = outfile;
- }
- else
- {
- AssetDatabase.CreateAsset( textureArray, path );
- EditorGUIUtility.PingObject( textureArray );
- m_lastSaved = textureArray;
- }
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASETextureArrayCreator.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASETextureArrayCreator.cs.meta
deleted file mode 100644
index 7a01b4f3..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ASETextureArrayCreator.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 436dc8bc09773454db57b9fbf799ec9d
-timeCreated: 1504633068
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomMaterialInspector.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomMaterialInspector.cs
deleted file mode 100644
index d34f6c50..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomMaterialInspector.cs
+++ /dev/null
@@ -1,509 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using UnityEngine;
-using UnityEditor;
-using System;
-using System.Reflection;
-using AmplifyShaderEditor;
-
-
-public static class MaterialPropertyHandlerEx
-{
- private static System.Type type = null;
- public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEditor.MaterialPropertyHandler, UnityEditor" ) : type; } }
- public static object GetHandler( Shader shader, string name )
- {
- return MaterialPropertyHandlerEx.Type.InvokeMember( "GetHandler", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { shader, name } );
- }
-
- public static void OnGUI( object obj, ref Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor )
- {
- Type.InvokeMember( "OnGUI", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, obj, new object[] { position, prop, label, editor } );
- }
-
- public static float GetPropertyHeight( object obj, MaterialProperty prop, string label, MaterialEditor editor )
- {
- return (float)Type.InvokeMember( "GetPropertyHeight", BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod, null, obj, new object[] { prop, label, editor } );
- }
-
- public static object PropertyDrawer( object obj )
- {
- return Type.InvokeMember( "propertyDrawer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty, null, obj, new object[] {} );
- }
-}
-
-internal class ASEMaterialInspector : ShaderGUI
-{
- private const string CopyButtonStr = "Copy Values";
- private const string PasteButtonStr = "Paste Values";
- private const string PreviewModelPref = "ASEMI_PREVIEWMODEL";
-
- private static MaterialEditor m_instance = null;
- private static bool m_refreshOnUndo = false;
-
- private bool m_initialized = false;
- private double m_lastRenderedTime;
- private PreviewRenderUtility m_previewRenderUtility;
- private Mesh m_targetMesh;
- private Vector2 m_previewDir = new Vector2( 120f, -20f );
- private int m_selectedMesh = 0;
-
-
- // Reflection Fields
- private Type m_modelInspectorType = null;
- private MethodInfo m_renderMeshMethod = null;
- private Type m_previewGUIType = null;
- private MethodInfo m_dragMethod = null;
- private FieldInfo m_selectedField = null;
- private FieldInfo m_infoField = null;
-
-#if UNITY_2018_2_OR_NEWER
- public override void OnClosed( Material material )
- {
- base.OnClosed( material );
- CleanUp();
- }
-#endif
-
- void CleanUp()
- {
- if( m_previewRenderUtility != null )
- {
- m_previewRenderUtility.Cleanup();
- m_previewRenderUtility = null;
- }
- }
-
- void UndoRedoPerformed()
- {
- m_refreshOnUndo = true;
- }
-
- ~ASEMaterialInspector()
- {
- Undo.undoRedoPerformed -= UndoRedoPerformed;
- CleanUp();
- }
- public override void OnGUI( MaterialEditor materialEditor, MaterialProperty[] properties )
- {
- IOUtils.Init();
- Material mat = materialEditor.target as Material;
-
- if( mat == null )
- return;
-
- m_instance = materialEditor;
-
- if( !m_initialized )
- {
- Init();
- m_initialized = true;
- Undo.undoRedoPerformed += UndoRedoPerformed;
- }
-
- if( Event.current.type == EventType.Repaint &&
- mat.HasProperty( IOUtils.DefaultASEDirtyCheckId ) &&
- mat.GetInt( IOUtils.DefaultASEDirtyCheckId ) == 1 )
- {
- mat.SetInt( IOUtils.DefaultASEDirtyCheckId, 0 );
- UIUtils.ForceUpdateFromMaterial();
- //Event.current.Use();
- }
-
- if( materialEditor.isVisible )
- {
- GUILayout.BeginVertical();
- {
- GUILayout.Space( 3 );
- if( GUILayout.Button( "Open in Shader Editor" ) )
- {
-#if UNITY_2018_3_OR_NEWER
- ASEPackageManagerHelper.SetupLateMaterial( mat );
-
-#else
- AmplifyShaderEditorWindow.LoadMaterialToASE( mat );
-#endif
- }
-
- GUILayout.BeginHorizontal();
- {
- if( GUILayout.Button( CopyButtonStr ) )
- {
- System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
-
- Shader shader = mat.shader;
- int propertyCount = UnityEditor.ShaderUtil.GetPropertyCount( shader );
- string allProperties = string.Empty;
- for( int i = 0; i < propertyCount; i++ )
- {
- UnityEditor.ShaderUtil.ShaderPropertyType type = UnityEditor.ShaderUtil.GetPropertyType( shader, i );
- string name = UnityEditor.ShaderUtil.GetPropertyName( shader, i );
- string valueStr = string.Empty;
- switch( type )
- {
- case UnityEditor.ShaderUtil.ShaderPropertyType.Color:
- {
- Color value = mat.GetColor( name );
- valueStr = value.r.ToString() + IOUtils.VECTOR_SEPARATOR +
- value.g.ToString() + IOUtils.VECTOR_SEPARATOR +
- value.b.ToString() + IOUtils.VECTOR_SEPARATOR +
- value.a.ToString();
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.Vector:
- {
- Vector4 value = mat.GetVector( name );
- valueStr = value.x.ToString() + IOUtils.VECTOR_SEPARATOR +
- value.y.ToString() + IOUtils.VECTOR_SEPARATOR +
- value.z.ToString() + IOUtils.VECTOR_SEPARATOR +
- value.w.ToString();
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.Float:
- {
- float value = mat.GetFloat( name );
- valueStr = value.ToString();
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.Range:
- {
- float value = mat.GetFloat( name );
- valueStr = value.ToString();
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv:
- {
- Texture value = mat.GetTexture( name );
- valueStr = AssetDatabase.GetAssetPath( value );
- Vector2 offset = mat.GetTextureOffset( name );
- Vector2 scale = mat.GetTextureScale( name );
- valueStr += IOUtils.VECTOR_SEPARATOR + scale.x.ToString() +
- IOUtils.VECTOR_SEPARATOR + scale.y.ToString() +
- IOUtils.VECTOR_SEPARATOR + offset.x.ToString() +
- IOUtils.VECTOR_SEPARATOR + offset.y.ToString();
- }
- break;
- }
-
- allProperties += name + IOUtils.FIELD_SEPARATOR + type + IOUtils.FIELD_SEPARATOR + valueStr;
-
- if( i < ( propertyCount - 1 ) )
- {
- allProperties += IOUtils.LINE_TERMINATOR;
- }
- }
- EditorPrefs.SetString( IOUtils.MAT_CLIPBOARD_ID, allProperties );
- System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
- }
-
- if( GUILayout.Button( PasteButtonStr ) )
- {
- System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
- string propertiesStr = EditorPrefs.GetString( IOUtils.MAT_CLIPBOARD_ID, string.Empty );
- if( !string.IsNullOrEmpty( propertiesStr ) )
- {
- string[] propertyArr = propertiesStr.Split( IOUtils.LINE_TERMINATOR );
- bool validData = true;
- try
- {
- for( int i = 0; i < propertyArr.Length; i++ )
- {
- string[] valuesArr = propertyArr[ i ].Split( IOUtils.FIELD_SEPARATOR );
- if( valuesArr.Length != 3 )
- {
- Debug.LogWarning( "Material clipboard data is corrupted" );
- validData = false;
- break;
- }
- else if( mat.HasProperty( valuesArr[ 0 ] ) )
- {
- UnityEditor.ShaderUtil.ShaderPropertyType type = (UnityEditor.ShaderUtil.ShaderPropertyType)Enum.Parse( typeof( UnityEditor.ShaderUtil.ShaderPropertyType ), valuesArr[ 1 ] );
- switch( type )
- {
- case UnityEditor.ShaderUtil.ShaderPropertyType.Color:
- {
- string[] colorVals = valuesArr[ 2 ].Split( IOUtils.VECTOR_SEPARATOR );
- if( colorVals.Length != 4 )
- {
- Debug.LogWarning( "Material clipboard data is corrupted" );
- validData = false;
- break;
- }
- else
- {
- mat.SetColor( valuesArr[ 0 ], new Color( Convert.ToSingle( colorVals[ 0 ] ),
- Convert.ToSingle( colorVals[ 1 ] ),
- Convert.ToSingle( colorVals[ 2 ] ),
- Convert.ToSingle( colorVals[ 3 ] ) ) );
- }
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.Vector:
- {
- string[] vectorVals = valuesArr[ 2 ].Split( IOUtils.VECTOR_SEPARATOR );
- if( vectorVals.Length != 4 )
- {
- Debug.LogWarning( "Material clipboard data is corrupted" );
- validData = false;
- break;
- }
- else
- {
- mat.SetVector( valuesArr[ 0 ], new Vector4( Convert.ToSingle( vectorVals[ 0 ] ),
- Convert.ToSingle( vectorVals[ 1 ] ),
- Convert.ToSingle( vectorVals[ 2 ] ),
- Convert.ToSingle( vectorVals[ 3 ] ) ) );
- }
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.Float:
- {
- mat.SetFloat( valuesArr[ 0 ], Convert.ToSingle( valuesArr[ 2 ] ) );
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.Range:
- {
- mat.SetFloat( valuesArr[ 0 ], Convert.ToSingle( valuesArr[ 2 ] ) );
- }
- break;
- case UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv:
- {
- string[] texVals = valuesArr[ 2 ].Split( IOUtils.VECTOR_SEPARATOR );
- if( texVals.Length != 5 )
- {
- Debug.LogWarning( "Material clipboard data is corrupted" );
- validData = false;
- break;
- }
- else
- {
- mat.SetTexture( valuesArr[ 0 ], AssetDatabase.LoadAssetAtPath<Texture>( texVals[ 0 ] ) );
- mat.SetTextureScale( valuesArr[ 0 ], new Vector2( Convert.ToSingle( texVals[ 1 ] ), Convert.ToSingle( texVals[ 2 ] ) ) );
- mat.SetTextureOffset( valuesArr[ 0 ], new Vector2( Convert.ToSingle( texVals[ 3 ] ), Convert.ToSingle( texVals[ 4 ] ) ) );
- }
- }
- break;
- }
- }
- }
- }
- catch( Exception e )
- {
- Debug.LogException( e );
- validData = false;
- }
-
-
- if( validData )
- {
- materialEditor.PropertiesChanged();
- UIUtils.CopyValuesFromMaterial( mat );
- }
- else
- {
- EditorPrefs.SetString( IOUtils.MAT_CLIPBOARD_ID, string.Empty );
- }
- }
- System.Threading.Thread.CurrentThread.CurrentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
- }
- }
- GUILayout.EndHorizontal();
- GUILayout.Space( 5 );
- }
- GUILayout.EndVertical();
- }
- EditorGUI.BeginChangeCheck();
- //base.OnGUI( materialEditor, properties );
-
- // Draw custom properties instead of calling BASE to use single line texture properties
- materialEditor.SetDefaultGUIWidths();
-
- if( m_infoField == null )
- {
- m_infoField = typeof( MaterialEditor ).GetField( "m_InfoMessage", BindingFlags.Instance | BindingFlags.NonPublic );
- }
-
- string info = m_infoField.GetValue( materialEditor ) as string;
- if( !string.IsNullOrEmpty( info ) )
- {
- EditorGUILayout.HelpBox( info, MessageType.Info );
- }
- else
- {
- GUIUtility.GetControlID( "EditorTextField".GetHashCode(), FocusType.Passive, new Rect( 0f, 0f, 0f, 0f ) );
- }
-
- for( int i = 0; i < properties.Length; i++ )
- {
- if( ( properties[ i ].flags & ( MaterialProperty.PropFlags.HideInInspector | MaterialProperty.PropFlags.PerRendererData ) ) == MaterialProperty.PropFlags.None )
- {
- // Removed no scale offset one line texture property for consistency :( sad face
- //if( ( properties[ i ].flags & MaterialProperty.PropFlags.NoScaleOffset ) == MaterialProperty.PropFlags.NoScaleOffset )
- //{
- // object obj = MaterialPropertyHandlerEx.GetHandler( mat.shader, properties[ i ].name );
- // if( obj != null )
- // {
- // float height = MaterialPropertyHandlerEx.GetPropertyHeight( obj, properties[ i ], properties[ i ].displayName, materialEditor );
- // //Rect rect = (Rect)materialEditor.GetType().InvokeMember( "GetPropertyRect", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, materialEditor, new object[] { properties[ i ], properties[ i ].displayName, true } );
- // Rect rect = EditorGUILayout.GetControlRect( true, height, EditorStyles.layerMaskField );
- // MaterialPropertyHandlerEx.OnGUI( obj, ref rect, properties[ i ], new GUIContent( properties[ i ].displayName ), materialEditor );
-
- // if( MaterialPropertyHandlerEx.PropertyDrawer( obj ) != null )
- // continue;
-
- // rect = EditorGUILayout.GetControlRect( true, height, EditorStyles.layerMaskField );
- // materialEditor.TexturePropertyMiniThumbnail( rect, properties[ i ], properties[ i ].displayName, string.Empty );
- // }
- // else
- // {
- // materialEditor.TexturePropertySingleLine( new GUIContent( properties[ i ].displayName ), properties[ i ] );
- // }
- //}
- //else
- //{
- float propertyHeight = materialEditor.GetPropertyHeight( properties[ i ], properties[ i ].displayName );
- Rect controlRect = EditorGUILayout.GetControlRect( true, propertyHeight, EditorStyles.layerMaskField, new GUILayoutOption[ 0 ] );
- materialEditor.ShaderProperty( controlRect, properties[ i ], properties[ i ].displayName );
- //}
- }
- }
-
- EditorGUILayout.Space();
- materialEditor.RenderQueueField();
-#if UNITY_5_6_OR_NEWER
- materialEditor.EnableInstancingField();
-#endif
-#if UNITY_5_6_2 || UNITY_5_6_3 || UNITY_5_6_4 || UNITY_2017_1_OR_NEWER
- materialEditor.DoubleSidedGIField();
-#endif
- materialEditor.LightmapEmissionProperty();
- if( m_refreshOnUndo || EditorGUI.EndChangeCheck() )
- {
- m_refreshOnUndo = false;
-
- string isEmissive = mat.GetTag( "IsEmissive", false, "false" );
- if( isEmissive.Equals( "true" ) )
- {
- mat.globalIlluminationFlags &= (MaterialGlobalIlluminationFlags)3;
- }
- else
- {
- mat.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
- }
-
- UIUtils.CopyValuesFromMaterial( mat );
- }
-
- if( materialEditor.RequiresConstantRepaint() && m_lastRenderedTime + 0.032999999821186066 < EditorApplication.timeSinceStartup )
- {
- this.m_lastRenderedTime = EditorApplication.timeSinceStartup;
- materialEditor.Repaint();
- }
- }
-
- private void Init()
- {
- string guid = EditorPrefs.GetString( PreviewModelPref, "" );
- if( !string.IsNullOrEmpty( guid ) )
- {
- m_targetMesh = AssetDatabase.LoadAssetAtPath<Mesh>( AssetDatabase.GUIDToAssetPath( guid ) );
- }
- }
-
- public override void OnMaterialPreviewSettingsGUI( MaterialEditor materialEditor )
- {
-
- base.OnMaterialPreviewSettingsGUI( materialEditor );
-
- if( UnityEditor.ShaderUtil.hardwareSupportsRectRenderTexture )
- {
- EditorGUI.BeginChangeCheck();
- m_targetMesh = (Mesh)EditorGUILayout.ObjectField( m_targetMesh, typeof( Mesh ), false, GUILayout.MaxWidth( 120 ) );
- if( EditorGUI.EndChangeCheck() )
- {
- if( m_targetMesh != null )
- {
- EditorPrefs.SetString( PreviewModelPref, AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_targetMesh ) ) );
- }
- else
- {
- EditorPrefs.SetString( PreviewModelPref, "" );
- }
- }
-
- if( m_selectedField == null )
- {
- m_selectedField = typeof( MaterialEditor ).GetField( "m_SelectedMesh", BindingFlags.Instance | BindingFlags.NonPublic );
- }
-
- m_selectedMesh = (int)m_selectedField.GetValue( materialEditor );
-
- if( m_selectedMesh != 0 )
- {
- if( m_targetMesh != null )
- {
- m_targetMesh = null;
- EditorPrefs.SetString( PreviewModelPref, "" );
- }
- }
- }
- }
-
- public override void OnMaterialInteractivePreviewGUI( MaterialEditor materialEditor, Rect r, GUIStyle background )
- {
- if( Event.current.type == EventType.DragExited )
- {
- if( DragAndDrop.objectReferences.Length > 0 )
- {
- GameObject dropped = DragAndDrop.objectReferences[ 0 ] as GameObject;
- if( dropped != null )
- {
- m_targetMesh = AssetDatabase.LoadAssetAtPath<Mesh>( AssetDatabase.GetAssetPath( dropped ) );
- EditorPrefs.SetString( PreviewModelPref, AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( m_targetMesh ) ) );
- }
- }
- }
-
- if( m_targetMesh == null )
- {
- base.OnMaterialInteractivePreviewGUI( materialEditor, r, background );
- return;
- }
-
- Material mat = materialEditor.target as Material;
-
- if( m_previewRenderUtility == null )
- {
- m_previewRenderUtility = new PreviewRenderUtility();
-#if UNITY_2017_1_OR_NEWER
- m_previewRenderUtility.cameraFieldOfView = 30f;
-#else
- m_previewRenderUtility.m_CameraFieldOfView = 30f;
-#endif
- }
-
- if( m_previewGUIType == null )
- {
- m_previewGUIType = Type.GetType( "PreviewGUI, UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" );
- m_dragMethod = m_previewGUIType.GetMethod( "Drag2D", BindingFlags.Static | BindingFlags.Public );
- }
-
- if( m_modelInspectorType == null )
- {
- m_modelInspectorType = Type.GetType( "UnityEditor.ModelInspector, UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" );
- m_renderMeshMethod = m_modelInspectorType.GetMethod( "RenderMeshPreview", BindingFlags.Static | BindingFlags.NonPublic );
- }
-
- m_previewDir = (Vector2)m_dragMethod.Invoke( m_previewGUIType, new object[] { m_previewDir, r } );
-
- if( Event.current.type == EventType.Repaint )
- {
- m_previewRenderUtility.BeginPreview( r, background );
- m_renderMeshMethod.Invoke( m_modelInspectorType, new object[] { m_targetMesh, m_previewRenderUtility, mat, null, m_previewDir, -1 } );
- m_previewRenderUtility.EndAndDrawPreview( r );
- }
- }
-
- public static MaterialEditor Instance { get { return m_instance; } set { m_instance = value; } }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomMaterialInspector.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomMaterialInspector.cs.meta
deleted file mode 100644
index c587b4c4..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomMaterialInspector.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: a1c012872b428594f95e585bd19e5347
-timeCreated: 1481126958
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomShaderInspector.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomShaderInspector.cs
deleted file mode 100644
index 439f777e..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomShaderInspector.cs
+++ /dev/null
@@ -1,963 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using System;
-using System.Reflection;
-using System.Globalization;
-using UnityEngine;
-using AmplifyShaderEditor;
-
-namespace UnityEditor
-{
- [CustomEditor( typeof( Shader ) )]
- internal class CustomShaderInspector : Editor
- {
- internal class Styles
- {
- public static Texture2D errorIcon = EditorGUIUtilityEx.LoadIcon( "console.erroricon.sml" );
-
- public static Texture2D warningIcon = EditorGUIUtilityEx.LoadIcon( "console.warnicon.sml" );
-
- public static GUIContent showSurface = EditorGUIUtilityEx.TextContent( "Show generated code|Show generated code of a surface shader" );
-
- public static GUIContent showFF = EditorGUIUtilityEx.TextContent( "Show generated code|Show generated code of a fixed function shader" );
-
- public static GUIContent showCurrent = new GUIContent( "Compile and show code | â–¾" );
-
- public static GUIStyle messageStyle = "CN StatusInfo";
-
- public static GUIStyle evenBackground = "CN EntryBackEven";
-
- public static GUIContent no = EditorGUIUtilityEx.TextContent( "no" );
-
- public static GUIContent builtinShader = EditorGUIUtilityEx.TextContent( "Built-in shader" );
-
- public static GUIContent arrayValuePopupButton = EditorGUIUtilityEx.TextContent( "..." );
- }
-
- private const float kSpace = 5f;
-
- const float kValueFieldWidth = 200.0f;
- const float kArrayValuePopupBtnWidth = 25.0f;
-
- private static readonly string[] kPropertyTypes = new string[]
- {
- "Color: ",
- "Vector: ",
- "Float: ",
- "Range: ",
- "Texture: "
- };
-
- private static readonly string[] kTextureTypes = new string[]
- {
- "No Texture?: ",
- "1D?: ",
- "2D: ",
- "3D: ",
- "Cube: ",
- "2DArray: ",
- "Any texture: "
- };
-
- private static readonly int kErrorViewHash = "ShaderErrorView".GetHashCode();
-
- private Vector2 m_ScrollPosition = Vector2.zero;
-
- private PreviewRenderUtility m_previewRenderUtility;
- private Material m_material;
- private Mesh m_previewMesh;
- private Vector2 m_mouseDelta;
- private Transform m_cameraTransform;
-
- private static int m_sliderHashCode = -1;
- private const float MaxDeltaY = 90;
- private const int DefaultMouseSpeed = 1;
- private const int ShiftMouseSpeed = 3;
- private const float DeltaMultiplier = 135f;
- private void ValidateData()
- {
- if ( m_previewRenderUtility == null )
- {
- m_previewRenderUtility = new PreviewRenderUtility();
-#if UNITY_2017_1_OR_NEWER
- m_cameraTransform = m_previewRenderUtility.camera.transform;
-#else
- m_cameraTransform = m_previewRenderUtility.m_Camera.transform;
-#endif
- m_cameraTransform.position = new Vector3( 0, 0, -4 );
- m_cameraTransform.rotation = Quaternion.identity;
- }
-
- if ( m_material == null )
- {
- m_material = new Material( target as Shader );
- m_material.hideFlags = HideFlags.DontSave;
- }
-
- if ( m_previewMesh == null )
- {
- m_previewMesh = Resources.GetBuiltinResource<Mesh>( "Sphere.fbx" );
- }
-
- if ( m_sliderHashCode < 0 )
- {
- "Slider".GetHashCode();
- }
- }
-
- public override bool HasPreviewGUI()
- {
- ValidateData();
- return true;
- }
-
- public static Vector2 CheckMouseMovement( Vector2 scrollPosition, Rect position )
- {
- int controlID = GUIUtility.GetControlID( m_sliderHashCode, FocusType.Passive );
- Event current = Event.current;
- switch ( current.GetTypeForControl( controlID ) )
- {
- case EventType.MouseDown:
- {
- if ( position.Contains( current.mousePosition ) && position.width > 50f )
- {
- GUIUtility.hotControl = controlID;
- current.Use();
- EditorGUIUtility.SetWantsMouseJumping( 1 );
- }
- }
- break;
- case EventType.MouseUp:
- {
- if ( GUIUtility.hotControl == controlID )
- {
- GUIUtility.hotControl = 0;
- }
- EditorGUIUtility.SetWantsMouseJumping( 0 );
- }
- break;
- case EventType.MouseDrag:
- {
- if ( GUIUtility.hotControl == controlID )
- {
- scrollPosition -= DeltaMultiplier * current.delta * ( float ) ( ( current.shift ) ? ShiftMouseSpeed : DefaultMouseSpeed ) / Mathf.Min( position.width, position.height );
- scrollPosition.y = Mathf.Clamp( scrollPosition.y, -MaxDeltaY, MaxDeltaY );
- current.Use();
- }
- }
- break;
- }
- return scrollPosition;
- }
-
- public override void OnPreviewGUI( Rect r, GUIStyle background )
- {
- m_mouseDelta = CheckMouseMovement( m_mouseDelta, r );
-
- if ( Event.current.type == EventType.Repaint )
- {
- m_previewRenderUtility.BeginPreview( r, background );
-
- Texture resultRender = m_previewRenderUtility.EndPreview();
- m_previewRenderUtility.DrawMesh( m_previewMesh, Matrix4x4.identity, m_material, 0 );
- m_cameraTransform.rotation = Quaternion.Euler( new Vector3( -m_mouseDelta.y, -m_mouseDelta.x, 0 ) );
- m_cameraTransform.position = m_cameraTransform.forward * -8f;
-#if UNITY_2017_1_OR_NEWER
- m_previewRenderUtility.camera.Render();
-#else
- m_previewRenderUtility.m_Camera.Render();
-#endif
- GUI.DrawTexture( r, resultRender, ScaleMode.StretchToFill, false );
- }
- }
-
- void OnDestroy()
- {
- CleanUp();
- }
-
- public void OnDisable()
- {
- CleanUp();
- if( m_SrpCompatibilityCheckMaterial != null )
- {
- GameObject.DestroyImmediate( m_SrpCompatibilityCheckMaterial );
- }
- }
-
- void CleanUp()
- {
- if( m_previewRenderUtility != null )
- {
- m_previewRenderUtility.Cleanup();
- m_previewRenderUtility = null;
- }
-
- if( m_previewMesh != null )
- {
- Resources.UnloadAsset( m_previewMesh );
- m_previewMesh = null;
- }
-
- if( m_previewRenderUtility != null )
- {
- m_previewRenderUtility.Cleanup();
- m_previewRenderUtility = null;
- }
- m_material = null;
- }
-
- private Material m_SrpCompatibilityCheckMaterial = null;
- public Material srpCompatibilityCheckMaterial
- {
- get
- {
- if( m_SrpCompatibilityCheckMaterial == null )
- {
- m_SrpCompatibilityCheckMaterial = new Material( target as Shader );
- }
- return m_SrpCompatibilityCheckMaterial;
- }
- }
-
- public virtual void OnEnable()
- {
- Shader s = this.target as Shader;
- if( s!= null )
- ShaderUtilEx.FetchCachedErrors( s );
- }
-
- private static string GetPropertyType( Shader s, int index )
- {
- UnityEditor.ShaderUtil.ShaderPropertyType propertyType = UnityEditor.ShaderUtil.GetPropertyType( s, index );
- if ( propertyType == UnityEditor.ShaderUtil.ShaderPropertyType.TexEnv )
- {
- return CustomShaderInspector.kTextureTypes[ ( int ) UnityEditor.ShaderUtil.GetTexDim( s, index ) ];
- }
- return CustomShaderInspector.kPropertyTypes[ ( int ) propertyType ];
- }
-
- public override void OnInspectorGUI()
- {
- Shader shader = this.target as Shader;
- if ( shader == null )
- {
- return;
- }
-
- GUI.enabled = true;
-
- GUILayout.Space( 3 );
- GUILayout.BeginHorizontal();
- {
- if ( GUILayout.Button( "Open in Shader Editor" ) )
- {
-#if UNITY_2018_3_OR_NEWER
- ASEPackageManagerHelper.SetupLateShader( shader );
-#else
- AmplifyShaderEditorWindow.ConvertShaderToASE( shader );
-#endif
- }
-
- if ( GUILayout.Button( "Open in Text Editor" ) )
- {
- if( UIUtils.IsUnityNativeShader( shader ) )
- {
- Debug.LogWarningFormat( "Action not allowed. Attempting to load the native {0} shader into Text Editor", shader.name );
- }
- else
- {
- AssetDatabase.OpenAsset( shader, 1 );
- }
- }
- }
- GUILayout.EndHorizontal();
-
- GUILayout.Space( 5 );
- EditorGUI.indentLevel = 0;
- this.ShowShaderCodeArea( shader );
- if ( shader.isSupported )
- {
- EditorGUILayout.LabelField( "Cast shadows", ( !ShaderUtilEx.HasShadowCasterPass( shader ) ) ? "no" : "yes", new GUILayoutOption[ 0 ] );
- EditorGUILayout.LabelField( "Render queue", ShaderUtilEx.GetRenderQueue( shader ).ToString( System.Globalization.CultureInfo.InvariantCulture ), new GUILayoutOption[ 0 ] );
- EditorGUILayout.LabelField( "LOD", ShaderUtilEx.GetLOD( shader ).ToString( System.Globalization.CultureInfo.InvariantCulture ), new GUILayoutOption[ 0 ] );
- EditorGUILayout.LabelField( "Ignore projector", ( !ShaderUtilEx.DoesIgnoreProjector( shader ) ) ? "no" : "yes", new GUILayoutOption[ 0 ] );
- string label;
- switch ( ShaderEx.GetDisableBatching( shader ) )
- {
- case DisableBatchingType.False:
- label = "no";
- break;
- case DisableBatchingType.True:
- label = "yes";
- break;
- case DisableBatchingType.WhenLODFading:
- label = "when LOD fading is on";
- break;
- default:
- label = "unknown";
- break;
- }
- EditorGUILayout.LabelField( "Disable batching", label, new GUILayoutOption[ 0 ] );
-#if UNITY_2019_3_OR_NEWER
- ShowKeywords( shader );
- srpCompatibilityCheckMaterial.SetPass( 0 );
-#endif
-
-#if UNITY_2018_3_OR_NEWER
- int shaderActiveSubshaderIndex = ShaderUtilEx.GetShaderActiveSubshaderIndex( shader );
- int sRPBatcherCompatibilityCode = ShaderUtilEx.GetSRPBatcherCompatibilityCode( shader, shaderActiveSubshaderIndex );
- string label2 = ( sRPBatcherCompatibilityCode != 0 ) ? "not compatible" : "compatible";
- EditorGUILayout.LabelField( "SRP Batcher", label2 );
- if( sRPBatcherCompatibilityCode != 0 )
- {
- EditorGUILayout.HelpBox( ShaderUtilEx.GetSRPBatcherCompatibilityIssueReason( shader, shaderActiveSubshaderIndex, sRPBatcherCompatibilityCode ), MessageType.Info );
- }
-#endif
- CustomShaderInspector.ShowShaderProperties( shader );
- }
- }
-#if UNITY_2019_3_OR_NEWER
- private void ShowKeywords( Shader s )
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PrefixLabel( "Keywords", EditorStyles.miniButton );
-
- Rect buttonRect = GUILayoutUtility.GetRect( Styles.arrayValuePopupButton, GUI.skin.button, GUILayout.MinWidth( kValueFieldWidth ) );
- buttonRect.width = kArrayValuePopupBtnWidth;
- if( GUI.Button( buttonRect, Styles.arrayValuePopupButton, EditorStyles.miniButton ) )
- {
- var globalKeywords = ShaderUtilEx.GetShaderGlobalKeywords( s );
- var localKeywords = ShaderUtilEx.GetShaderLocalKeywords( s );
- PopupWindow.Show( buttonRect, new KeywordsPopup( globalKeywords, localKeywords, 150.0f ) );
- }
-
- EditorGUILayout.EndHorizontal();
- }
-#endif
- private void ShowShaderCodeArea( Shader s )
- {
- CustomShaderInspector.ShowSurfaceShaderButton( s );
- CustomShaderInspector.ShowFixedFunctionShaderButton( s );
- this.ShowCompiledCodeButton( s );
- this.ShowShaderErrors( s );
- }
-
- private static void ShowShaderProperties( Shader s )
- {
- GUILayout.Space( 5f );
- GUILayout.Label( "Properties:", EditorStyles.boldLabel, new GUILayoutOption[ 0 ] );
- int propertyCount = UnityEditor.ShaderUtil.GetPropertyCount( s );
- for ( int i = 0; i < propertyCount; i++ )
- {
- string propertyName = UnityEditor.ShaderUtil.GetPropertyName( s, i );
- string label = CustomShaderInspector.GetPropertyType( s, i ) + UnityEditor.ShaderUtil.GetPropertyDescription( s, i );
- EditorGUILayout.LabelField( propertyName, label, new GUILayoutOption[ 0 ] );
- }
- }
-
- internal static void ShaderErrorListUI( UnityEngine.Object shader, ShaderError[] errors, ref Vector2 scrollPosition )
- {
- int num = errors.Length;
- GUILayout.Space( 5f );
- GUILayout.Label( string.Format( "Errors ({0}):", num ), EditorStyles.boldLabel, new GUILayoutOption[ 0 ] );
- int controlID = GUIUtility.GetControlID( CustomShaderInspector.kErrorViewHash, FocusType.Passive );
- float minHeight = Mathf.Min( ( float ) num * 20f + 40f, 150f );
- scrollPosition = GUILayout.BeginScrollView( scrollPosition, GUISkinEx.GetCurrentSkin().box, new GUILayoutOption[]
- {
- GUILayout.MinHeight(minHeight)
- } );
- EditorGUIUtility.SetIconSize( new Vector2( 16f, 16f ) );
- float height = CustomShaderInspector.Styles.messageStyle.CalcHeight( EditorGUIUtilityEx.TempContent( CustomShaderInspector.Styles.errorIcon ), 100f );
- Event current = Event.current;
- for ( int i = 0; i < num; i++ )
- {
- Rect controlRect = EditorGUILayout.GetControlRect( false, height, new GUILayoutOption[ 0 ] );
- string message = errors[ i ].message;
- string platform = errors[ i ].platform;
- bool flag = errors[ i ].warning != 0;
- string lastPathNameComponent = FileUtilEx.GetLastPathNameComponent( errors[ i ].file );
- int line = errors[ i ].line;
- if ( current.type == EventType.MouseDown && current.button == 0 && controlRect.Contains( current.mousePosition ) )
- {
- GUIUtility.keyboardControl = controlID;
- if ( current.clickCount == 2 )
- {
- string file = errors[ i ].file;
- UnityEngine.Object @object = ( !string.IsNullOrEmpty( file ) ) ? AssetDatabase.LoadMainAssetAtPath( file ) : null;
- AssetDatabase.OpenAsset( @object ?? shader, line );
- GUIUtility.ExitGUI();
- }
- current.Use();
- }
- if ( current.type == EventType.ContextClick && controlRect.Contains( current.mousePosition ) )
- {
- current.Use();
- GenericMenu genericMenu = new GenericMenu();
- int errorIndex = i;
- genericMenu.AddItem( new GUIContent( "Copy error text" ), false, delegate
- {
- string text = errors[ errorIndex ].message;
- if ( !string.IsNullOrEmpty( errors[ errorIndex ].messageDetails ) )
- {
- text += '\n';
- text += errors[ errorIndex ].messageDetails;
- }
- EditorGUIUtility.systemCopyBuffer = text;
- } );
- genericMenu.ShowAsContext();
- }
- if ( current.type == EventType.Repaint && ( i & 1 ) == 0 )
- {
- GUIStyle evenBackground = CustomShaderInspector.Styles.evenBackground;
- evenBackground.Draw( controlRect, false, false, false, false );
- }
- Rect rect = controlRect;
- rect.xMin = rect.xMax;
- if ( line > 0 )
- {
- GUIContent content;
- if ( string.IsNullOrEmpty( lastPathNameComponent ) )
- {
- content = EditorGUIUtilityEx.TempContent( line.ToString( System.Globalization.CultureInfo.InvariantCulture ) );
- }
- else
- {
- content = EditorGUIUtilityEx.TempContent( lastPathNameComponent + ":" + line.ToString( System.Globalization.CultureInfo.InvariantCulture ) );
- }
- Vector2 vector = EditorStyles.miniLabel.CalcSize( content );
- rect.xMin -= vector.x;
- GUI.Label( rect, content, EditorStyles.miniLabel );
- rect.xMin -= 2f;
- if ( rect.width < 30f )
- {
- rect.xMin = rect.xMax - 30f;
- }
- }
- Rect position = rect;
- position.width = 0f;
- if ( platform.Length > 0 )
- {
- GUIContent content2 = EditorGUIUtilityEx.TempContent( platform );
- Vector2 vector2 = EditorStyles.miniLabel.CalcSize( content2 );
- position.xMin -= vector2.x;
- Color contentColor = GUI.contentColor;
- GUI.contentColor = new Color( 1f, 1f, 1f, 0.5f );
- GUI.Label( position, content2, EditorStyles.miniLabel );
- GUI.contentColor = contentColor;
- position.xMin -= 2f;
- }
- Rect position2 = controlRect;
- position2.xMax = position.xMin;
- GUI.Label( position2, EditorGUIUtilityEx.TempContent( message, ( !flag ) ? CustomShaderInspector.Styles.errorIcon : CustomShaderInspector.Styles.warningIcon ), CustomShaderInspector.Styles.messageStyle );
- }
- EditorGUIUtility.SetIconSize( Vector2.zero );
- GUILayout.EndScrollView();
- }
-
-#if UNITY_2019_3_OR_NEWER
- ShaderMessage[] m_ShaderMessages;
-#endif
- private void ShowShaderErrors( Shader s )
- {
-#if UNITY_2019_3_OR_NEWER
- if( Event.current.type == EventType.Layout )
- {
- int n = ShaderUtil.GetShaderMessageCount( s );
- m_ShaderMessages = null;
- if( n >= 1 )
- {
- m_ShaderMessages = ShaderUtil.GetShaderMessages( s );
- }
- }
-
- if( m_ShaderMessages == null )
- return;
-
- ShaderInspectorEx.ShaderErrorListUI( s, m_ShaderMessages, ref this.m_ScrollPosition );
-#else
- int shaderErrorCount = ShaderUtilEx.GetShaderErrorCount( s );
- if ( shaderErrorCount < 1 )
- {
- return;
- }
- CustomShaderInspector.ShaderErrorListUI( s, ShaderUtilEx.GetShaderErrors( s ), ref this.m_ScrollPosition );
-#endif
- }
-
- private void ShowCompiledCodeButton( Shader s )
- {
- EditorGUILayout.BeginHorizontal( new GUILayoutOption[ 0 ] );
- EditorGUILayout.PrefixLabel( "Compiled code", EditorStyles.miniButton );
- bool flag = ShaderUtilEx.HasShaderSnippets( s ) || ShaderUtilEx.HasSurfaceShaders( s ) || ShaderUtilEx.HasFixedFunctionShaders( s );
- if ( flag )
- {
- GUIContent showCurrent = CustomShaderInspector.Styles.showCurrent;
- Rect rect = GUILayoutUtility.GetRect( showCurrent, EditorStyles.miniButton, new GUILayoutOption[]
- {
- GUILayout.ExpandWidth(false)
- } );
- Rect position = new Rect( rect.xMax - 16f, rect.y, 16f, rect.height );
- if ( EditorGUIEx.ButtonMouseDown( position, GUIContent.none, FocusType.Passive, GUIStyle.none ) )
- {
- Rect last = GUILayoutUtilityEx.TopLevel_GetLast();
- PopupWindow.Show( last, ( PopupWindowContent ) Activator.CreateInstance( System.Type.GetType( "UnityEditor.ShaderInspectorPlatformsPopup, UnityEditor" ), new object[] { s } ) );
- GUIUtility.ExitGUI();
- }
- if ( GUI.Button( rect, showCurrent, EditorStyles.miniButton ) )
- {
- ShaderUtilEx.OpenCompiledShader( s, ShaderInspectorPlatformsPopupEx.GetCurrentMode(), ShaderInspectorPlatformsPopupEx.GetCurrentPlatformMask(), ShaderInspectorPlatformsPopupEx.GetCurrentVariantStripping() == 0 );
- GUIUtility.ExitGUI();
- }
- }
- else
- {
- GUILayout.Button( "none (precompiled shader)", GUI.skin.label, new GUILayoutOption[ 0 ] );
- }
- EditorGUILayout.EndHorizontal();
- }
-
- private static void ShowSurfaceShaderButton( Shader s )
- {
- bool flag = ShaderUtilEx.HasSurfaceShaders( s );
- EditorGUILayout.BeginHorizontal( new GUILayoutOption[ 0 ] );
- EditorGUILayout.PrefixLabel( "Surface shader", EditorStyles.miniButton );
- if ( flag )
- {
- if ( !( AssetImporter.GetAtPath( AssetDatabase.GetAssetPath( s ) ) == null ) )
- {
- if ( GUILayout.Button( CustomShaderInspector.Styles.showSurface, EditorStyles.miniButton, new GUILayoutOption[]
- {
- GUILayout.ExpandWidth(false)
- } ) )
- {
- ShaderUtilEx.OpenParsedSurfaceShader( s );
- GUIUtility.ExitGUI();
- }
- }
- else
- {
- GUILayout.Button( CustomShaderInspector.Styles.builtinShader, GUI.skin.label, new GUILayoutOption[ 0 ] );
- }
- }
- else
- {
- GUILayout.Button( CustomShaderInspector.Styles.no, GUI.skin.label, new GUILayoutOption[ 0 ] );
- }
- EditorGUILayout.EndHorizontal();
- }
-
- private static void ShowFixedFunctionShaderButton( Shader s )
- {
- bool flag = ShaderUtilEx.HasFixedFunctionShaders( s );
- EditorGUILayout.BeginHorizontal( new GUILayoutOption[ 0 ] );
- EditorGUILayout.PrefixLabel( "Fixed function", EditorStyles.miniButton );
- if ( flag )
- {
- if ( !( AssetImporter.GetAtPath( AssetDatabase.GetAssetPath( s ) ) == null ) )
- {
- if ( GUILayout.Button( CustomShaderInspector.Styles.showFF, EditorStyles.miniButton, new GUILayoutOption[]
- {
- GUILayout.ExpandWidth(false)
- } ) )
- {
- ShaderUtilEx.OpenGeneratedFixedFunctionShader( s );
- GUIUtility.ExitGUI();
- }
- }
- else
- {
- GUILayout.Button( CustomShaderInspector.Styles.builtinShader, GUI.skin.label, new GUILayoutOption[ 0 ] );
- }
- }
- else
- {
- GUILayout.Button( CustomShaderInspector.Styles.no, GUI.skin.label, new GUILayoutOption[ 0 ] );
- }
- EditorGUILayout.EndHorizontal();
- }
- }
-
- internal class KeywordsPopup : PopupWindowContent
- {
- private Vector2 m_ScrollPos = Vector2.zero;
- private string[] m_GlobalKeywords;
- private string[] m_LocalKeywords;
- private bool m_GlobalKeywordsExpended;
- private bool m_LocalKeywordsExpended;
- private float m_WindowWidth;
-
- private static readonly GUIStyle m_Style = EditorStyles.miniLabel;
-
- public KeywordsPopup( string[] globalKeywords, string[] localKeywords, float windowWidth )
- {
- m_GlobalKeywords = globalKeywords;
- m_LocalKeywords = localKeywords;
- m_GlobalKeywordsExpended = true;
- m_LocalKeywordsExpended = true;
- m_WindowWidth = windowWidth;
- }
-
- public override Vector2 GetWindowSize()
- {
- var numValues = m_GlobalKeywords.Length + m_LocalKeywords.Length + 2;
- var lineHeight = m_Style.lineHeight + m_Style.padding.vertical + m_Style.margin.top;
- return new Vector2( m_WindowWidth, Math.Min( lineHeight * numValues, 250.0f ) );
- }
-
- public override void OnGUI( Rect rect )
- {
- m_ScrollPos = EditorGUILayout.BeginScrollView( m_ScrollPos );
-
- m_GlobalKeywordsExpended = KeywordsFoldout( m_GlobalKeywordsExpended, "Global Keywords", m_GlobalKeywords );
- m_LocalKeywordsExpended = KeywordsFoldout( m_LocalKeywordsExpended, "Local Keywords", m_LocalKeywords );
-
- EditorGUILayout.EndScrollView();
- }
-
- private bool KeywordsFoldout( bool expended, string name, string[] values )
- {
- expended = EditorGUILayout.Foldout( expended, name, true, m_Style );
-
- if( expended )
- {
- EditorGUI.indentLevel++;
- for( int i = 0; i < values.Length; ++i )
- {
- EditorGUILayout.LabelField( values[ i ], m_Style );
- }
- EditorGUI.indentLevel--;
- }
-
- return expended;
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // UNITY EDITOR EXTENSIONS
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- public enum DisableBatchingType
- {
- False,
- True,
- WhenLODFading
- }
-
- public struct ShaderError
- {
- public string message;
- public string messageDetails;
- public string platform;
- public string file;
- public int line;
- public int warning;
- }
-
- public static class EditorGUIUtilityEx
- {
- private static System.Type type = null;
- public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEditor.EditorGUIUtility, UnityEditor" ) : type; } }
-
- public static Texture2D LoadIcon( string icon )
- {
- return ( Texture2D ) EditorGUIUtilityEx.Type.InvokeMember( "LoadIcon", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { icon } );
- }
-
- public static GUIContent TextContent( string t )
- {
- return ( GUIContent ) EditorGUIUtilityEx.Type.InvokeMember( "TextContent", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { t } );
- }
-
- internal static GUIContent TempContent( string t )
- {
- return ( GUIContent ) EditorGUIUtilityEx.Type.InvokeMember( "TempContent", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { t } );
- }
-
- internal static GUIContent TempContent( Texture i )
- {
- return ( GUIContent ) EditorGUIUtilityEx.Type.InvokeMember( "TempContent", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { i } );
- }
-
- internal static GUIContent TempContent( string t, Texture i )
- {
- return ( GUIContent ) EditorGUIUtilityEx.Type.InvokeMember( "TempContent", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { t, i } );
- }
- }
-
- public static class EditorGUILayoutEx
- {
- public static System.Type Type = typeof( EditorGUILayout );
- public static Gradient GradientField( Gradient value, params GUILayoutOption[] options )
- {
-#if UNITY_2018_3_OR_NEWER
- return EditorGUILayout.GradientField( value, options );
-#else
- MethodInfo method = EditorGUILayoutEx.Type.GetMethod( "GradientField", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof( Gradient ), typeof( GUILayoutOption[] ) }, null );
- return (Gradient)method.Invoke( Type, new object[]{ value, options} );
-#endif
- }
-
- public static Gradient GradientField( string label, Gradient value, params GUILayoutOption[] options )
- {
-#if UNITY_2018_3_OR_NEWER
- return EditorGUILayout.GradientField( label, value, options );
-#else
- MethodInfo method = EditorGUILayoutEx.Type.GetMethod( "GradientField", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof( string ), typeof( Gradient ), typeof( GUILayoutOption[] ) }, null );
- return (Gradient)method.Invoke( Type, new object[] { label, value, options } );
-#endif
- }
- }
-
- public static class GUILayoutUtilityEx
- {
- private static System.Type type = null;
- public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEngine.GUILayoutUtility, UnityEngine" ) : type; } }
-
- public static Rect TopLevel_GetLast()
- {
- System.Type guiLayoutGroup = System.Type.GetType( "UnityEngine.GUILayoutGroup, UnityEngine" );
- var topLevel = GUILayoutUtilityEx.Type.GetProperty( "topLevel", BindingFlags.NonPublic | BindingFlags.Static ).GetValue( null, null );
- return ( Rect ) guiLayoutGroup.InvokeMember( "GetLast", BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, topLevel, new object[] { } );
- }
- }
-
- public static class ShaderEx
- {
- private static System.Type type = null;
- public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEngine.Shader, UnityEngine" ) : type; } }
-
- public static DisableBatchingType GetDisableBatching( Shader s )
- {
- return ( DisableBatchingType ) ShaderEx.Type.GetProperty( "disableBatching", BindingFlags.NonPublic | BindingFlags.Instance ).GetValue( s, new object[ 0 ] );
- }
- }
-
- public static class ShaderUtilEx
- {
- private static System.Type type = null;
- public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEditor.ShaderUtil, UnityEditor" ) : type; } }
-
- public static void OpenParsedSurfaceShader( Shader s )
- {
- ShaderUtilEx.Type.InvokeMember( "OpenParsedSurfaceShader", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
- }
-
- public static void OpenGeneratedFixedFunctionShader( Shader s )
- {
- ShaderUtilEx.Type.InvokeMember( "OpenGeneratedFixedFunctionShader", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
- }
-
- public static void OpenCompiledShader( Shader shader, int mode, int customPlatformsMask, bool includeAllVariants )
- {
- ShaderUtilEx.Type.InvokeMember( "OpenCompiledShader", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { shader, mode, customPlatformsMask, includeAllVariants } );
- }
-
- public static void FetchCachedErrors( Shader s )
- {
-#if UNITY_2019_3_OR_NEWER
- ShaderUtilEx.Type.InvokeMember( "FetchCachedMessages", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
-#else
- ShaderUtilEx.Type.InvokeMember( "FetchCachedErrors", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
-#endif
- }
-
- public static string[] GetShaderGlobalKeywords( Shader s )
- {
- return ShaderUtilEx.Type.InvokeMember( "GetShaderGlobalKeywords", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } ) as string[];
- }
-
- public static string[] GetShaderLocalKeywords( Shader s )
- {
- return ShaderUtilEx.Type.InvokeMember( "GetShaderLocalKeywords", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } ) as string[];
- }
-
- public static int GetShaderErrorCount( Shader s )
- {
-#if UNITY_2019_3_OR_NEWER
- return ShaderUtil.GetShaderMessageCount( s );
-#else
- return ( int ) ShaderUtilEx.Type.InvokeMember( "GetShaderErrorCount", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
-#endif
- }
-
- public static int GetAvailableShaderCompilerPlatforms()
- {
- return (int)ShaderUtilEx.Type.InvokeMember( "GetAvailableShaderCompilerPlatforms", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { } );
- }
-
- public static ShaderError[] GetShaderErrors( Shader s )
- {
- System.Type shaderErrorType = System.Type.GetType( "UnityEditor.ShaderError, UnityEditor" );
- var errorList = ( System.Collections.IList ) ShaderUtilEx.Type.InvokeMember( "GetShaderErrors", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
-
- FieldInfo messageField = shaderErrorType.GetField( "message", BindingFlags.Public | BindingFlags.Instance );
- FieldInfo messageDetailsField = shaderErrorType.GetField( "messageDetails", BindingFlags.Public | BindingFlags.Instance );
- FieldInfo platformField = shaderErrorType.GetField( "platform", BindingFlags.Public | BindingFlags.Instance );
- FieldInfo fileField = shaderErrorType.GetField( "file", BindingFlags.Public | BindingFlags.Instance );
- FieldInfo lineField = shaderErrorType.GetField( "line", BindingFlags.Public | BindingFlags.Instance );
- FieldInfo warningField = shaderErrorType.GetField( "warning", BindingFlags.Public | BindingFlags.Instance );
-
- ShaderError[] errors = new ShaderError[ errorList.Count ];
- for ( int i = 0; i < errorList.Count; i++ )
- {
- errors[ i ].message = ( string ) messageField.GetValue( errorList[ i ] );
- errors[ i ].messageDetails = ( string ) messageDetailsField.GetValue( errorList[ i ] );
- errors[ i ].platform = ( string ) platformField.GetValue( errorList[ i ] );
- errors[ i ].file = ( string ) fileField.GetValue( errorList[ i ] );
- errors[ i ].line = ( int ) lineField.GetValue( errorList[ i ] );
- errors[ i ].warning = ( int ) warningField.GetValue( errorList[ i ] );
- }
- return errors;
- }
-
- public static bool HasShaderSnippets( Shader s )
- {
- return ( bool ) ShaderUtilEx.Type.InvokeMember( "HasShaderSnippets", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
- }
-
- public static bool HasSurfaceShaders( Shader s )
- {
- return ( bool ) ShaderUtilEx.Type.InvokeMember( "HasSurfaceShaders", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
- }
-
- public static bool HasFixedFunctionShaders( Shader s )
- {
- return ( bool ) ShaderUtilEx.Type.InvokeMember( "HasFixedFunctionShaders", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
- }
-
- public static bool HasShadowCasterPass( Shader s )
- {
- return ( bool ) ShaderUtilEx.Type.InvokeMember( "HasShadowCasterPass", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
- }
-
- public static int GetRenderQueue( Shader s )
- {
- return ( int ) ShaderUtilEx.Type.InvokeMember( "GetRenderQueue", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
- }
-
- public static int GetLOD( Shader s )
- {
- return ( int ) ShaderUtilEx.Type.InvokeMember( "GetLOD", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
- }
-
- public static bool DoesIgnoreProjector( Shader s )
- {
- return ( bool ) ShaderUtilEx.Type.InvokeMember( "DoesIgnoreProjector", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
- }
-
-#if UNITY_2018_3_OR_NEWER
- public static int GetShaderActiveSubshaderIndex( Shader s )
- {
- return (int)ShaderUtilEx.Type.InvokeMember( "GetShaderActiveSubshaderIndex", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s } );
- }
-
- public static int GetSRPBatcherCompatibilityCode( Shader s, int subShaderIdx )
- {
- return (int)ShaderUtilEx.Type.InvokeMember( "GetSRPBatcherCompatibilityCode", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s, subShaderIdx } );
- }
-
- public static string GetSRPBatcherCompatibilityIssueReason( Shader s, int subShaderIdx, int err )
- {
- return (string)ShaderUtilEx.Type.InvokeMember( "GetSRPBatcherCompatibilityIssueReason", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { s, subShaderIdx, err } );
- }
-#endif
- }
-
- public static class FileUtilEx
- {
- private static System.Type type = null;
- public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEditor.FileUtil, UnityEditor" ) : type; } }
-
- public static string GetLastPathNameComponent( string path )
- {
- return ( string ) FileUtilEx.Type.InvokeMember( "GetLastPathNameComponent", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { path } );
- }
- }
-
- public static class ShaderInspectorEx
- {
- private static System.Type type = null;
- public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEditor.ShaderInspector, UnityEditor" ) : type; } }
-
-#if UNITY_2019_3_OR_NEWER
- public static void ShaderErrorListUI( UnityEngine.Object shader, ShaderMessage[] messages, ref Vector2 scrollPosition )
- {
- Type.InvokeMember( "ShaderErrorListUI", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { shader, messages, scrollPosition } );
- }
-#endif
- }
-
- public static class GUISkinEx
- {
- private static System.Type type = null;
- public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEngine.GUISkin, UnityEngine" ) : type; } }
-
- public static GUISkin GetCurrentSkin()
- {
- return ( GUISkin ) GUISkinEx.Type.GetField( "current", BindingFlags.NonPublic | BindingFlags.Static ).GetValue( null );
- }
- }
-
- public static class EditorGUIEx
- {
- public static System.Type Type = typeof( EditorGUI );
-
- public static Gradient GradientField( Rect position, Gradient gradient )
- {
-#if UNITY_2018_3_OR_NEWER
- return EditorGUI.GradientField( position, gradient );
-#else
- return (Gradient)EditorGUIEx.Type.InvokeMember( "GradientField", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { position, gradient } );
-#endif
- }
-
- public static bool ButtonMouseDown( Rect position, GUIContent content, FocusType focusType, GUIStyle style )
- {
-#if UNITY_5_6_OR_NEWER
- return EditorGUI.DropdownButton( position, content, focusType, style );
-#else
- return ( bool ) EditorGUIEx.Type.InvokeMember( "ButtonMouseDown", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { position, content, focusType, style } );
-#endif
- }
-
- public static float kObjectFieldMiniThumbnailHeight
- {
- get
- {
- return (float)EditorGUIEx.Type.InvokeMember( "kObjectFieldMiniThumbnailHeight", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetField, null, null, new object[] {} );
- }
- }
-
- public static float kSingleLineHeight
- {
- get
- {
- return (float)EditorGUIEx.Type.InvokeMember( "kSingleLineHeight", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.GetField, null, null, new object[] { } );
- }
- }
-
- }
-
- public static class ShaderInspectorPlatformsPopupEx
- {
- private static System.Type type = null;
- public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEditor.ShaderInspectorPlatformsPopup, UnityEditor" ) : type; } }
-
- public static int GetCurrentMode()
- {
- return ( int ) ShaderInspectorPlatformsPopupEx.Type.GetProperty( "currentMode", BindingFlags.Public | BindingFlags.Static ).GetValue( null, null );
- }
-
- public static int GetCurrentPlatformMask()
- {
- return ( int ) ShaderInspectorPlatformsPopupEx.Type.GetProperty( "currentPlatformMask", BindingFlags.Public | BindingFlags.Static ).GetValue( null, null );
- }
-
- public static int GetCurrentVariantStripping()
- {
- return ( int ) ShaderInspectorPlatformsPopupEx.Type.GetProperty( "currentVariantStripping", BindingFlags.Public | BindingFlags.Static ).GetValue( null, null );
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomShaderInspector.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomShaderInspector.cs.meta
deleted file mode 100644
index 06851759..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomShaderInspector.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 641dff721f3c24c4188f01fea49484cb
-timeCreated: 1481126956
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomTexture2DArrayInspector.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomTexture2DArrayInspector.cs
deleted file mode 100644
index b43ee4e2..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomTexture2DArrayInspector.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-#if !UNITY_2019_1_OR_NEWER
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEditor;
-
-namespace AmplifyShaderEditor
-{
- [CustomEditor( typeof( Texture2DArray ) )]
- public class CustomTexture2DArrayInspector : Editor
- {
- Texture2DArray m_target;
- [SerializeField]
- float m_index;
- Shader m_textureArrayPreview;
- Material m_previewMaterial;
- GUIStyle slider = null;
- GUIStyle thumb = null;
- GUIContent m_allButton = null;
- [SerializeField]
- bool m_seeAll;
- void OnEnable()
- {
- m_target = ( target as Texture2DArray );
- m_textureArrayPreview = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "610c24aad350fba4583068c6c22fa428" ) );
- m_previewMaterial = new Material( m_textureArrayPreview );
- slider = null;
- thumb = null;
- }
-
- public override void OnPreviewGUI( Rect r, GUIStyle background )
- {
- base.OnPreviewGUI( r, background );
- m_previewMaterial.SetTexture( "_MainTex", m_target );
- m_previewMaterial.SetFloat( "_Index", m_index );
- EditorGUI.DrawPreviewTexture( r, m_target, m_previewMaterial, ScaleMode.ScaleToFit, 1f );
- }
-
- private void OnDisable()
- {
- DestroyImmediate( m_previewMaterial );
- m_previewMaterial = null;
- }
-
- public override void OnInspectorGUI()
- {
- if( slider == null )
- slider = "preSlider";
-
- if( thumb == null )
- thumb = "preSliderThumb";
-
- if( m_allButton == null )
- m_allButton = EditorGUIUtility.IconContent( "PreTextureMipMapLow" );
-
- base.OnInspectorGUI();
- }
-
- public override bool HasPreviewGUI()
- {
- return true;
- }
-
- public override void OnPreviewSettings()
- {
- base.OnPreviewSettings();
- m_seeAll = GUILayout.Toggle( m_seeAll, m_allButton, "preButton" );
- EditorGUI.BeginDisabledGroup( m_seeAll );
- m_index = Mathf.Round( GUILayout.HorizontalSlider( m_index, 0, m_target.depth - 1, slider, thumb ) );
- EditorGUI.EndDisabledGroup();
- }
-
- public override void OnInteractivePreviewGUI( Rect r, GUIStyle background )
- {
- //base.OnInteractivePreviewGUI( r, background );
- if( m_seeAll )
- {
- int columns = Mathf.CeilToInt( Mathf.Sqrt( m_target.depth ) );
- float sizeX = r.width / columns - 20;
- float centerY = ( columns * columns ) - m_target.depth;
- int rows = columns;
- if( centerY >= columns )
- rows--;
- float sizeY = ( r.height - 16 ) / rows - 15;
-
- if( centerY >= columns )
- centerY = sizeY * 0.5f;
- else
- centerY = 0;
-
- Rect smallRect = r;
- if( rows > 1 )
- smallRect.y += ( 15 / ( rows - 1 ) );
- else
- smallRect.y += 15;
- smallRect.x = r.x + 10;
- smallRect.width = sizeX;
- smallRect.height = sizeY;
-
- for( int i = 0; i < m_target.depth; i++ )
- {
- m_previewMaterial.SetTexture( "_MainTex", m_target );
- m_previewMaterial.SetFloat( "_Index", i );
- EditorGUI.DrawPreviewTexture( smallRect, m_target, m_previewMaterial, ScaleMode.ScaleToFit, 1 );
- Rect dropRect = smallRect;
-
- float diff = smallRect.height - smallRect.width;
- if( diff > 0 )
- dropRect.y -= diff * 0.5f;
- dropRect.y += 16;
- EditorGUI.DropShadowLabel( dropRect, "[" + i + "]" );
-
- smallRect.x += sizeX + 20;
- if( ( ( i + 1 ) % ( columns ) ) == 0 )
- {
- smallRect.x = r.x + 10;
- smallRect.height = sizeY;
- smallRect.y += sizeY + 30;
- }
- }
- }
- else
- {
- m_previewMaterial.SetTexture( "_MainTex", m_target );
- m_previewMaterial.SetFloat( "_Index", m_index );
- EditorGUI.DrawPreviewTexture( r, m_target, m_previewMaterial, ScaleMode.ScaleToFit, 1f );
- EditorGUI.DropShadowLabel( r, "[" + m_index + "]" );
- }
- }
- }
-}
-#endif
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomTexture2DArrayInspector.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomTexture2DArrayInspector.cs.meta
deleted file mode 100644
index 7149ec03..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/CustomTexture2DArrayInspector.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 871ecf36e52b267449b9047596793d6f
-timeCreated: 1517913060
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/EditorVariablesManager.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/EditorVariablesManager.cs
deleted file mode 100644
index 7b9c67c6..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/EditorVariablesManager.cs
+++ /dev/null
@@ -1,254 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using UnityEditor;
-using System;
-using UnityEngine;
-
-namespace AmplifyShaderEditor
-{
- public class EditorVariable<T>
- {
- protected string m_labelName;
- protected string m_name;
- protected T m_value;
- protected T m_defaultValue;
-
- public EditorVariable( string name, string labelName, T defaultValue ) { m_name = name; m_labelName = labelName; m_defaultValue = defaultValue; m_value = defaultValue; }
- public string Name { get { return m_name; } }
-
- public virtual T Value
- {
- get { return m_value; }
- set
- {
- m_value = value;
- }
- }
- public string LabelName { get { return m_labelName; } }
- }
-
- public sealed class EditorVariableFloat : EditorVariable<float>
- {
- public EditorVariableFloat( string name, string labelName, float defaultValue ) : base( name, labelName, defaultValue )
- {
- m_value = EditorPrefs.GetFloat( name, m_defaultValue );
- }
-
- public override float Value
- {
- get { return m_value; }
- set
- {
- if( m_value != value )
- {
- m_value = value;
- EditorPrefs.SetFloat( m_name, m_value );
- }
- }
- }
- }
-
- public sealed class EditorVariableBool : EditorVariable<bool>
- {
- public EditorVariableBool( string name, string labelName, bool defaultValue ) : base( name, labelName, defaultValue )
- {
- m_value = EditorPrefs.GetBool( name, m_defaultValue );
- }
-
- public override bool Value
- {
- get { return m_value; }
- set
- {
- if( m_value != value )
- {
- m_value = value;
- EditorPrefs.SetBool( m_name, m_value );
- }
- }
- }
- }
-
- public sealed class EditorVariableInt : EditorVariable<int>
- {
- public EditorVariableInt( string name, string labelName, int defaultValue ) : base( name, labelName, defaultValue )
- {
- m_value = EditorPrefs.GetInt( name, m_defaultValue );
- }
-
- public override int Value
- {
- get { return m_value; }
- set
- {
- if( m_value != value )
- {
- m_value = value;
- EditorPrefs.SetInt( m_name, m_value );
- }
- }
- }
- }
-
- public sealed class EditorVariableString : EditorVariable<string>
- {
- public EditorVariableString( string name, string labelName, string defaultValue ) : base( name, labelName, defaultValue )
- {
- m_value = EditorPrefs.GetString( name, m_defaultValue );
- }
-
- public override string Value
- {
- get { return m_value; }
- set
- {
- if( !m_value.Equals( value ) )
- {
- m_value = value;
- EditorPrefs.SetString( m_name, m_value );
- }
- }
- }
- }
-
- public class EditorVariablesManager
- {
- public static EditorVariableBool LiveMode = new EditorVariableBool( "ASELiveMode", "LiveMode", false );
- public static EditorVariableBool OutlineActiveMode = new EditorVariableBool( "ASEOutlineActiveMode", " Outline", false );
- public static EditorVariableBool NodeParametersMaximized = new EditorVariableBool( "ASENodeParametersVisible", " NodeParameters", true );
- public static EditorVariableBool NodePaletteMaximized = new EditorVariableBool( "ASENodePaletteVisible", " NodePalette", true );
- public static EditorVariableBool ExpandedRenderingPlatforms = new EditorVariableBool( "ASEExpandedRenderingPlatforms", " ExpandedRenderingPlatforms", false );
- public static EditorVariableBool ExpandedRenderingOptions = new EditorVariableBool( "ASEExpandedRenderingOptions", " ExpandedRenderingPlatforms", false );
- public static EditorVariableBool ExpandedGeneralShaderOptions = new EditorVariableBool( "ASEExpandedGeneralShaderOptions", " ExpandedGeneralShaderOptions", false );
- public static EditorVariableBool ExpandedBlendOptions = new EditorVariableBool( "ASEExpandedBlendOptions", " ExpandedBlendOptions", false );
- public static EditorVariableBool ExpandedStencilOptions = new EditorVariableBool( "ASEExpandedStencilOptions", " ExpandedStencilOptions", false );
- public static EditorVariableBool ExpandedVertexOptions = new EditorVariableBool( "ASEExpandedVertexOptions", " ExpandedVertexOptions", false );
- public static EditorVariableBool ExpandedFunctionInputs = new EditorVariableBool( "ASEExpandedFunctionInputs", " ExpandedFunctionInputs", false );
- public static EditorVariableBool ExpandedFunctionSwitches = new EditorVariableBool( "ASEExpandedFunctionSwitches", " ExpandedFunctionSwitches", false );
- public static EditorVariableBool ExpandedFunctionOutputs = new EditorVariableBool( "ASEExpandedFunctionOutputs", " ExpandedFunctionOutputs", false );
- public static EditorVariableBool ExpandedAdditionalIncludes = new EditorVariableBool( "ASEExpandedAdditionalIncludes", " ExpandedAdditionalIncludes", false );
- public static EditorVariableBool ExpandedAdditionalDefines = new EditorVariableBool( "ASEExpandedAdditionalDefines", " ExpandedAdditionalDefines", false );
- public static EditorVariableBool ExpandedAdditionalDirectives = new EditorVariableBool( "ASEExpandedAdditionalDirectives", " ExpandedAdditionalDirectives", false );
- public static EditorVariableBool ExpandedCustomTags = new EditorVariableBool( "ASEExpandedCustomTags", " ExpandedCustomTags", false );
- public static EditorVariableBool ExpandedAdditionalSurfaceOptions = new EditorVariableBool( "ASEExpandedAdditionalSurfaceOptions", " ExpandedAdditionalSurfaceOptions", false );
- public static EditorVariableBool ExpandedAdditionalPragmas = new EditorVariableBool( "ASEExpandedAdditionalPragmas", " ExpandedAdditionalPragmas", false );
- public static EditorVariableBool ExpandedDependencies = new EditorVariableBool( "ASEExpandedDependencies", " ExpandedDependencies", false );
- public static EditorVariableBool ExpandedDepth = new EditorVariableBool( "ASEExpandedDepth", " ExpandedDepth", false );
- public static EditorVariableBool ExpandedTesselation = new EditorVariableBool( "ASEExpandedTesselation", " ExpandedTesselation", false );
- public static EditorVariableBool ExpandedProperties = new EditorVariableBool( "ASEExpandedProperties", " ExpandedProperties", false );
- public static EditorVariableBool ExpandedUsePass = new EditorVariableBool( "ASEUsePass", " UsePass", false );
- //Templates
- public static EditorVariableBool ExpandedBlendModeModule = new EditorVariableBool( "ASEExpandedBlendModeModule", " ExpandedBlendModeModule", false );
- }
-
- [Serializable]
- public class InnerWindowEditorVariables
- {
- [SerializeField]
- private bool m_liveMode = false;
- [SerializeField]
- private bool m_outlineActiveMode = false;
- [SerializeField]
- private bool m_nodeParametersMaximized = false;
- [SerializeField]
- private bool m_nodePaletteMaximized = false;
- [SerializeField]
- private bool m_expandedRenderingPlatforms = false;
- [SerializeField]
- private bool m_expandedRenderingOptions = false;
- [SerializeField]
- private bool m_expandedGeneralShaderOptions = false;
- [SerializeField]
- private bool m_expandedBlendOptions = false;
- [SerializeField]
- private bool m_expandedStencilOptions = false;
- [SerializeField]
- private bool m_expandedVertexOptions = false;
- [SerializeField]
- private bool m_expandedFunctionInputs = false;
- [SerializeField]
- private bool m_expandedFunctionSwitches = false;
- [SerializeField]
- private bool m_expandedFunctionOutputs = false;
- [SerializeField]
- private bool m_expandedAdditionalIncludes = false;
- [SerializeField]
- private bool m_expandedAdditionalDefines = false;
- [SerializeField]
- private bool m_expandedAdditionalDirectives = false;
- [SerializeField]
- private bool m_expandedCustomTags = false;
- [SerializeField]
- private bool m_expandedAdditionalSurfaceOptions = false;
- [SerializeField]
- private bool m_expandedAdditionalPragmas = false;
- [SerializeField]
- private bool m_expandedDependencies = false;
- [SerializeField]
- private bool m_expandedBlendModeModule = false;
- [SerializeField]
- private bool m_expandedDepth = false;
- [SerializeField]
- private bool m_expandedTesselation = false;
- [SerializeField]
- private bool m_expandedProperties = false;
- [SerializeField]
- private bool m_expandedUsePass = false;
-
- public void Initialize()
- {
- m_liveMode = EditorVariablesManager.LiveMode.Value;
- m_outlineActiveMode = EditorVariablesManager.OutlineActiveMode.Value;
- m_nodeParametersMaximized = EditorVariablesManager.NodeParametersMaximized.Value;
- m_nodePaletteMaximized = EditorVariablesManager.NodePaletteMaximized.Value;
- m_expandedRenderingPlatforms = EditorVariablesManager.ExpandedRenderingPlatforms.Value;
- m_expandedRenderingOptions = EditorVariablesManager.ExpandedRenderingOptions.Value;
- m_expandedGeneralShaderOptions = EditorVariablesManager.ExpandedGeneralShaderOptions.Value;
- m_expandedBlendOptions = EditorVariablesManager.ExpandedBlendOptions.Value;
- m_expandedStencilOptions = EditorVariablesManager.ExpandedStencilOptions.Value;
- m_expandedVertexOptions = EditorVariablesManager.ExpandedVertexOptions.Value;
- m_expandedFunctionInputs = EditorVariablesManager.ExpandedFunctionInputs.Value;
- m_expandedFunctionSwitches = EditorVariablesManager.ExpandedFunctionSwitches.Value;
- m_expandedFunctionOutputs = EditorVariablesManager.ExpandedFunctionOutputs.Value;
- m_expandedAdditionalIncludes = EditorVariablesManager.ExpandedAdditionalIncludes.Value;
- m_expandedAdditionalDefines = EditorVariablesManager.ExpandedAdditionalDefines.Value;
- m_expandedAdditionalDirectives = EditorVariablesManager.ExpandedAdditionalDirectives.Value;
- m_expandedCustomTags = EditorVariablesManager.ExpandedCustomTags.Value;
- m_expandedAdditionalSurfaceOptions = EditorVariablesManager.ExpandedAdditionalSurfaceOptions.Value;
- m_expandedAdditionalPragmas = EditorVariablesManager.ExpandedAdditionalPragmas.Value;
- m_expandedDependencies = EditorVariablesManager.ExpandedDependencies.Value;
- m_expandedBlendModeModule = EditorVariablesManager.ExpandedBlendModeModule.Value;
- m_expandedDepth = EditorVariablesManager.ExpandedDepth.Value;
- m_expandedTesselation = EditorVariablesManager.ExpandedTesselation.Value;
- m_expandedProperties = EditorVariablesManager.ExpandedProperties.Value;
- m_expandedUsePass = EditorVariablesManager.ExpandedUsePass.Value;
- }
-
- public bool LiveMode{ get { return m_liveMode; } set { m_liveMode = value; EditorVariablesManager.LiveMode.Value = value; } }
- public bool OutlineActiveMode { get { return m_outlineActiveMode; } set { m_outlineActiveMode = value; EditorVariablesManager.OutlineActiveMode.Value = value; } }
- public bool NodeParametersMaximized { get { return m_nodeParametersMaximized; } set { m_nodeParametersMaximized = value; EditorVariablesManager.NodeParametersMaximized.Value = value; } }
- public bool NodePaletteMaximized { get { return m_nodePaletteMaximized; } set { m_nodePaletteMaximized = value; EditorVariablesManager.NodePaletteMaximized.Value = value; } }
- public bool ExpandedRenderingPlatforms { get { return m_expandedRenderingPlatforms; } set { m_expandedRenderingPlatforms = value; EditorVariablesManager.ExpandedRenderingPlatforms.Value = value; } }
- public bool ExpandedRenderingOptions { get { return m_expandedRenderingOptions; } set { m_expandedRenderingOptions = value; EditorVariablesManager.ExpandedRenderingOptions.Value = value; } }
- public bool ExpandedGeneralShaderOptions { get { return m_expandedGeneralShaderOptions; } set { m_expandedGeneralShaderOptions = value; EditorVariablesManager.ExpandedGeneralShaderOptions.Value = value; } }
- public bool ExpandedBlendOptions { get { return m_expandedBlendOptions; } set { m_expandedBlendOptions = value; EditorVariablesManager.ExpandedBlendOptions.Value = value; } }
- public bool ExpandedStencilOptions { get { return m_expandedStencilOptions; } set { m_expandedStencilOptions = value; EditorVariablesManager.ExpandedStencilOptions.Value = value; } }
- public bool ExpandedVertexOptions { get { return m_expandedVertexOptions; } set { m_expandedVertexOptions = value; EditorVariablesManager.ExpandedVertexOptions.Value = value; } }
- public bool ExpandedFunctionInputs { get { return m_expandedFunctionInputs; } set { m_expandedFunctionInputs = value; EditorVariablesManager.ExpandedFunctionInputs.Value = value; } }
- public bool ExpandedFunctionSwitches { get { return m_expandedFunctionSwitches; } set { m_expandedFunctionSwitches = value; EditorVariablesManager.ExpandedFunctionSwitches.Value = value; } }
- public bool ExpandedFunctionOutputs { get { return m_expandedFunctionOutputs; } set { m_expandedFunctionOutputs = value; EditorVariablesManager.ExpandedFunctionOutputs.Value = value; } }
- public bool ExpandedAdditionalIncludes { get { return m_expandedAdditionalIncludes; } set { m_expandedAdditionalIncludes = value; EditorVariablesManager.ExpandedAdditionalIncludes.Value = value; } }
- public bool ExpandedAdditionalDefines { get { return m_expandedAdditionalDefines; } set { m_expandedAdditionalDefines = value; EditorVariablesManager.ExpandedAdditionalDefines.Value = value; } }
- public bool ExpandedAdditionalDirectives { get { return m_expandedAdditionalDirectives; } set { m_expandedAdditionalDirectives = value; EditorVariablesManager.ExpandedAdditionalDirectives.Value = value; } }
- public bool ExpandedCustomTags { get { return m_expandedCustomTags; } set { m_expandedCustomTags = value; EditorVariablesManager.ExpandedCustomTags.Value = value; } }
- public bool ExpandedAdditionalSurfaceOptions { get { return m_expandedAdditionalSurfaceOptions; } set { m_expandedAdditionalSurfaceOptions = value; EditorVariablesManager.ExpandedAdditionalSurfaceOptions.Value = value; } }
- public bool ExpandedAdditionalPragmas { get { return m_expandedAdditionalPragmas; } set { m_expandedAdditionalPragmas = value; EditorVariablesManager.ExpandedAdditionalPragmas.Value = value; } }
- public bool ExpandedDependencies { get { return m_expandedDependencies; } set { m_expandedDependencies = value; EditorVariablesManager.ExpandedDependencies.Value = value; } }
- public bool ExpandedBlendModeModule { get { return m_expandedBlendModeModule; } set { m_expandedBlendModeModule = value; EditorVariablesManager.ExpandedBlendModeModule.Value = value; } }
- public bool ExpandedDepth { get { return m_expandedDepth; } set { m_expandedDepth = value; EditorVariablesManager.ExpandedDepth.Value = value; } }
- public bool ExpandedTesselation { get { return m_expandedTesselation; } set { m_expandedTesselation = value; EditorVariablesManager.ExpandedTesselation.Value = value; } }
- public bool ExpandedProperties { get { return m_expandedProperties; } set { m_expandedProperties = value; EditorVariablesManager.ExpandedProperties.Value = value; } }
- public bool ExpandedUsePass { get { return m_expandedUsePass; } set { m_expandedUsePass = value; EditorVariablesManager.ExpandedUsePass.Value = value; } }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/EditorVariablesManager.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/EditorVariablesManager.cs.meta
deleted file mode 100644
index 73d074df..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/EditorVariablesManager.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: d402e3c7d578ee046a5d0826b9a41c27
-timeCreated: 1487245046
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GeneratorUtils.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GeneratorUtils.cs
deleted file mode 100644
index 9923fc13..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GeneratorUtils.cs
+++ /dev/null
@@ -1,1022 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-namespace AmplifyShaderEditor
-{
- public static class GeneratorUtils
- {
- public const string ObjectScaleStr = "ase_objectScale";
- public const string ParentObjectScaleStr = "ase_parentObjectScale";
- public const string ScreenDepthStr = "ase_screenDepth";
- public const string ViewPositionStr = "ase_viewPos";
- public const string WorldViewDirectionStr = "ase_worldViewDir";
- public const string TangentViewDirectionStr = "ase_tanViewDir";
- public const string NormalizedViewDirStr = "ase_normViewDir";
- public const string ClipPositionStr = "ase_clipPos";
- public const string VertexPosition3Str = "ase_vertex3Pos";
- public const string VertexPosition4Str = "ase_vertex4Pos";
- public const string VertexNormalStr = "ase_vertexNormal";
- public const string VertexTangentStr = "ase_vertexTangent";
- public const string VertexTangentSignStr = "ase_vertexTangentSign";
- public const string VertexBitangentStr = "ase_vertexBitangent";
- public const string ScreenPositionStr = "ase_screenPos";
- public const string NormalizedScreenPosFormat = "{0} / {0}.w";
- public const string ScreenPositionNormalizedStr = "ase_screenPosNorm";
- public const string GrabScreenPositionStr = "ase_grabScreenPos";
- public const string GrabScreenPositionNormalizedStr = "ase_grabScreenPosNorm";
- public const string WorldPositionStr = "ase_worldPos";
- public const string RelativeWorldPositionStr = "ase_relWorldPos";
- public const string VFaceStr = "ase_vface";
- public const string ShadowCoordsStr = "ase_shadowCoords";
- public const string WorldLightDirStr = "ase_worldlightDir";
- public const string ObjectLightDirStr = "ase_objectlightDir";
- public const string WorldNormalStr = "ase_worldNormal";
- public const string NormalizedWorldNormalStr = "ase_normWorldNormal";
- public const string WorldReflectionStr = "ase_worldReflection";
- public const string WorldTangentStr = "ase_worldTangent";
- public const string WorldBitangentStr = "ase_worldBitangent";
- public const string WorldToTangentStr = "ase_worldToTangent";
- public const string ObjectToTangentStr = "ase_objectToTangent";
- public const string TangentToWorldPreciseStr = "ase_tangentToWorldPrecise";
- public const string TangentToWorldFastStr = "ase_tangentToWorldFast";
- public const string TangentToObjectStr = "ase_tangentToObject";
- public const string TangentToObjectFastStr = "ase_tangentToObjectFast";
- private const string Float3Format = "float3 {0} = {1};";
- private const string Float4Format = "float4 {0} = {1};";
- private const string GrabFunctionHeader = "inline float4 ASE_ComputeGrabScreenPos( float4 pos )";
- private const string GrabFunctionCall = "ASE_ComputeGrabScreenPos( {0} )";
- private const string Identity4x4 = "ase_identity4x4";
- private static readonly string[] GrabFunctionBody = {
- "#if UNITY_UV_STARTS_AT_TOP",
- "float scale = -1.0;",
- "#else",
- "float scale = 1.0;",
- "#endif",
- "float4 o = pos;",
- "o.y = pos.w * 0.5f;",
- "o.y = ( pos.y - o.y ) * _ProjectionParams.x * scale + o.y;",
- "return o;"
- };
-
- // MATRIX IDENTITY
- static public string GenerateIdentity4x4( ref MasterNodeDataCollector dataCollector, int uniqueId )
- {
- dataCollector.AddLocalVariable( uniqueId, "float4x4 ase_identity4x4 = float4x4(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);" );
- return Identity4x4;
- }
-
-
- // OBJECT SCALE
- static public string GenerateObjectScale( ref MasterNodeDataCollector dataCollector, int uniqueId )
- {
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GenerateObjectScale( ref dataCollector, uniqueId );
-
- //string value= "1/float3( length( unity_WorldToObject[ 0 ].xyz ), length( unity_WorldToObject[ 1 ].xyz ), length( unity_WorldToObject[ 2 ].xyz ) );";
- string value = "float3( length( unity_ObjectToWorld[ 0 ].xyz ), length( unity_ObjectToWorld[ 1 ].xyz ), length( unity_ObjectToWorld[ 2 ].xyz ) )";
- dataCollector.AddLocalVariable( uniqueId, PrecisionType.Float, WirePortDataType.FLOAT3, ObjectScaleStr, value );
- return ObjectScaleStr;
- }
-
- static public string GenerateRotationIndependentObjectScale( ref MasterNodeDataCollector dataCollector, int uniqueId )
- {
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GenerateRotationIndependentObjectScale( ref dataCollector, uniqueId );
-
- string value = "(1.0/float3( length( unity_WorldToObject[ 0 ].xyz ), length( unity_WorldToObject[ 1 ].xyz ), length( unity_WorldToObject[ 2 ].xyz ) ))";
- dataCollector.AddLocalVariable( uniqueId, PrecisionType.Float, WirePortDataType.FLOAT3, ParentObjectScaleStr, value );
- return ParentObjectScaleStr;
- }
-
- // WORLD POSITION
- static public string GenerateWorldPosition( ref MasterNodeDataCollector dataCollector, int uniqueId )
- {
- PrecisionType precision = PrecisionType.Float;
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetWorldPos();
-
- dataCollector.AddToInput( -1, SurfaceInputs.WORLD_POS, precision );
-
- string result = Constants.InputVarStr + ".worldPos";
-
- if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
- result = "mul( unity_ObjectToWorld, " + Constants.VertexShaderInputStr + ".vertex )";
-
- //dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, string.Format( Float3Format, WorldPositionStr, result ) );
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, WorldPositionStr, result );
-
- return WorldPositionStr;
- }
-
- // WORLD REFLECTION
- static public string GenerateWorldReflection( ref MasterNodeDataCollector dataCollector, int uniqueId, bool normalize = false )
- {
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetWorldReflection( UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision, true, MasterNodePortCategory.Fragment, normalize );
-
- string precisionType = UIUtils.PrecisionWirePortToCgType( UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision, WirePortDataType.FLOAT3 );
- string result = string.Empty;
- if( !dataCollector.DirtyNormal )
- result = Constants.InputVarStr + ".worldRefl";
- else
- result = "WorldReflectionVector( " + Constants.InputVarStr + ", " + precisionType + "( 0, 0, 1 ) )";
-
- if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
- result = "UnityObjectToWorldNormal( " + Constants.VertexShaderInputStr + ".normal )";
- if( normalize )
- {
- result = string.Format( "normalize( {0} )", result );
- }
-
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, string.Concat( precisionType, " ", WorldReflectionStr, " = ", result, ";" ) );
- return WorldReflectionStr;
- }
-
- // WORLD NORMAL
- static public string GenerateWorldNormal( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precisionType, string normal, string outputId )
- {
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetWorldNormal( uniqueId, precisionType, normal, outputId );
-
- string tanToWorld = GenerateTangentToWorldMatrixFast( ref dataCollector, uniqueId, precisionType );
- return string.Format( "mul({0},{1})", tanToWorld, normal );
-
- }
- static public string GenerateWorldNormal( ref MasterNodeDataCollector dataCollector, int uniqueId, bool normalize = false )
- {
- PrecisionType precision = UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision;
-
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetWorldNormal( precision, true, MasterNodePortCategory.Fragment, normalize );
-
- string precisionType = UIUtils.PrecisionWirePortToCgType( precision, WirePortDataType.FLOAT3 );
- string result = string.Empty;
- if( !dataCollector.DirtyNormal )
- result = Constants.InputVarStr + ".worldNormal";
- else
- result = "WorldNormalVector( " + Constants.InputVarStr + ", " + precisionType + "( 0, 0, 1 ) )";
-
- if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
- result = "UnityObjectToWorldNormal( " + Constants.VertexShaderInputStr + ".normal )";
-
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, WorldNormalStr, result );
- if( normalize )
- {
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, NormalizedWorldNormalStr, "normalize( " + WorldNormalStr + " )" );
- return NormalizedWorldNormalStr;
- }
- return WorldNormalStr;
- }
-
- // WORLD TANGENT
- static public string GenerateWorldTangent( ref MasterNodeDataCollector dataCollector, int uniqueId )
- {
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetWorldTangent( UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
-
- string precisionType = UIUtils.PrecisionWirePortToCgType( UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision, WirePortDataType.FLOAT3 );
- string result = "WorldNormalVector( " + Constants.InputVarStr + ", " + precisionType + "( 1, 0, 0 ) )";
-
- if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
- result = "UnityObjectToWorldDir( " + Constants.VertexShaderInputStr + ".tangent.xyz )";
- dataCollector.AddLocalVariable( uniqueId, UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision, WirePortDataType.FLOAT3, WorldTangentStr, result );
- //dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, string.Concat( precisionType, " ", WorldTangentStr, " = ", result, ";" ) );
- return WorldTangentStr;
- }
-
- // WORLD BITANGENT
- static public string GenerateWorldBitangent( ref MasterNodeDataCollector dataCollector, int uniqueId )
- {
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetWorldBinormal( UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
-
- string precisionType = UIUtils.PrecisionWirePortToCgType( UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision, WirePortDataType.FLOAT3 );
- string result = "WorldNormalVector( " + Constants.InputVarStr + ", " + precisionType + "( 0, 1, 0 ) )";
-
- if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
- {
- string worldNormal = GenerateWorldNormal( ref dataCollector, uniqueId );
- string worldTangent = GenerateWorldTangent( ref dataCollector, uniqueId );
- dataCollector.AddToVertexLocalVariables( uniqueId, string.Format( "half tangentSign = {0}.tangent.w * unity_WorldTransformParams.w;", Constants.VertexShaderInputStr ) );
- result = "cross( " + worldNormal + ", " + worldTangent + " ) * tangentSign";
- }
-
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, string.Concat( precisionType, " ", WorldBitangentStr, " = ", result, ";" ) );
- return WorldBitangentStr;
- }
-
- // OBJECT TO TANGENT MATRIX
- static public string GenerateObjectToTangentMatrix( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- string normal = GenerateVertexNormal( ref dataCollector, uniqueId, precision );
- string tangent = GenerateVertexTangent( ref dataCollector, uniqueId, precision, WirePortDataType.FLOAT3 );
- string bitangen = GenerateVertexBitangent( ref dataCollector, uniqueId, precision );
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3x3, ObjectToTangentStr, "float3x3( " + tangent + ", " + bitangen + ", " + normal + " )" );
- return ObjectToTangentStr;
- }
-
- // TANGENT TO OBJECT
- //static public string GenerateTangentToObjectMatrixFast( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- //{
- // string normal = GenerateVertexNormal( ref dataCollector, uniqueId, precision );
- // string tangent = GenerateVertexTangent( ref dataCollector, uniqueId, precision );
- // string bitangent = GenerateVertexBitangent( ref dataCollector, uniqueId, precision );
-
- // string result = string.Format( "float3x3({0}.x,{1}.x,{2}.x,{0}.y,{1}.y,{2}.y,{0}.z,{1}.z,{2}.z)",tangent,bitangent,normal );
- // dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3x3, TangentToObjectFastStr, result );
- // return TangentToObjectFastStr;
- //}
-
- //static public string GenerateTangentToObjectMatrixPrecise( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- //{
- // string objectToTangent = GenerateObjectToTangentMatrix( ref dataCollector, uniqueId, precision );
- // Add3x3InverseFunction( ref dataCollector, UIUtils.PrecisionWirePortToCgType( precision, WirePortDataType.FLOAT ) );
- // dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3x3, TangentToObjectStr, string.Format( Inverse3x3Header, objectToTangent ) );
- // return TangentToObjectStr;
- //}
-
- // WORLD TO TANGENT MATRIX
- static public string GenerateWorldToTangentMatrix( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetWorldToTangentMatrix( precision );
-
- if( dataCollector.IsFragmentCategory )
- {
- dataCollector.ForceNormal = true;
-
- dataCollector.AddToInput( -1, SurfaceInputs.WORLD_NORMAL, precision );
- dataCollector.AddToInput( -1, SurfaceInputs.INTERNALDATA, addSemiColon: false );
- }
-
- string worldNormal = GenerateWorldNormal( ref dataCollector, uniqueId );
- string worldTangent = GenerateWorldTangent( ref dataCollector, uniqueId );
- string worldBitangent = GenerateWorldBitangent( ref dataCollector, uniqueId );
-
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3x3, WorldToTangentStr, "float3x3( " + worldTangent + ", " + worldBitangent + ", " + worldNormal + " )" );
- return WorldToTangentStr;
- }
-
- // TANGENT TO WORLD
- static public string GenerateTangentToWorldMatrixFast( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetTangentToWorldMatrixFast( precision );
-
- if( dataCollector.IsFragmentCategory )
- {
- dataCollector.ForceNormal = true;
-
- dataCollector.AddToInput( -1, SurfaceInputs.WORLD_NORMAL, precision );
- dataCollector.AddToInput( -1, SurfaceInputs.INTERNALDATA, addSemiColon: false );
- }
-
- string worldNormal = GenerateWorldNormal( ref dataCollector, uniqueId );
- string worldTangent = GenerateWorldTangent( ref dataCollector, uniqueId );
- string worldBitangent = GenerateWorldBitangent( ref dataCollector, uniqueId );
-
- string result = string.Format( "float3x3({0}.x,{1}.x,{2}.x,{0}.y,{1}.y,{2}.y,{0}.z,{1}.z,{2}.z)", worldTangent, worldBitangent, worldNormal );
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3x3, TangentToWorldFastStr, result );
- return TangentToWorldFastStr;
- }
-
- static public string GenerateTangentToWorldMatrixPrecise( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetTangentToWorldMatrixPrecise( precision );
-
- if( dataCollector.IsFragmentCategory )
- {
- dataCollector.ForceNormal = true;
-
- dataCollector.AddToInput( -1, SurfaceInputs.WORLD_NORMAL, precision );
- dataCollector.AddToInput( -1, SurfaceInputs.INTERNALDATA, addSemiColon: false );
- }
-
- string worldToTangent = GenerateWorldToTangentMatrix( ref dataCollector, uniqueId, precision );
- Add3x3InverseFunction( ref dataCollector, UIUtils.PrecisionWirePortToCgType( precision, WirePortDataType.FLOAT ) );
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3x3, TangentToWorldPreciseStr, string.Format( Inverse3x3Header, worldToTangent ) );
- return TangentToWorldPreciseStr;
- }
-
- // AUTOMATIC UVS
- static public string GenerateAutoUVs( ref MasterNodeDataCollector dataCollector, int uniqueId, int index, string propertyName = null, WirePortDataType size = WirePortDataType.FLOAT2, string scale = null, string offset = null, string outputId = null )
- {
- string result = string.Empty;
- string varName = string.Empty;
- if( !dataCollector.IsTemplate && index > 3 )
- {
- string texCoordName = TemplateHelperFunctions.BaseInterpolatorName + index;
- if( dataCollector.IsFragmentCategory )
- {
-
- GenerateValueInVertex( ref dataCollector, uniqueId, size, PrecisionType.Float, Constants.VertexShaderInputStr + "." + texCoordName, texCoordName, true );
- result = Constants.InputVarStr + "." + texCoordName;
- }
- else
- {
- result = Constants.VertexShaderInputStr + "." + texCoordName;
- }
-
- if( !string.IsNullOrEmpty( propertyName ) )
- {
- dataCollector.AddToUniforms( uniqueId, "uniform float4 " + propertyName + "_ST;" );
- if( size > WirePortDataType.FLOAT2 )
- {
- dataCollector.UsingHigherSizeTexcoords = true;
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, PrecisionType.Float, size, "uv" + propertyName, result );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, "uv" + propertyName + ".xy = " + result + ".xy * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw;" );
- }
- else
- {
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, PrecisionType.Float, size, "uv" + propertyName, result + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw" );
- }
-
- result = "uv" + propertyName;
- }
-
- return result;
- }
-
- string indexStr = index > 0 ? ( index + 1 ).ToString() : "";
-
- if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug )
- {
- string sizeDif = string.Empty;
- if( size == WirePortDataType.FLOAT3 )
- sizeDif = "3";
- else if( size == WirePortDataType.FLOAT4 )
- sizeDif = "4";
-
- string dummyPropUV = "_tex" + sizeDif + "coord" + indexStr;
- string dummyUV = "uv" + indexStr + dummyPropUV;
-
- dataCollector.AddToProperties( uniqueId, "[HideInInspector] " + dummyPropUV + "( \"\", 2D ) = \"white\" {}", 100 );
- dataCollector.AddToInput( uniqueId, dummyUV, size );
-
- result = Constants.InputVarStr + "." + dummyUV;
- }
- else
- {
- result = Constants.VertexShaderInputStr + ".texcoord";
- if( index > 0 )
- {
- result += index.ToString();
- }
-
- switch( size )
- {
- default:
- case WirePortDataType.FLOAT2:
- {
- result += ".xy";
- }
- break;
- case WirePortDataType.FLOAT3:
- {
- result += ".xyz";
- }
- break;
- case WirePortDataType.FLOAT4: break;
- }
- }
-
- varName = "uv" + indexStr + "_TexCoord" + outputId;
-
- if( !string.IsNullOrEmpty( propertyName ) )
- {
- string finalVarName = "uv" + index + propertyName;
-
- dataCollector.AddToUniforms( uniqueId, "uniform float4 " + propertyName + "_ST;" );
- if( size > WirePortDataType.FLOAT2 )
- {
- dataCollector.UsingHigherSizeTexcoords = true;
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, PrecisionType.Float, size, finalVarName, result );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, finalVarName + ".xy = " + result + ".xy * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw;" );
- }
- else
- {
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, PrecisionType.Float, size, finalVarName, result + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw" );
- }
-
- result = finalVarName;
- }
- else if( !string.IsNullOrEmpty( scale ) || !string.IsNullOrEmpty( offset ) )
- {
- if( size > WirePortDataType.FLOAT2 )
- {
- dataCollector.UsingHigherSizeTexcoords = true;
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, PrecisionType.Float, size, varName, result );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, varName + ".xy = " + result + ".xy" + ( string.IsNullOrEmpty( scale ) ? "" : " * " + scale ) + ( string.IsNullOrEmpty( offset ) ? "" : " + " + offset ) + ";" );
- }
- else
- {
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, uniqueId, PrecisionType.Float, size, varName, result + ( string.IsNullOrEmpty( scale ) ? "" : " * " + scale ) + ( string.IsNullOrEmpty( offset ) ? "" : " + " + offset ) );
- }
-
- result = varName;
- }
- else if( dataCollector.PortCategory == MasterNodePortCategory.Fragment )
- {
- if( size > WirePortDataType.FLOAT2 )
- dataCollector.UsingHigherSizeTexcoords = true;
- }
-
- return result;
- }
-
- // SCREEN POSITION NORMALIZED
- static public string GenerateScreenPositionNormalizedForValue( string customVertexPos, string outputId, ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true )
- {
- string stringPosVar = GenerateScreenPositionForValue( customVertexPos, outputId, ref dataCollector, uniqueId, precision, addInput );
- string varName = ScreenPositionNormalizedStr + uniqueId;
-
- // TODO: check later if precision can be half
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT4, varName, string.Format( NormalizedScreenPosFormat, stringPosVar ) );
- dataCollector.AddLocalVariable( uniqueId, varName + ".z = ( UNITY_NEAR_CLIP_VALUE >= 0 ) ? " + varName + ".z : " + varName + ".z * 0.5 + 0.5;" );
-
- return varName;
- }
-
- static public string GenerateScreenPositionNormalized( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true, string customScreenPos = null )
- {
- string stringPosVar = string.IsNullOrEmpty( customScreenPos ) ? GenerateScreenPosition( ref dataCollector, uniqueId, precision, addInput ) : customScreenPos;
-
- // TODO: check later if precision can be half
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT4, ScreenPositionNormalizedStr, string.Format( NormalizedScreenPosFormat, stringPosVar ) );
- dataCollector.AddLocalVariable( uniqueId, ScreenPositionNormalizedStr + ".z = ( UNITY_NEAR_CLIP_VALUE >= 0 ) ? " + ScreenPositionNormalizedStr + ".z : " + ScreenPositionNormalizedStr + ".z * 0.5 + 0.5;" );
-
- return ScreenPositionNormalizedStr;
- }
-
- // SCREEN POSITION
- static public string GenerateScreenPositionForValue( string customVertexPosition, string outputId, ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true )
- {
- // overriding precision
- precision = PrecisionType.Float;
-
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetScreenPosForValue( precision, customVertexPosition, outputId );
-
-
- string value = GenerateVertexScreenPositionForValue( customVertexPosition, outputId, ref dataCollector, uniqueId, precision );
- string screenPosVarName = "screenPosition" + outputId;
- dataCollector.AddToInput( uniqueId, screenPosVarName, WirePortDataType.FLOAT4, precision );
- dataCollector.AddToVertexLocalVariables( uniqueId, Constants.VertexShaderOutputStr + "." + screenPosVarName + " = " + value + ";" );
-
- string screenPosVarNameOnFrag = ScreenPositionStr + outputId;
- string globalResult = Constants.InputVarStr + "." + screenPosVarName;
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT4, screenPosVarNameOnFrag, globalResult );
- return screenPosVarNameOnFrag;
-
- }
-
- static public string GenerateScreenPosition( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true )
- {
- // overriding precision
- precision = PrecisionType.Float;
-
- if( dataCollector.UsingCustomScreenPos && dataCollector.IsFragmentCategory )
- {
- string value = GenerateVertexScreenPosition( ref dataCollector, uniqueId, precision );
- dataCollector.AddToInput( uniqueId, "screenPosition", WirePortDataType.FLOAT4, precision );
- dataCollector.AddToVertexLocalVariables( uniqueId, Constants.VertexShaderOutputStr + ".screenPosition = " + value + ";" );
-
- string globalResult = Constants.InputVarStr + ".screenPosition";
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT4, ScreenPositionStr, globalResult );
- return ScreenPositionStr;
- }
- else
- {
- if( !dataCollector.IsFragmentCategory )
- return GenerateVertexScreenPosition( ref dataCollector, uniqueId, precision );
-
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetScreenPos( precision );
- }
-
-
- if( addInput )
- dataCollector.AddToInput( uniqueId, SurfaceInputs.SCREEN_POS, precision );
-
- string result = Constants.InputVarStr + ".screenPos";
- dataCollector.AddLocalVariable( uniqueId, string.Format( "float4 {0} = float4( {1}.xyz , {1}.w + 0.00000000001 );", ScreenPositionStr, result ) );
-
- return ScreenPositionStr;
- }
-
- // GRAB SCREEN POSITION
- static public string GenerateGrabScreenPosition( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true, string customScreenPos = null )
- {
- // overriding precision
- precision = PrecisionType.Float;
-
- string screenPos = string.Empty;
- if( string.IsNullOrEmpty( customScreenPos ) )
- screenPos = GenerateScreenPosition( ref dataCollector, uniqueId, precision, addInput );
- else
- screenPos = customScreenPos;
-
- string computeBody = string.Empty;
- IOUtils.AddFunctionHeader( ref computeBody, GrabFunctionHeader );
- foreach( string line in GrabFunctionBody )
- IOUtils.AddFunctionLine( ref computeBody, line );
- IOUtils.CloseFunctionBody( ref computeBody );
- string functionResult = dataCollector.AddFunctions( GrabFunctionCall, computeBody, screenPos );
-
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT4, GrabScreenPositionStr, functionResult );
- return GrabScreenPositionStr;
- }
-
- // GRAB SCREEN POSITION NORMALIZED
- static public string GenerateGrabScreenPositionNormalized( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true, string customScreenPos = null )
- {
- string stringPosVar = GenerateGrabScreenPosition( ref dataCollector, uniqueId, precision, addInput, customScreenPos );
-
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT4, GrabScreenPositionNormalizedStr, string.Format( NormalizedScreenPosFormat, stringPosVar ) );
- return GrabScreenPositionNormalizedStr;
- }
-
- // SCREEN POSITION ON VERT
- static public string GenerateVertexScreenPositionForValue( string customVertexPosition, string outputId, ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- // overriding precision
- precision = PrecisionType.Float;
-
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetScreenPosForValue( precision, customVertexPosition, outputId );
-
- string screenPosVarName = ScreenPositionStr + outputId;
- string value = string.Format( "ComputeScreenPos( UnityObjectToClipPos( {0} ) )", customVertexPosition );
- dataCollector.AddToVertexLocalVariables( uniqueId, precision, WirePortDataType.FLOAT4, screenPosVarName, value );
- return screenPosVarName;
- }
-
- static public string GenerateVertexScreenPosition( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- // overriding precision
- precision = PrecisionType.Float;
-
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetScreenPos( precision );
-
- string value = string.Format( "ComputeScreenPos( UnityObjectToClipPos( {0}.vertex ) )", Constants.VertexShaderInputStr );
- dataCollector.AddToVertexLocalVariables( uniqueId, precision, WirePortDataType.FLOAT4, ScreenPositionStr, value );
- return ScreenPositionStr;
- }
-
- // VERTEX POSITION
- static public string GenerateVertexPosition( ref MasterNodeDataCollector dataCollector, int uniqueId, WirePortDataType size )
- {
- // overriding precision
- var precision = PrecisionType.Float;
-
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetVertexPosition( size, precision );
-
- string value = Constants.VertexShaderInputStr + ".vertex";
- if( size == WirePortDataType.FLOAT3 )
- value += ".xyz";
-
- if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug )
- {
- dataCollector.AddToInput( uniqueId, SurfaceInputs.WORLD_POS );
- dataCollector.AddToIncludes( uniqueId, Constants.UnityShaderVariables );
-
- value = "mul( unity_WorldToObject, float4( " + Constants.InputVarStr + ".worldPos , 1 ) )";
- }
- string varName = VertexPosition4Str;
- if( size == WirePortDataType.FLOAT3 )
- varName = VertexPosition3Str;
-
- dataCollector.AddLocalVariable( uniqueId, precision, size, varName, value );
- return varName;
- }
-
- // VERTEX NORMAL
- static public string GenerateVertexNormal( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template )
- {
- return dataCollector.TemplateDataCollectorInstance.GetVertexNormal( UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
- }
-
- string value = Constants.VertexShaderInputStr + ".normal.xyz";
- if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug )
- {
- GenerateWorldNormal( ref dataCollector, uniqueId );
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, VertexNormalStr, "mul( unity_WorldToObject, float4( " + WorldNormalStr + ", 0 ) )" );
- //dataCollector.AddToLocalVariables( uniqueId, precision, WirePortDataType.FLOAT3, VertexNormalStr, "mul( unity_WorldToObject, float4( " + WorldNormalStr + ", 0 ) )" );
- }
- else
- {
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, VertexNormalStr, value );
- }
- return VertexNormalStr;
- }
-
- // VERTEX TANGENT
- static public string GenerateVertexTangent( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, WirePortDataType size )
- {
- if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template )
- {
- return dataCollector.TemplateDataCollectorInstance.GetVertexTangent( size,UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
- }
-
- if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug )
- {
- GenerateWorldTangent( ref dataCollector, uniqueId );
- dataCollector.AddToLocalVariables( uniqueId, precision, WirePortDataType.FLOAT4, VertexTangentStr, "mul( unity_WorldToObject, float4( " + WorldTangentStr + ", 0 ) )" );
- }
- else
- {
- string value = Constants.VertexShaderInputStr + ".tangent";
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT4, VertexTangentStr, value );
- }
-
- return ( size == WirePortDataType.FLOAT4 ) ? VertexTangentStr : VertexTangentStr + ".xyz";
- }
-
- // VERTEX TANGENT SIGN
- static public string GenerateVertexTangentSign( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template )
- {
- return dataCollector.TemplateDataCollectorInstance.GetTangentSign( UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
- }
-
- string value = Constants.VertexShaderInputStr + ".tangent.w";
- if( dataCollector.IsFragmentCategory )
- {
- dataCollector.AddToInput( uniqueId, VertexTangentSignStr, WirePortDataType.FLOAT, PrecisionType.Half );
- dataCollector.AddToVertexLocalVariables( uniqueId, Constants.VertexShaderOutputStr + "." + VertexTangentSignStr + " = " + Constants.VertexShaderInputStr + ".tangent.w;" );
- return Constants.InputVarStr + "." + VertexTangentSignStr;
- }
- else
- {
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT, VertexTangentSignStr, value );
- }
- return VertexTangentSignStr;
- }
-
- // VERTEX BITANGENT
- static public string GenerateVertexBitangent( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template )
- {
- return dataCollector.TemplateDataCollectorInstance.GetVertexBitangent( UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision );
- }
-
- if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug )
- {
- GenerateWorldBitangent( ref dataCollector, uniqueId );
- dataCollector.AddToLocalVariables( uniqueId, precision, WirePortDataType.FLOAT3, VertexBitangentStr, "mul( unity_WorldToObject, float4( " + WorldBitangentStr + ", 0 ) )" );
- }
- else
- {
- GenerateVertexNormal( ref dataCollector, uniqueId, precision );
- GenerateVertexTangent( ref dataCollector, uniqueId, precision, WirePortDataType.FLOAT3 );
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, VertexBitangentStr, "cross( " + VertexNormalStr + ", " + VertexTangentStr + ") * " + Constants.VertexShaderInputStr + ".tangent.w * unity_WorldTransformParams.w" );
- }
- return VertexBitangentStr;
- }
-
- // VERTEX POSITION ON FRAG
- static public string GenerateVertexPositionOnFrag( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- dataCollector.AddToInput( uniqueId, SurfaceInputs.WORLD_POS );
- dataCollector.AddToIncludes( uniqueId, Constants.UnityShaderVariables );
-
- string value = "mul( unity_WorldToObject, float4( " + Constants.InputVarStr + ".worldPos , 1 ) )";
-
- dataCollector.AddToLocalVariables( uniqueId, precision, WirePortDataType.FLOAT4, VertexPosition4Str, value );
- return VertexPosition4Str;
- }
-
- // CLIP POSITION ON FRAG
- static public string GenerateClipPositionOnFrag( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- if( dataCollector.IsTemplate )
- return dataCollector.TemplateDataCollectorInstance.GetClipPos();
-
- string vertexName = GenerateVertexPositionOnFrag( ref dataCollector, uniqueId, precision );
- string value = string.Format( "ComputeScreenPos( UnityObjectToClipPos( {0} ) )", vertexName );
- dataCollector.AddToLocalVariables( uniqueId, precision, WirePortDataType.FLOAT4, ClipPositionStr, value );
- return ClipPositionStr;
- }
-
- // VIEW DIRECTION
- static public string GenerateViewDirection( ref MasterNodeDataCollector dataCollector, int uniqueId, ViewSpace space = ViewSpace.World )
- {
- PrecisionType precision = UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision;
- if( dataCollector.IsTemplate )
- return ( space == ViewSpace.Tangent ) ? dataCollector.TemplateDataCollectorInstance.GetTangentViewDir( precision ) : dataCollector.TemplateDataCollectorInstance.GetViewDir();
-
- string worldPos = GenerateWorldPosition( ref dataCollector, uniqueId );
- string safeNormalizeInstruction = string.Empty;
- if( dataCollector.SafeNormalizeViewDir )
- {
- if( dataCollector.IsTemplate && dataCollector.IsSRP )
- {
- safeNormalizeInstruction = "SafeNormalize";
- }
- else
- {
- if( dataCollector.IsTemplate )
- dataCollector.AddToIncludes( -1, Constants.UnityBRDFLib );
- safeNormalizeInstruction = "Unity_SafeNormalize";
- }
- }
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, WorldViewDirectionStr, ( dataCollector.SafeNormalizeViewDir ? safeNormalizeInstruction : "normalize" ) + "( UnityWorldSpaceViewDir( " + worldPos + " ) )" );
-
- if( space == ViewSpace.Tangent )
- {
- string worldToTangent = GenerateWorldToTangentMatrix( ref dataCollector, uniqueId, precision );
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, TangentViewDirectionStr, "mul( " + worldToTangent + ", " + WorldViewDirectionStr + " )" );
- return TangentViewDirectionStr;
- }
- else
- {
- return WorldViewDirectionStr;
- }
- }
-
- // VIEW POS
- static public string GenerateViewPositionOnFrag( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- // overriding precision
- precision = PrecisionType.Float;
-
- if( dataCollector.IsTemplate )
- UnityEngine.Debug.LogWarning( "View Pos not implemented on Templates" );
-
- string vertexName = GenerateVertexPositionOnFrag( ref dataCollector, uniqueId, precision );
- string value = string.Format( "UnityObjectToViewPos( {0} )", vertexName );
- dataCollector.AddToLocalVariables( uniqueId, precision, WirePortDataType.FLOAT3, ViewPositionStr, value );
- return ViewPositionStr;
- }
-
- // SCREEN DEPTH
- static public string GenerateScreenDepthOnFrag( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- // overriding precision
- precision = PrecisionType.Float;
-
- if( dataCollector.IsTemplate )
- UnityEngine.Debug.LogWarning( "Screen Depth not implemented on Templates" );
-
- string viewPos = GenerateViewPositionOnFrag( ref dataCollector, uniqueId, precision );
- string value = string.Format( "-{0}.z", viewPos );
- dataCollector.AddToLocalVariables( uniqueId, precision, WirePortDataType.FLOAT, ScreenDepthStr, value );
- return ScreenDepthStr;
- }
-
- // LIGHT DIRECTION WORLD
- static public string GenerateWorldLightDirection( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
- {
- dataCollector.AddToIncludes( uniqueId, Constants.UnityCgLibFuncs );
- string worldPos = GeneratorUtils.GenerateWorldPosition( ref dataCollector, uniqueId );
- dataCollector.AddLocalVariable( uniqueId, "#if defined(LIGHTMAP_ON) && UNITY_VERSION < 560 //aseld" );
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, WorldLightDirStr, "0" );
- dataCollector.AddLocalVariable( uniqueId, "#else //aseld" );
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, WorldLightDirStr, ( dataCollector.SafeNormalizeLightDir ? "Unity_SafeNormalize" : "normalize" ) + "( UnityWorldSpaceLightDir( " + worldPos + " ) )" );
- dataCollector.AddLocalVariable( uniqueId, "#endif //aseld" );
- return WorldLightDirStr;
- }
-
- // LIGHT DIRECTION Object
- static public string GenerateObjectLightDirection( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, string vertexPos )
- {
- dataCollector.AddToIncludes( uniqueId, Constants.UnityCgLibFuncs );
- dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, ObjectLightDirStr, "normalize( ObjSpaceLightDir( " + vertexPos + " ) )" );
- return ObjectLightDirStr;
- }
-
- //MATRIX INVERSE
- // 3x3
- public static string Inverse3x3Header = "Inverse3x3( {0} )";
- public static string[] Inverse3x3Function =
- {
- "{0}3x3 Inverse3x3({0}3x3 input)\n",
- "{\n",
- "\t{0}3 a = input._11_21_31;\n",
- "\t{0}3 b = input._12_22_32;\n",
- "\t{0}3 c = input._13_23_33;\n",
- "\treturn {0}3x3(cross(b,c), cross(c,a), cross(a,b)) * (1.0 / dot(a,cross(b,c)));\n",
- "}\n"
- };
-
- public static bool[] Inverse3x3FunctionFlags =
- {
- true,
- false,
- true,
- true,
- true,
- true,
- false
- };
-
- public static void Add3x3InverseFunction( ref MasterNodeDataCollector dataCollector, string precisionString )
- {
- if( !dataCollector.HasFunction( Inverse3x3Header ) )
- {
- //Hack to be used util indent is properly used
- int currIndent = UIUtils.ShaderIndentLevel;
- if( dataCollector.IsTemplate )
- {
- UIUtils.ShaderIndentLevel = 0;
- }
- else
- {
- UIUtils.ShaderIndentLevel = 1;
- UIUtils.ShaderIndentLevel++;
- }
- string finalFunction = string.Empty;
- for( int i = 0; i < Inverse3x3Function.Length; i++ )
- {
- finalFunction += UIUtils.ShaderIndentTabs + ( Inverse3x3FunctionFlags[ i ] ? string.Format( Inverse3x3Function[ i ], precisionString ) : Inverse3x3Function[ i ] );
- }
-
-
- UIUtils.ShaderIndentLevel = currIndent;
-
- dataCollector.AddFunction( Inverse3x3Header, finalFunction );
- }
- }
-
- public static string GenerateValueInVertex( ref MasterNodeDataCollector dataCollector, int uniqueId, WirePortDataType dataType, PrecisionType currentPrecisionType, string dataValue, string dataName, bool createInterpolator )
- {
- if( !dataCollector.IsFragmentCategory )
- return dataValue;
-
- //TEMPLATES
- if( dataCollector.IsTemplate )
- {
- if( createInterpolator && dataCollector.TemplateDataCollectorInstance.HasCustomInterpolatedData( dataName ) )
- return dataName;
-
- MasterNodePortCategory category = dataCollector.PortCategory;
- dataCollector.PortCategory = MasterNodePortCategory.Vertex;
-
- dataCollector.PortCategory = category;
-
- if( createInterpolator )
- {
- dataCollector.TemplateDataCollectorInstance.RegisterCustomInterpolatedData( dataName, dataType, currentPrecisionType, dataValue );
- }
- else
- {
- dataCollector.AddToVertexLocalVariables( -1, currentPrecisionType, dataType, dataName, dataValue );
- }
-
- return dataName;
- }
-
- //SURFACE
- {
- if( dataCollector.TesselationActive )
- {
- UIUtils.ShowMessage( "Unable to use Vertex to Frag when Tessellation is active" );
- switch( dataType )
- {
- case WirePortDataType.FLOAT2:
- {
- return "(0).xx";
- }
- case WirePortDataType.FLOAT3:
- {
- return "(0).xxx";
- }
- case WirePortDataType.FLOAT4:
- case WirePortDataType.COLOR:
- {
- return "(0).xxxx";
- }
- }
- return "0";
- }
-
- if( createInterpolator )
- dataCollector.AddToInput( uniqueId, dataName, dataType, currentPrecisionType );
-
- MasterNodePortCategory portCategory = dataCollector.PortCategory;
- dataCollector.PortCategory = MasterNodePortCategory.Vertex;
- if( createInterpolator )
- {
- dataCollector.AddLocalVariable( uniqueId, Constants.VertexShaderOutputStr + "." + dataName, dataValue + ";" );
- }
- else
- {
- dataCollector.AddLocalVariable( uniqueId, currentPrecisionType, dataType, dataName, dataValue );
- }
- dataCollector.PortCategory = portCategory;
- return createInterpolator ? Constants.InputVarStr + "." + dataName : dataName;
- }
- }
-
- public static void AddCustomStandardSamplingMacros( ref MasterNodeDataCollector dataCollector )
- {
- for( int i = 0; i < Constants.CustomStandardSamplingMacros.Length; i++ )
- dataCollector.AddToDirectives( Constants.CustomStandardSamplingMacros[ i ] );
- }
-
- public static void AddCustomArraySamplingMacros( ref MasterNodeDataCollector dataCollector )
- {
- for( int i = 0; i < Constants.CustomArraySamplingMacros.Length; i++ )
- dataCollector.AddToDirectives( Constants.CustomArraySamplingMacros[ i ] );
- }
-
- public static void AddCustomASEMacros( ref MasterNodeDataCollector dataCollector )
- {
- string varPrefix = dataCollector.IsSRP ? varPrefix = "TEXTURE" : "UNITY_DECLARE_TEX";
-
- if( dataCollector.IsSRP )
- {
- for( int i = 0; i < Constants.CustomASESRPArgsMacros.Length; i++ )
- {
- dataCollector.AddToDirectives( Constants.CustomASESRPArgsMacros[ i ] );
- }
-
- for( int i = 0; i < Constants.CustomSRPSamplingMacros.Length; i++ )
- {
- dataCollector.AddToDirectives( Constants.CustomSRPSamplingMacros[ i ] );
- }
- }
- else
- {
-
- for( int i = 0; i < Constants.CustomASEStandardArgsMacros.Length; i++ )
- {
- dataCollector.AddToDirectives( Constants.CustomASEStandardArgsMacros[ i ] );
- }
-
- for( int i = 0; i < Constants.CustomStandardSamplingMacros.Length; i++ )
- {
- dataCollector.AddToDirectives( Constants.CustomStandardSamplingMacros[ i ] );
- }
- }
-
- for( int i = 0; i < Constants.CustomASEDeclararionMacros.Length; i++ )
- {
- string value = string.Format( Constants.CustomASEDeclararionMacros[ i ], varPrefix );
- dataCollector.AddToDirectives( value );
- }
-
- string samplePrefix = string.Empty;
- string samplerArgs = string.Empty;
- string samplerDecl = string.Empty;
-
- if( dataCollector.IsSRP )
- {
- samplePrefix = "SAMPLE_TEXTURE";
- samplerArgs = "samplerName,";
-
- for( int i = 0; i < Constants.CustomASESamplingMacros.Length; i++ )
- {
- string value = string.Format( Constants.CustomASESamplingMacros[ i ], samplerArgs, samplePrefix, samplerDecl );
- dataCollector.AddToDirectives( value );
- }
- }
- else
- {
- samplePrefix = "UNITY_SAMPLE_TEX";
- samplerArgs = "samplerName,";
- samplerDecl = "_SAMPLER";
- dataCollector.AddToDirectives( Constants.CustomASEStandarSamplingMacrosHelper[ 0 ] );
- for( int i = 0; i < Constants.CustomASESamplingMacros.Length; i++ )
- {
- string value = string.Format( Constants.CustomASESamplingMacros[ i ], samplerArgs, samplePrefix, samplerDecl );
- dataCollector.AddToDirectives( value );
- }
- dataCollector.AddToDirectives( Constants.CustomASEStandarSamplingMacrosHelper[ 1 ] );
- samplerArgs = string.Empty;
- samplerDecl = string.Empty;
- for( int i = 0; i < Constants.CustomASESamplingMacros.Length; i++ )
- {
- string value = string.Format( Constants.CustomASESamplingMacros[ i ], samplerArgs, samplePrefix, samplerDecl );
- dataCollector.AddToDirectives( value );
- }
- dataCollector.AddToDirectives( Constants.CustomASEStandarSamplingMacrosHelper[ 2 ] );
- }
- }
-
- public static void RegisterUnity2019MatrixDefines( ref MasterNodeDataCollector dataCollector )
- {
-#if UNITY_2019_1_OR_NEWER
- if( dataCollector.IsSRP && dataCollector.TemplateDataCollectorInstance.IsHDRP && ASEPackageManagerHelper.CurrentHDVersion >= ASESRPVersions.ASE_SRP_5_13_0 )
- {
- //dataCollector.AddToDefines( -1, "unity_CameraProjection UNITY_MATRIX_P" );
- //dataCollector.AddToDefines( -1, "unity_CameraInvProjection UNITY_MATRIX_I_P" );
- //dataCollector.AddToDefines( -1, "unity_WorldToCamera UNITY_MATRIX_V" );
- //dataCollector.AddToDefines( -1, "unity_CameraToWorld UNITY_MATRIX_I_V" );
-
- dataCollector.AddToUniforms( -1, "float4x4 unity_CameraProjection;" );
- dataCollector.AddToUniforms( -1, "float4x4 unity_CameraInvProjection;" );
- dataCollector.AddToUniforms( -1, "float4x4 unity_WorldToCamera;" );
- dataCollector.AddToUniforms( -1, "float4x4 unity_CameraToWorld;" );
- }
-#endif
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GeneratorUtils.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GeneratorUtils.cs.meta
deleted file mode 100644
index 190ac10d..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GeneratorUtils.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 7ab31d77d200c7a4ca43f4bf159de6b3
-timeCreated: 1490798546
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GenericMessage.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GenericMessage.cs
deleted file mode 100644
index 3a699c60..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GenericMessage.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using UnityEditor;
-using UnityEngine;
-using System.Collections.Generic;
-
-namespace AmplifyShaderEditor
-{
- public enum MessageSeverity
- {
- Normal,
- Warning,
- Error
- }
- public class GenericMessageData
- {
- public string message;
- public MessageSeverity severity;
- public bool console;
- public GenericMessageData( string msg, MessageSeverity svrty, bool csle )
- {
- message = msg;
- severity = svrty;
- console = csle;
- }
- }
-
- class GenericMessageUI
- {
- public delegate void OnMessageDisplay( string message, MessageSeverity severity, bool console );
- public event OnMessageDisplay OnMessageDisplayEvent;
-
- private const double MESSAGE_TIME = 2;
- private double m_currentMessageStartTime;
- private Queue<GenericMessageData> m_messageQueue;
- private bool m_displayingMessage;
-
- public GenericMessageUI()
- {
- m_messageQueue = new Queue<GenericMessageData>();
- m_displayingMessage = false;
- m_currentMessageStartTime = EditorApplication.timeSinceStartup;
- }
-
- public void Destroy()
- {
- m_messageQueue.Clear();
- OnMessageDisplayEvent = null;
- }
-
- public void AddToQueue( string message, MessageSeverity severity, bool console )
- {
- m_messageQueue.Enqueue( new GenericMessageData( message, severity, console ) );
- }
-
- public void Log( string message )
- {
- m_messageQueue.Enqueue( new GenericMessageData( message, MessageSeverity.Normal, true ) );
- Debug.Log( message );
- }
-
- public void LogError( string message )
- {
- m_messageQueue.Enqueue( new GenericMessageData( message, MessageSeverity.Error, true ) );
- Debug.LogError( message );
- }
-
- public void LogWarning( string message )
- {
- m_messageQueue.Enqueue( new GenericMessageData( message, MessageSeverity.Warning, true ) );
- Debug.LogWarning( message );
- }
-
- public void CheckForMessages()
- {
- if ( m_displayingMessage )
- {
- double timeLeft = EditorApplication.timeSinceStartup - m_currentMessageStartTime;
- if ( timeLeft > MESSAGE_TIME )
- {
- m_displayingMessage = false;
- }
- }
-
- if ( !m_displayingMessage )
- {
- if ( m_messageQueue.Count > 0 )
- {
- m_displayingMessage = true;
- GenericMessageData data = m_messageQueue.Dequeue();
- m_currentMessageStartTime = EditorApplication.timeSinceStartup;
-
- if ( OnMessageDisplayEvent != null )
- OnMessageDisplayEvent( data.message, data.severity, data.console );
- }
- }
- }
-
- public void CleanUpMessageStack()
- {
- m_displayingMessage = false;
- m_messageQueue.Clear();
- }
-
- public void StartMessageCounter()
- {
- m_displayingMessage = true;
- m_currentMessageStartTime = EditorApplication.timeSinceStartup;
- }
-
- public bool DisplayingMessage
- {
- get { return ( m_displayingMessage || m_messageQueue.Count > 0 ); }
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GenericMessage.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GenericMessage.cs.meta
deleted file mode 100644
index 13853703..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/GenericMessage.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 87cfef50a69ad24479fb8b472dac6d6e
-timeCreated: 1481126957
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/IOUtils.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/IOUtils.cs
deleted file mode 100644
index 30385506..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/IOUtils.cs
+++ /dev/null
@@ -1,843 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using System;
-using System.IO;
-using System.Security.Cryptography;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEditor;
-using System.Threading;
-using UnityEditor.VersionControl;
-
-namespace AmplifyShaderEditor
-{
- public enum ShaderLoadResult
- {
- LOADED,
- TEMPLATE_LOADED,
- FILE_NOT_FOUND,
- ASE_INFO_NOT_FOUND,
- UNITY_NATIVE_PATHS
- }
-
- public class Worker
- {
- public static readonly object locker = new object();
- public void DoWork()
- {
- while ( IOUtils.ActiveThread )
- {
- if ( IOUtils.SaveInThreadFlag )
- {
- IOUtils.SaveInThreadFlag = false;
- lock ( locker )
- {
- IOUtils.SaveInThreadShaderBody = IOUtils.ShaderCopywriteMessage + IOUtils.SaveInThreadShaderBody;
- // Add checksum
- string checksum = IOUtils.CreateChecksum( IOUtils.SaveInThreadShaderBody );
- IOUtils.SaveInThreadShaderBody += IOUtils.CHECKSUM + IOUtils.VALUE_SEPARATOR + checksum;
-
- // Write to disk
- StreamWriter fileWriter = new StreamWriter( IOUtils.SaveInThreadPathName );
- try
- {
- fileWriter.Write( IOUtils.SaveInThreadShaderBody );
- Debug.Log( "Saving complete" );
- }
- catch ( Exception e )
- {
- Debug.LogException( e );
- }
- finally
- {
- fileWriter.Close();
- }
- }
- }
- }
- Debug.Log( "Thread closed" );
- }
- }
-
- public static class IOUtils
- {
- public delegate void OnShaderAction( Shader shader, bool isTemplate, string type );
- public static OnShaderAction OnShaderSavedEvent;
- public static OnShaderAction OnShaderTypeChangedEvent;
-
- public static readonly string ShaderCopywriteMessage = "// Made with Amplify Shader Editor\n// Available at the Unity Asset Store - http://u3d.as/y3X \n";
- public static readonly string GrabPassEmpty = "\t\tGrabPass{ }\n";
- public static readonly string GrabPassBegin = "\t\tGrabPass{ \"";
- public static readonly string GrabPassEnd = "\" }\n";
- public static readonly string PropertiesBegin = "\tProperties\n\t{\n";
- public static readonly string PropertiesEnd = "\t}\n";
- public static readonly string PropertiesElement = "\t\t{0}\n";
- public static readonly string PropertiesElementsRaw = "{0}\n";
-
- public static readonly string PragmaTargetHeader = "\t\t#pragma target {0}\n";
- public static readonly string InstancedPropertiesHeader = "multi_compile_instancing";
- public static readonly string VirtualTexturePragmaHeader = "multi_compile _ _VT_SINGLE_MODE";
-
- public static readonly string InstancedPropertiesBegin = "UNITY_INSTANCING_CBUFFER_START({0})";
- public static readonly string InstancedPropertiesEnd = "UNITY_INSTANCING_CBUFFER_END";
- public static readonly string InstancedPropertiesElement = "UNITY_DEFINE_INSTANCED_PROP({0}, {1})";
- public static readonly string InstancedPropertiesData = "UNITY_ACCESS_INSTANCED_PROP({0})";
-
- public static readonly string DotsInstancedPropertiesData = "\tUNITY_DOTS_INSTANCED_PROP({0}, {1})";
- public static readonly string DotsInstancedDefinesData = "#define {1} UNITY_ACCESS_DOTS_INSTANCED_PROP_FROM_MACRO({0} , Metadata_{1})";
-
- public static readonly string LWSRPInstancedPropertiesBegin = "UNITY_INSTANCING_BUFFER_START({0})";
- public static readonly string LWSRPInstancedPropertiesEnd = "UNITY_INSTANCING_BUFFER_END({0})";
- public static readonly string LWSRPInstancedPropertiesElement = "UNITY_DEFINE_INSTANCED_PROP({0}, {1})";
- public static readonly string LWSRPInstancedPropertiesData = "UNITY_ACCESS_INSTANCED_PROP({0},{1})";
-
- public static readonly string SRPCBufferPropertiesBegin = "CBUFFER_START( UnityPerMaterial )";//"CBUFFER_START({0})";
- public static readonly string SRPCBufferPropertiesEnd = "CBUFFER_END";
-
-
- public static readonly string InstancedPropertiesBeginTabs = "\t\t"+ InstancedPropertiesBegin + "\n";
- public static readonly string InstancedPropertiesEndTabs = "\t\t"+ InstancedPropertiesEnd + "\n";
- public static readonly string InstancedPropertiesElementTabs = "\t\t\t"+ InstancedPropertiesElement + "\n";
-
- public static readonly string MetaBegin = "defaultTextures:";
- public static readonly string MetaEnd = "userData:";
- public static readonly string ShaderBodyBegin = "/*ASEBEGIN";
- public static readonly string ShaderBodyEnd = "ASEEND*/";
- //public static readonly float CurrentVersionFlt = 0.4f;
- //public static readonly string CurrentVersionStr = "Version=" + CurrentVersionFlt;
-
- public static readonly string CHECKSUM = "//CHKSM";
- public static readonly string LAST_OPENED_OBJ_ID = "ASELASTOPENOBJID";
-
- public static readonly string MAT_CLIPBOARD_ID = "ASEMATCLIPBRDID";
- public static readonly char FIELD_SEPARATOR = ';';
- public static readonly char VALUE_SEPARATOR = '=';
- public static readonly char LINE_TERMINATOR = '\n';
- public static readonly char VECTOR_SEPARATOR = ',';
- public static readonly char FLOAT_SEPARATOR = '.';
- public static readonly char CLIPBOARD_DATA_SEPARATOR = '|';
- public static readonly char MATRIX_DATA_SEPARATOR = '|';
- public readonly static string NO_TEXTURES = "<None>";
- public static readonly string SaveShaderStr = "Please enter shader name to save";
- public static readonly string FloatifyStr = ".0";
-
- // Node parameter names
- public const string NodeParam = "Node";
- public const string NodePosition = "Position";
- public const string NodeId = "Id";
- public const string NodeType = "Type";
- public const string WireConnectionParam = "WireConnection";
-
- public static readonly uint NodeTypeId = 1;
-
- public static readonly int InNodeId = 1;
- public static readonly int InPortId = 2;
- public static readonly int OutNodeId = 3;
- public static readonly int OutPortId = 4;
-
- public readonly static string DefaultASEDirtyCheckName = "__dirty";
- public readonly static string DefaultASEDirtyCheckProperty = "[HideInInspector] " + DefaultASEDirtyCheckName + "( \"\", Int ) = 1";
- public readonly static string DefaultASEDirtyCheckUniform = "uniform int " + DefaultASEDirtyCheckName + " = 1;";
-
- public readonly static string MaskClipValueName = "_Cutoff";
- public readonly static string MaskClipValueProperty = MaskClipValueName + "( \"{0}\", Float ) = {1}";
- public readonly static string MaskClipValueUniform = "uniform float " + MaskClipValueName + " = {0};";
-
- public readonly static string ChromaticAberrationProperty = "_ChromaticAberration";
-
- //public static readonly string ASEFolderGUID = "daca988099666ec40aaa2cde22bb4935";
- //public static string ASEResourcesPath = "/Plugins/EditorResources/";
- //public static string ASEFolderPath;
-
- //public static bool IsShaderFunctionWindow = false;
-
-
- public static int DefaultASEDirtyCheckId;
-
- // this is to be used in combination with AssetDatabase.GetAssetPath, both of these include the Assets/ path so we need to remove from one of them
- public static string dataPath;
-
-
- public static string EditorResourcesGUID = "0932db7ec1402c2489679c4b72eab5eb";
- public static string GraphBgTextureGUID = "881c304491028ea48b5027ac6c62cf73";
- public static string GraphFgTextureGUID = "8c4a7fca2884fab419769ccc0355c0c1";
- public static string WireTextureGUID = "06e687f68dd96f0448c6d8217bbcf608";
- public static string MasterNodeOnTextureGUID = "26c64fcee91024a49980ea2ee9d1a2fb";
- public static string MasterNodeOffTextureGUID = "712aee08d999c16438e2d694f42428e8";
- public static string GPUInstancedOnTextureGUID = "4b0c2926cc71c5846ae2a29652d54fb6";
- public static string GPUInstancedOffTextureGUID = "486c7766baaf21b46afb63c1121ef03e";
- public static string MainSkinGUID = "57482289c346f104a8162a3a79aaff9d";
-
- public static string UpdateOutdatedGUID = "cce638be049286c41bcbd0a26c356b18";
- public static string UpdateOFFGUID = "99d70ac09b4db9742b404c3f92d8564b";
- public static string UpdateUpToDatedGUID = "ce30b12fbb3223746bcfef9ea82effe3";
- public static string LiveOffGUID = "bb16faf366bcc6c4fbf0d7666b105354";
- public static string LiveOnGUID = "6a0ae1d7892333142aeb09585572202c";
- public static string LivePendingGUID = "e3182200efb67114eb5050f8955e1746";
- public static string CleanupOFFGUID = "f62c0c3a5ddcd844e905fb2632fdcb15";
- public static string CleanUpOnGUID = "615d853995cf2344d8641fd19cb09b5d";
- public static string TakeScreenshotOFFGUID = "7587de2e3bec8bf4d973109524ccc6b1";
- public static string TakeScreenshotONGUID = "7587de2e3bec8bf4d973109524ccc6b1";
- public static string ShareOFFGUID = "bc5bd469748466a459badfab23915cb0";
- public static string ShareONGUID = "bc5bd469748466a459badfab23915cb0";
- public static string OpenSourceCodeOFFGUID = "f7e8834b42791124095a8b7f2d4daac2";
- public static string OpenSourceCodeONGUID = "8b114792ff84f6546880c031eda42bc0";
- public static string FocusNodeGUID = "da673e6179c67d346abb220a6935e359";
- public static string FitViewGUID = "1def740f2314c6b4691529cadeee2e9c";
- public static string ShowInfoWindowGUID = "77af20044e9766840a6be568806dc22e";
- public static string ShowTipsWindowGUID = "066674048bbb1e64e8cdcc6c3b4abbeb";
- public static string ShowConsoleWindowGUID = "9a81d7df8e62c044a9d1cada0c8a2131";
-
-
- public static Dictionary<string, string> NodeTypeReplacer = new Dictionary<string, string>()
- {
- {"AmplifyShaderEditor.RotateAboutAxis", "AmplifyShaderEditor.RotateAboutAxisNode"},
- {"GlobalArrayNode", "AmplifyShaderEditor.GlobalArrayNode"},
- {"AmplifyShaderEditor.SimpleMaxOp", "AmplifyShaderEditor.SimpleMaxOpNode"},
- {"AmplifyShaderEditor.SimpleMinNode", "AmplifyShaderEditor.SimpleMinOpNode"},
- {"AmplifyShaderEditor.TFHCRemap", "AmplifyShaderEditor.TFHCRemapNode"},
- {"AmplifyShaderEditor.TFHCPixelateUV", "AmplifyShaderEditor.TFHCPixelate"},
- {"AmplifyShaderEditor.VirtualTexturePropertyNode", "AmplifyShaderEditor.VirtualTextureObject"}
- };
-
- private static readonly string AmplifyShaderEditorDefineSymbol = "AMPLIFY_SHADER_EDITOR";
-
- /////////////////////////////////////////////////////////////////////////////
- // THREAD IO UTILS
- public static bool SaveInThreadFlag = false;
- public static string SaveInThreadShaderBody;
- public static string SaveInThreadPathName;
- public static Thread SaveInThreadMainThread;
- public static bool ActiveThread = true;
- private static bool UseSaveThread = false;
-
- private static bool Initialized = false;
-
- public static bool FunctionNodeChanged = false;
-
- public static List<AmplifyShaderEditorWindow> AllOpenedWindows = new List<AmplifyShaderEditorWindow>();
-
- public static void StartSaveThread( string shaderBody, string pathName )
- {
- if( Provider.enabled && Provider.isActive )
- {
- Asset loadedAsset = Provider.GetAssetByPath( FileUtil.GetProjectRelativePath( pathName ) );
- if( loadedAsset != null )
- {
- //Task statusTask = Provider.Status( loadedAsset );
- //statusTask.Wait();
- //if( Provider.CheckoutIsValid( statusTask.assetList[ 0 ] ) )
- {
- Task checkoutTask = Provider.Checkout( loadedAsset, CheckoutMode.Both );
- checkoutTask.Wait();
- }
- }
- }
-
- if( UseSaveThread )
- {
- if ( !SaveInThreadFlag )
- {
- if ( SaveInThreadMainThread == null )
- {
- Worker worker = new Worker();
- SaveInThreadMainThread = new Thread( worker.DoWork );
- SaveInThreadMainThread.Start();
- Debug.Log( "Thread created" );
- }
-
- SaveInThreadShaderBody = shaderBody;
- SaveInThreadPathName = pathName;
- SaveInThreadFlag = true;
- }
- }
- else
- {
- SaveTextfileToDisk( shaderBody, pathName );
- }
- }
-
- ////////////////////////////////////////////////////////////////////////////
- public static void SetAmplifyDefineSymbolOnBuildTargetGroup( BuildTargetGroup targetGroup )
- {
- string currData = PlayerSettings.GetScriptingDefineSymbolsForGroup( targetGroup );
- if ( !currData.Contains( AmplifyShaderEditorDefineSymbol ) )
- {
- if ( string.IsNullOrEmpty( currData ) )
- {
- PlayerSettings.SetScriptingDefineSymbolsForGroup( targetGroup, AmplifyShaderEditorDefineSymbol );
- }
- else
- {
- if ( !currData[ currData.Length - 1 ].Equals( ';' ) )
- {
- currData += ';';
- }
- currData += AmplifyShaderEditorDefineSymbol;
- PlayerSettings.SetScriptingDefineSymbolsForGroup( targetGroup, currData );
- }
- }
- }
-
- public static void RemoveAmplifyDefineSymbolOnBuildTargetGroup( BuildTargetGroup targetGroup )
- {
- string currData = PlayerSettings.GetScriptingDefineSymbolsForGroup( targetGroup );
- if( currData.Contains( AmplifyShaderEditorDefineSymbol ) )
- {
- currData = currData.Replace( AmplifyShaderEditorDefineSymbol + ";", "" );
- currData = currData.Replace( ";" + AmplifyShaderEditorDefineSymbol, "" );
- currData = currData.Replace( AmplifyShaderEditorDefineSymbol, "" );
- PlayerSettings.SetScriptingDefineSymbolsForGroup( targetGroup, currData );
- }
- }
-
- public static void Init()
- {
- if ( !Initialized )
- {
- Initialized = true;
- if( EditorPrefs.GetBool( Preferences.PrefDefineSymbol, true ) )
- SetAmplifyDefineSymbolOnBuildTargetGroup( EditorUserBuildSettings.selectedBuildTargetGroup );
- //Array BuildTargetGroupValues = Enum.GetValues( typeof( BuildTargetGroup ));
- //for ( int i = 0; i < BuildTargetGroupValues.Length; i++ )
- //{
- // if( i != 0 && i != 15 && i != 16 )
- // SetAmplifyDefineSymbolOnBuildTargetGroup( ( BuildTargetGroup ) BuildTargetGroupValues.GetValue( i ) );
- //}
-
- DefaultASEDirtyCheckId = Shader.PropertyToID( DefaultASEDirtyCheckName );
- dataPath = Application.dataPath.Remove( Application.dataPath.Length - 6 );
-
-
- //ASEFolderPath = AssetDatabase.GUIDToAssetPath( ASEFolderGUID );
- //ASEResourcesPath = ASEFolderPath + ASEResourcesPath;
- }
- }
-
-
- public static void DumpTemplateManagers()
- {
- for( int i = 0; i < AllOpenedWindows.Count; i++ )
- {
- if( AllOpenedWindows[ i ].TemplatesManagerInstance != null )
- {
- Debug.Log( AllOpenedWindows[ i ].titleContent.text + ": " + AllOpenedWindows[ i ].TemplatesManagerInstance.GetInstanceID() );
- }
- }
- }
-
- public static TemplatesManager FirstValidTemplatesManager
- {
- get
- {
- for( int i = 0; i < AllOpenedWindows.Count; i++ )
- {
- if( AllOpenedWindows[ i ].TemplatesManagerInstance != null )
- {
- return AllOpenedWindows[ i ].TemplatesManagerInstance;
- }
- }
- return null;
- }
- }
-
- public static void UpdateSFandRefreshWindows( AmplifyShaderFunction function )
- {
- for( int i = 0; i < AllOpenedWindows.Count; i++ )
- {
- AllOpenedWindows[ i ].LateRefreshAvailableNodes();
- if( AllOpenedWindows[ i ].IsShaderFunctionWindow )
- {
- if( AllOpenedWindows[ i ].OpenedShaderFunction == function )
- {
- AllOpenedWindows[ i ].UpdateTabTitle();
- }
- }
- }
- }
-
- public static void UpdateIO()
- {
- int windowCount = AllOpenedWindows.Count;
- if ( windowCount == 0 )
- {
- EditorApplication.update -= IOUtils.UpdateIO;
- return;
- }
-
- for ( int i = 0; i < AllOpenedWindows.Count; i++ )
- {
- if ( AllOpenedWindows[i] == EditorWindow.focusedWindow )
- {
- UIUtils.CurrentWindow = AllOpenedWindows[ i ];
- }
-
- if( FunctionNodeChanged )
- AllOpenedWindows[ i ].CheckFunctions = true;
-
- if ( AllOpenedWindows[ i ] == null )
- {
- AllOpenedWindows.RemoveAt( i );
- i--;
- }
- }
-
- if ( FunctionNodeChanged )
- FunctionNodeChanged = false;
- }
-
- public static void Destroy()
- {
- ActiveThread = false;
- if ( SaveInThreadMainThread != null )
- {
- SaveInThreadMainThread.Abort();
- SaveInThreadMainThread = null;
- }
- }
-
- public static void GetShaderName( out string shaderName, out string fullPathname, string defaultName, string customDatapath )
- {
- string currDatapath = String.IsNullOrEmpty( customDatapath ) ? Application.dataPath : customDatapath;
- fullPathname = EditorUtility.SaveFilePanelInProject( "Select Shader to save", defaultName, "shader", SaveShaderStr, currDatapath );
- if ( !String.IsNullOrEmpty( fullPathname ) )
- {
- shaderName = fullPathname.Remove( fullPathname.Length - 7 ); // -7 remove .shader extension
- string[] subStr = shaderName.Split( '/' );
- if ( subStr.Length > 0 )
- {
- shaderName = subStr[ subStr.Length - 1 ]; // Remove pathname
- }
- }
- else
- {
- shaderName = string.Empty;
- }
- }
-
- public static void AddTypeToString( ref string myString, string typeName )
- {
- myString += typeName;
- }
-
- public static void AddFieldToString( ref string myString, string fieldName, object fieldValue )
- {
- myString += FIELD_SEPARATOR + fieldName + VALUE_SEPARATOR + fieldValue;
- }
-
- public static void AddFieldValueToString( ref string myString, object fieldValue )
- {
- myString += FIELD_SEPARATOR + fieldValue.ToString();
- }
-
- public static void AddLineTerminator( ref string myString )
- {
- myString += LINE_TERMINATOR;
- }
-
- public static string CreateChecksum( string buffer )
- {
- SHA1 sha1 = SHA1.Create();
- byte[] buf = System.Text.Encoding.UTF8.GetBytes( buffer );
- byte[] hash = sha1.ComputeHash( buf, 0, buf.Length );
- string hashstr = BitConverter.ToString( hash ).Replace( "-", "" );
- return hashstr;
- }
-
- public static void SaveTextfileToDisk( string shaderBody, string pathName, bool addAdditionalInfo = true )
- {
-
- if ( addAdditionalInfo )
- {
- shaderBody = ShaderCopywriteMessage + shaderBody;
- // Add checksum
- string checksum = CreateChecksum( shaderBody );
- shaderBody += CHECKSUM + VALUE_SEPARATOR + checksum;
- }
-
- // Write to disk
- StreamWriter fileWriter = new StreamWriter( pathName );
- try
- {
- fileWriter.Write( shaderBody );
- }
- catch ( Exception e )
- {
- Debug.LogException( e );
- }
- finally
- {
- fileWriter.Close();
- }
- }
-
- public static string AddAdditionalInfo( string shaderBody )
- {
- shaderBody = ShaderCopywriteMessage + shaderBody;
- string checksum = CreateChecksum( shaderBody );
- shaderBody += CHECKSUM + VALUE_SEPARATOR + checksum;
- return shaderBody;
- }
-
- public static string LoadTextFileFromDisk( string pathName )
- {
- string result = string.Empty;
- if ( !string.IsNullOrEmpty( pathName ) && File.Exists( pathName ) )
- {
-
- StreamReader fileReader = null;
- try
- {
- fileReader = new StreamReader( pathName );
- result = fileReader.ReadToEnd();
- }
- catch ( Exception e )
- {
- Debug.LogException( e );
- }
- finally
- {
- if( fileReader != null)
- fileReader.Close();
- }
- }
- return result;
- }
-
- public static bool IsASEShader( Shader shader )
- {
- string datapath = AssetDatabase.GetAssetPath( shader );
- if ( UIUtils.IsUnityNativeShader( datapath ) )
- {
- return false;
- }
-
- string buffer = LoadTextFileFromDisk( datapath );
- if ( String.IsNullOrEmpty( buffer ) || !IOUtils.HasValidShaderBody( ref buffer ) )
- {
- return false;
- }
- return true;
- }
-
- public static bool IsShaderFunction( string functionInfo )
- {
- string buffer = functionInfo;
- if ( String.IsNullOrEmpty( buffer ) || !IOUtils.HasValidShaderBody( ref buffer ) )
- {
- return false;
- }
- return true;
- }
-
- public static bool HasValidShaderBody( ref string shaderBody )
- {
- int shaderBodyBeginId = shaderBody.IndexOf( ShaderBodyBegin );
- if ( shaderBodyBeginId > -1 )
- {
- int shaderBodyEndId = shaderBody.IndexOf( ShaderBodyEnd );
- return ( shaderBodyEndId > -1 && shaderBodyEndId > shaderBodyBeginId );
- }
- return false;
- }
-
- public static int[] AllIndexesOf( this string str, string substr, bool ignoreCase = false )
- {
- if ( string.IsNullOrEmpty( str ) || string.IsNullOrEmpty( substr ) )
- {
- throw new ArgumentException( "String or substring is not specified." );
- }
-
- List<int> indexes = new List<int>();
- int index = 0;
-
- while ( ( index = str.IndexOf( substr, index, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal ) ) != -1 )
- {
- indexes.Add( index++ );
- }
-
- return indexes.ToArray();
- }
-
- public static void AddFunctionHeader( ref string function, string header )
- {
- function += "\t\t" + header + "\n\t\t{\n";
- }
-
- public static void AddSingleLineFunction( ref string function, string header )
- {
- function += "\t\t" + header;
- }
-
- public static void AddFunctionLine( ref string function, string line )
- {
- function += "\t\t\t" + line + "\n";
- }
-
- public static void CloseFunctionBody( ref string function )
- {
- function += "\t\t}\n";
- }
-
- public static string CreateFullFunction( string header, params string[] functionLines )
- {
- string result = string.Empty;
- AddFunctionHeader( ref result, header );
- for ( int i = 0; i > functionLines.Length; i++ )
- {
- AddFunctionLine( ref result, functionLines[ i ] );
- }
- CloseFunctionBody( ref result );
- return result;
- }
-
- public static string CreateCodeComments( bool forceForwardSlash, params string[] comments )
- {
- string finalComment = string.Empty;
- if ( comments.Length == 1 )
- {
- finalComment = "//" + comments[ 0 ];
- }
- else
- {
- if ( forceForwardSlash )
- {
- for ( int i = 0; i < comments.Length; i++ )
- {
- finalComment += "//" + comments[ i ];
- if ( i < comments.Length - 1 )
- {
- finalComment += "\n\t\t\t";
- }
- }
- }
- else
- {
- finalComment = "/*";
- for ( int i = 0; i < comments.Length; i++ )
- {
- if ( i != 0 )
- finalComment += "\t\t\t";
- finalComment += comments[ i ];
- if ( i < comments.Length - 1 )
- finalComment += "\n";
- }
- finalComment += "*/";
- }
- }
- return finalComment;
- }
-
- public static string GetUVChannelDeclaration( string uvName, int channelId, int set )
- {
- string uvSetStr = ( set == 0 ) ? "uv" : "uv" + Constants.AvailableUVSetsStr[ set ];
- return "float2 " + uvSetStr + uvName /*+ " : TEXCOORD" + channelId*/;
- }
-
- public static string GetUVChannelName( string uvName, int set )
- {
- string uvSetStr = ( set == 0 ) ? "uv" : "uv" + Constants.AvailableUVSetsStr[ set ];
- return uvSetStr + uvName;
- }
-
- public static string GetVertexUVChannelName( int set )
- {
- string uvSetStr = ( set == 0 ) ? "texcoord" : ( "texcoord" + set.ToString() );
- return uvSetStr;
- }
-
- public static string Floatify( float value )
- {
- return ( value % 1 ) != 0 ? value.ToString() : ( value.ToString() + FloatifyStr );
- }
-
- public static string Vector2ToString( Vector2 data )
- {
- return data.x.ToString() + VECTOR_SEPARATOR + data.y.ToString();
- }
-
- public static string Vector3ToString( Vector3 data )
- {
- return data.x.ToString() + VECTOR_SEPARATOR + data.y.ToString() + VECTOR_SEPARATOR + data.z.ToString();
- }
-
- public static string Vector4ToString( Vector4 data )
- {
- return data.x.ToString() + VECTOR_SEPARATOR + data.y.ToString() + VECTOR_SEPARATOR + data.z.ToString() + VECTOR_SEPARATOR + data.w.ToString();
- }
-
- public static string ColorToString( Color data )
- {
- return data.r.ToString() + VECTOR_SEPARATOR + data.g.ToString() + VECTOR_SEPARATOR + data.b.ToString() + VECTOR_SEPARATOR + data.a.ToString();
- }
-
- public static string Matrix3x3ToString( Matrix4x4 matrix )
- {
- return matrix[ 0, 0 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 0, 1 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 0, 2 ].ToString() + IOUtils.VECTOR_SEPARATOR +
- matrix[ 1, 0 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 1, 1 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 1, 2 ].ToString() + IOUtils.VECTOR_SEPARATOR +
- matrix[ 2, 0 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 2, 1 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 2, 2 ].ToString();
- }
-
- public static string Matrix4x4ToString( Matrix4x4 matrix )
- {
- return matrix[ 0, 0 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 0, 1 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 0, 2 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 0, 3 ].ToString() + IOUtils.VECTOR_SEPARATOR +
- matrix[ 1, 0 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 1, 1 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 1, 2 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 1, 3 ].ToString() + IOUtils.VECTOR_SEPARATOR +
- matrix[ 2, 0 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 2, 1 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 2, 2 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 2, 3 ].ToString() + IOUtils.VECTOR_SEPARATOR +
- matrix[ 3, 0 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 3, 1 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 3, 2 ].ToString() + IOUtils.VECTOR_SEPARATOR + matrix[ 3, 3 ].ToString();
- }
-
- public static Vector2 StringToVector2( string data )
- {
- string[] parsedData = data.Split( VECTOR_SEPARATOR );
- if ( parsedData.Length >= 2 )
- {
- return new Vector2( Convert.ToSingle( parsedData[ 0 ] ),
- Convert.ToSingle( parsedData[ 1 ] ) );
- }
- return Vector2.zero;
- }
-
- public static Vector3 StringToVector3( string data )
- {
- string[] parsedData = data.Split( VECTOR_SEPARATOR );
- if ( parsedData.Length >= 3 )
- {
- return new Vector3( Convert.ToSingle( parsedData[ 0 ] ),
- Convert.ToSingle( parsedData[ 1 ] ),
- Convert.ToSingle( parsedData[ 2 ] ) );
- }
- return Vector3.zero;
- }
-
- public static Vector4 StringToVector4( string data )
- {
- string[] parsedData = data.Split( VECTOR_SEPARATOR );
- if ( parsedData.Length >= 4 )
- {
- return new Vector4( Convert.ToSingle( parsedData[ 0 ] ),
- Convert.ToSingle( parsedData[ 1 ] ),
- Convert.ToSingle( parsedData[ 2 ] ),
- Convert.ToSingle( parsedData[ 3 ] ) );
- }
- return Vector4.zero;
- }
-
- public static Color StringToColor( string data )
- {
- string[] parsedData = data.Split( VECTOR_SEPARATOR );
- if ( parsedData.Length >= 4 )
- {
- return new Color( Convert.ToSingle( parsedData[ 0 ] ),
- Convert.ToSingle( parsedData[ 1 ] ),
- Convert.ToSingle( parsedData[ 2 ] ),
- Convert.ToSingle( parsedData[ 3 ] ) );
- }
- return Color.white;
- }
-
- public static Matrix4x4 StringToMatrix3x3( string data )
- {
- string[] parsedData = data.Split( VECTOR_SEPARATOR );
- if ( parsedData.Length == 9 )
- {
- Matrix4x4 matrix = new Matrix4x4();
- matrix[ 0, 0 ] = Convert.ToSingle( parsedData[ 0 ] );
- matrix[ 0, 1 ] = Convert.ToSingle( parsedData[ 1 ] );
- matrix[ 0, 2 ] = Convert.ToSingle( parsedData[ 2 ] );
-
- matrix[ 1, 0 ] = Convert.ToSingle( parsedData[ 3 ] );
- matrix[ 1, 1 ] = Convert.ToSingle( parsedData[ 4 ] );
- matrix[ 1, 2 ] = Convert.ToSingle( parsedData[ 5 ] );
-
- matrix[ 2, 0 ] = Convert.ToSingle( parsedData[ 6 ] );
- matrix[ 2, 1 ] = Convert.ToSingle( parsedData[ 7 ] );
- matrix[ 2, 2 ] = Convert.ToSingle( parsedData[ 8 ] );
- return matrix;
- }
- return Matrix4x4.identity;
- }
-
- public static Matrix4x4 StringToMatrix4x4( string data )
- {
- string[] parsedData = data.Split( VECTOR_SEPARATOR );
- if ( parsedData.Length == 16 )
- {
- Matrix4x4 matrix = new Matrix4x4();
- matrix[ 0, 0 ] = Convert.ToSingle( parsedData[ 0 ] );
- matrix[ 0, 1 ] = Convert.ToSingle( parsedData[ 1 ] );
- matrix[ 0, 2 ] = Convert.ToSingle( parsedData[ 2 ] );
- matrix[ 0, 3 ] = Convert.ToSingle( parsedData[ 3 ] );
-
- matrix[ 1, 0 ] = Convert.ToSingle( parsedData[ 4 ] );
- matrix[ 1, 1 ] = Convert.ToSingle( parsedData[ 5 ] );
- matrix[ 1, 2 ] = Convert.ToSingle( parsedData[ 6 ] );
- matrix[ 1, 3 ] = Convert.ToSingle( parsedData[ 7 ] );
-
- matrix[ 2, 0 ] = Convert.ToSingle( parsedData[ 8 ] );
- matrix[ 2, 1 ] = Convert.ToSingle( parsedData[ 9 ] );
- matrix[ 2, 2 ] = Convert.ToSingle( parsedData[ 10 ] );
- matrix[ 2, 3 ] = Convert.ToSingle( parsedData[ 11 ] );
-
- matrix[ 3, 0 ] = Convert.ToSingle( parsedData[ 12 ] );
- matrix[ 3, 1 ] = Convert.ToSingle( parsedData[ 13 ] );
- matrix[ 3, 2 ] = Convert.ToSingle( parsedData[ 14 ] );
- matrix[ 3, 3 ] = Convert.ToSingle( parsedData[ 15 ] );
- return matrix;
- }
- return Matrix4x4.identity;
- }
-
- public static void SaveTextureToDisk( Texture2D tex, string pathname )
- {
- byte[] rawData = tex.GetRawTextureData();
- Texture2D newTex = new Texture2D( tex.width, tex.height, tex.format, tex.mipmapCount > 1, false );
- newTex.LoadRawTextureData( rawData );
- newTex.Apply();
- byte[] pngData = newTex.EncodeToPNG();
- File.WriteAllBytes( pathname, pngData );
- }
-
- //public static void SaveObjToList( string newObj )
- //{
- // Debug.Log( UIUtils.CurrentWindow.Lastpath );
- // UIUtils.CurrentWindow.Lastpath = newObj;
- // string lastOpenedObj = EditorPrefs.GetString( IOUtils.LAST_OPENED_OBJ_ID );
- // string[] allLocations = lastOpenedObj.Split( ':' );
-
- // string lastLocation = allLocations[ allLocations.Length - 1 ];
-
- // string resave = string.Empty;
- // for ( int i = 0; i < allLocations.Length; i++ )
- // {
- // if ( string.IsNullOrEmpty( allLocations[ i ] ) )
- // continue;
-
- // resave += allLocations[ i ];
- // resave += ":";
- // }
-
- // resave += newObj;
- // EditorPrefs.SetString( IOUtils.LAST_OPENED_OBJ_ID, resave );
- //}
-
- //public static void DeleteObjFromList( string newObj )
- //{
- // string lastOpenedObj = EditorPrefs.GetString( IOUtils.LAST_OPENED_OBJ_ID );
- // string[] allLocations = lastOpenedObj.Split( ':' );
-
- // string resave = string.Empty;
- // for ( int i = 0; i < allLocations.Length; i++ )
- // {
- // if ( string.IsNullOrEmpty( allLocations[ i ] ) || newObj.Equals( allLocations[ i ] ) )
- // continue;
-
- // resave += allLocations[ i ];
- // if ( i < allLocations.Length - 1 )
- // resave += ":";
- // }
-
- // EditorPrefs.SetString( IOUtils.LAST_OPENED_OBJ_ID, resave );
- //}
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/IOUtils.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/IOUtils.cs.meta
deleted file mode 100644
index 08f17515..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/IOUtils.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: d39b4c96fb4d7f847b3a21c377d4188d
-timeCreated: 1481126959
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InlineProperty.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InlineProperty.cs
deleted file mode 100644
index 55113c61..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InlineProperty.cs
+++ /dev/null
@@ -1,320 +0,0 @@
-using UnityEngine;
-using UnityEditor;
-using System;
-
-namespace AmplifyShaderEditor
-{
- [System.Serializable]
- public class InlineProperty
- {
- [SerializeField]
- private float m_value = 0;
-
- [SerializeField]
- private bool m_active = false;
-
- [SerializeField]
- private int m_nodeId = -1;
-
- [SerializeField]
- private string m_nodePropertyName = string.Empty;
-
- public InlineProperty() { }
-
- public InlineProperty( float val )
- {
- m_value = val;
- }
-
- public InlineProperty( int val )
- {
- m_value = val;
- }
-
- public void ResetProperty()
- {
- m_nodeId = -1;
- m_active = false;
- }
-
- public void CopyFrom( InlineProperty other )
- {
- m_value = other.m_value;
- m_active = other.m_active;
- m_nodeId = other.m_nodeId;
- }
-
- public void SetInlineByName( string propertyName )
- {
- m_nodeId = UIUtils.GetNodeIdByName( propertyName );
- m_nodePropertyName = propertyName;
- m_active = m_nodeId != -1;
- }
-
- public void IntField( ref UndoParentNode owner, string content )
- {
- if( !m_active )
- {
- EditorGUILayout.BeginHorizontal();
- m_value = owner.EditorGUILayoutIntField( content, (int)m_value );
- if( GUILayout.Button( UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF, GUILayout.Width( 15 ), GUILayout.Height( 15 ) ) )
- m_active = !m_active;
- EditorGUILayout.EndHorizontal();
- }
- else
- {
- DrawPicker( ref owner, content );
- }
- }
-
- public void IntSlider( ref UndoParentNode owner, GUIContent content, int min, int max )
- {
- if( !m_active )
- {
- EditorGUILayout.BeginHorizontal();
- m_value = owner.EditorGUILayoutIntSlider( content, (int)m_value, min, max );
- if( GUILayout.Button( UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF, GUILayout.Width( 15 ), GUILayout.Height( 15 ) ) )
- m_active = !m_active;
- EditorGUILayout.EndHorizontal();
- }
- else
- {
- DrawPicker( ref owner, content );
- }
- }
-
- public void IntSlider( ref UndoParentNode owner, string content, int min, int max )
- {
- if( !m_active )
- {
- EditorGUILayout.BeginHorizontal();
- m_value = owner.EditorGUILayoutIntSlider( content, (int)m_value, min, max );
- if( GUILayout.Button( UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF, GUILayout.Width( 15 ), GUILayout.Height( 15 ) ) )
- m_active = !m_active;
- EditorGUILayout.EndHorizontal();
- }
- else
- {
- DrawPicker( ref owner, content );
- }
- }
-
- public void EnumTypePopup( ref UndoParentNode owner, string content, string[] displayOptions )
- {
- if( !m_active )
- {
- EditorGUILayout.BeginHorizontal();
- m_value = owner.EditorGUILayoutPopup( content, (int)m_value, displayOptions );
- if( GUILayout.Button( UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF, GUILayout.Width( 15 ), GUILayout.Height( 15 ) ) )
- m_active = !m_active;
- EditorGUILayout.EndHorizontal();
-
- }
- else
- {
- DrawPicker( ref owner, content );
- }
- }
-
- public void FloatField( ref UndoParentNode owner, string content )
- {
- if( !m_active )
- {
- EditorGUILayout.BeginHorizontal();
- m_value = owner.EditorGUILayoutFloatField( content, m_value );
- if( GUILayout.Button( UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF, GUILayout.Width( 15 ), GUILayout.Height( 15 ) ) )
- m_active = !m_active;
- EditorGUILayout.EndHorizontal();
- }
- else
- {
- DrawPicker( ref owner, content );
- }
- }
-
- public void SliderField( ref UndoParentNode owner, string content, float min, float max )
- {
- if( !m_active )
- {
- EditorGUILayout.BeginHorizontal();
- m_value = owner.EditorGUILayoutSlider( content, m_value, min, max );
- if( GUILayout.Button( UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF, GUILayout.Width( 15 ), GUILayout.Height( 15 ) ) )
- m_active = !m_active;
- EditorGUILayout.EndHorizontal();
- }
- else
- {
- DrawPicker( ref owner, content );
- }
- }
-
- public void RangedFloatField( ref UndoParentNode owner, string content, float min, float max )
- {
- if( !m_active )
- {
- EditorGUILayout.BeginHorizontal();
- m_value = owner.EditorGUILayoutRangedFloatField( content, m_value, min, max );
- if( GUILayout.Button( UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF, GUILayout.Width( 15 ), GUILayout.Height( 15 ) ) )
- m_active = !m_active;
- EditorGUILayout.EndHorizontal();
- }
- else
- {
- DrawPicker( ref owner, content );
- }
- }
-
-
- public void CustomDrawer( ref UndoParentNode owner, DrawPropertySection Drawer, string content )
- {
- if( !m_active )
- {
- EditorGUILayout.BeginHorizontal();
- Drawer( owner );
- if( GUILayout.Button( UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF, GUILayout.Width( 15 ), GUILayout.Height( 15 ) ) )
- m_active = !m_active;
- EditorGUILayout.EndHorizontal();
- }
- else
- {
- DrawPicker( ref owner, content );
- }
- }
-
- public delegate void DrawPropertySection( UndoParentNode owner );
-
- private void DrawPicker( ref UndoParentNode owner, GUIContent content )
- {
- DrawPicker( ref owner, content.text );
- }
-
- private void DrawPicker( ref UndoParentNode owner, string content )
- {
- EditorGUILayout.BeginHorizontal();
- m_nodeId = owner.EditorGUILayoutIntPopup( content, m_nodeId, UIUtils.FloatIntNodeArr(), UIUtils.FloatIntNodeIds() );
- if( GUILayout.Button( UIUtils.FloatIntIconOFF, UIUtils.FloatIntPickerONOFF, GUILayout.Width( 15 ), GUILayout.Height( 15 ) ) )
- m_active = !m_active;
- EditorGUILayout.EndHorizontal();
- }
-
- public string GetValueOrProperty( bool parentesis = true )
- {
- if( m_active )
- {
- PropertyNode node = GetPropertyNode();
- if( node != null )
- {
- return parentesis ? "[" + node.PropertyName + "]" : node.PropertyName;
- }
- else
- {
- m_active = false;
- m_nodeId = -1;
- return m_value.ToString();
- }
- }
- else
- {
- return m_value.ToString();
- }
- }
-
- public string GetValueOrProperty( string defaultValue, bool parentesis = true )
- {
- if( m_active )
- {
- PropertyNode node = GetPropertyNode();
- if( node != null )
- {
- return parentesis ? "[" + node.PropertyName + "]" : node.PropertyName;
- }
- else if( !string.IsNullOrEmpty( defaultValue ) )
- {
- m_active = false;
- m_nodeId = -1;
- return defaultValue;
- }
- else
- {
- m_active = false;
- m_nodeId = -1;
- return m_value.ToString();
- }
- }
- else
- {
- return defaultValue;
- }
- }
-
- public void ReadFromString( ref uint index, ref string[] nodeParams, bool isInt = true )
- {
- m_value = isInt ? Convert.ToInt32( nodeParams[ index++ ] ) : Convert.ToSingle( nodeParams[ index++ ] );
- m_active = Convert.ToBoolean( nodeParams[ index++ ] );
- m_nodeId = Convert.ToInt32( nodeParams[ index++ ] );
- }
-
- public void ReadFromSingle( string singleLine )
- {
- string[] data = singleLine.Split( IOUtils.VECTOR_SEPARATOR );
- m_value = Convert.ToSingle( data[ 0 ] );
- m_active = Convert.ToBoolean( data[ 1 ] );
- m_nodeId = Convert.ToInt32( data[ 2 ] );
- }
-
- public void WriteToString( ref string nodeInfo )
- {
- IOUtils.AddFieldValueToString( ref nodeInfo, m_value );
- IOUtils.AddFieldValueToString( ref nodeInfo, m_active );
- IOUtils.AddFieldValueToString( ref nodeInfo, m_nodeId );
- }
-
- public string WriteToSingle()
- {
- return m_value.ToString() + IOUtils.VECTOR_SEPARATOR + m_active + IOUtils.VECTOR_SEPARATOR + m_nodeId;
- }
-
- public void SetInlineNodeValue()
- {
- if( IsValid )
- {
- RangedFloatNode fnode = UIUtils.GetNode( m_nodeId ) as RangedFloatNode;
- if( fnode != null )
- {
- fnode.Value = m_value;
- fnode.SetMaterialValueFromInline( m_value );
- }
- else
- {
- IntNode inode = UIUtils.GetNode( m_nodeId ) as IntNode;
- inode.Value = (int)m_value;
- inode.SetMaterialValueFromInline( (int)m_value );
- }
- }
- }
-
- public bool IsValid { get { return m_active && m_nodeId != -1; } }
-
- public PropertyNode GetPropertyNode()
- {
- if( m_nodeId >= 0 )
- return UIUtils.GetNode( m_nodeId ) as PropertyNode;
-
- if( m_nodeId < -1 )
- {
- if(!string.IsNullOrEmpty(m_nodePropertyName))
- return UIUtils.GetInternalTemplateNode( m_nodePropertyName );
-
-
- return UIUtils.GetInternalTemplateNode( m_nodeId );
- }
-
- return null;
- }
-
- public int IntValue { get { return (int)m_value; } set { m_value = value; } }
- public float FloatValue { get { return m_value; } set { m_value = value; } }
- public bool Active { get { return m_active; } set { m_active = value; } }
- public int NodeId { get { return m_nodeId; } set { m_nodeId = value; } }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InlineProperty.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InlineProperty.cs.meta
deleted file mode 100644
index 7c5e45d6..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InlineProperty.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: f4f4421f529503243bfef5076ae82512
-timeCreated: 1519298230
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InvalidDataChecker.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InvalidDataChecker.cs
deleted file mode 100644
index b5540b2f..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InvalidDataChecker.cs
+++ /dev/null
@@ -1,172 +0,0 @@
-using UnityEditor;
-using UnityEngine;
-using System;
-using System.Collections;
-using UnityEngine.Networking;
-
-namespace AmplifyShaderEditor
-{
- [InitializeOnLoad]
- public class InvalidDataChecker
- {
- private static string[] m_invalidData = { "674ea7bed6b1cd94b8057074298096db", //"/Samples",
- "2738539936eacef409be91f148b2a4a0", //"/Resources",
- "c880e50f07f2be9499d414ac6f9f3a7a", //"/Templates",
- "563f992b9989cf547ac59bf748442c17"};//"/Textures"};
- //private static string m_ASEFolderPath;
- private static string m_invalidDataCollected = string.Empty;
- static InvalidDataChecker()
- {
- bool foundInvalidData = false;
- //m_ASEFolderPath = AssetDatabase.GUIDToAssetPath( IOUtils.ASEFolderGUID );
- int count = 0;
- for ( int i = 0; i < m_invalidData.Length; i++ )
- {
- //m_invalidData[ i ] = m_ASEFolderPath + m_invalidData[ i ];
- m_invalidData[ i ] = AssetDatabase.GUIDToAssetPath( m_invalidData[ i ] );
- if ( AssetDatabase.IsValidFolder( m_invalidData[ i ] ) )
- {
- foundInvalidData = true;
- m_invalidDataCollected += m_invalidData[ i ]+"\n";
- count += 1;
- }
- }
- if ( count < 5 )
- {
- for ( ; count < 5; count++ )
- {
- m_invalidDataCollected += "\n";
- }
- }
-
- if ( foundInvalidData )
- {
- InvalidDataPopUp window = ( InvalidDataPopUp ) EditorWindow.GetWindow( typeof( InvalidDataPopUp ), true, "Found Invalid Data" );
- window.minSize = new Vector2( 502, 265 );
- window.maxSize = new Vector2( 502, 265 );
- window.Show();
- }
-
- EditorApplication.update += Update;
- }
-
- static void Update()
- {
- EditorApplication.update -= Update;
-
- if( !EditorApplication.isPlayingOrWillChangePlaymode )
- {
- Preferences.ShowOption show = Preferences.ShowOption.Never;
- if( !EditorPrefs.HasKey( Preferences.PrefStartUp ) )
- {
- show = Preferences.ShowOption.Always;
- EditorPrefs.SetInt( Preferences.PrefStartUp, 0 );
- }
- else
- {
- if( Time.realtimeSinceStartup < 10 )
- {
- show = (Preferences.ShowOption) EditorPrefs.GetInt( Preferences.PrefStartUp, 0 );
- // check version here
- if( show == Preferences.ShowOption.OnNewVersion )
- {
- ASEStartScreen.StartBackgroundTask( StartRequest( ASEStartScreen.ChangelogURL, () =>
- {
- var changeLog = ChangeLogInfo.CreateFromJSON( www.downloadHandler.text );
- if( changeLog != null )
- {
- if( changeLog.Version > VersionInfo.FullNumber )
- ASEStartScreen.Init();
- }
- } ) );
- }
- }
- }
-
- if( show == Preferences.ShowOption.Always )
- ASEStartScreen.Init();
- }
- }
-
- static UnityWebRequest www;
-
- static IEnumerator StartRequest( string url, Action success = null )
- {
- using( www = UnityWebRequest.Get( url ) )
- {
-#if UNITY_2017_2_OR_NEWER
- yield return www.SendWebRequest();
-#else
- yield return www.Send();
-#endif
-
- while( www.isDone == false )
- yield return null;
-
- if( success != null )
- success();
- }
- }
-
- public static void CleanInvalidData()
- {
- for ( int i = 0; i < m_invalidData.Length; i++ )
- {
- if ( FileUtil.DeleteFileOrDirectory( m_invalidData[ i ] ) )
- {
- Debug.Log( "Removed invalid " + m_invalidData[ i ] );
- if ( FileUtil.DeleteFileOrDirectory( m_invalidData[ i ] + ".meta" ) )
- {
- Debug.Log( "Removed invalid " + m_invalidData[ i ] + ".meta" );
- }
- }
- }
- AssetDatabase.Refresh();
- }
-
- public static string InvalidDataCollected { get { return m_invalidDataCollected; } }
- }
-
- public class InvalidDataPopUp : EditorWindow
- {
- private readonly GUIContent m_buttonContent = new GUIContent( "Remove Invalid Data" );
- private Vector2 m_scrollPosition = Vector2.zero;
- public void OnGUI()
- {
- GUILayout.BeginVertical();
- {
- GUIStyle labelStyle = new GUIStyle( EditorStyles.label );
- labelStyle.alignment = TextAnchor.MiddleCenter;
- labelStyle.wordWrap = true;
- GUILayout.Label( "\nAmplify Shader Editor " + VersionInfo.StaticToString(), labelStyle, GUILayout.ExpandWidth( true ) );
- GUILayout.Space( 5 );
- GUILayout.Label( "Invalid/Legacy Data was found on your previous ASE folder which needs to be removed in order for it to work correctly." , labelStyle, GUILayout.ExpandWidth( true ) );
- GUILayout.Space( 5 );
- GUILayout.Label( "Below are the detected files/folders which require to be removed.", labelStyle, GUILayout.ExpandWidth( true ) );
- GUILayout.Space( 5 );
-
- m_scrollPosition = GUILayout.BeginScrollView( m_scrollPosition ,GUILayout.Height(85));
-
- GUILayout.TextArea( InvalidDataChecker.InvalidDataCollected );
- GUILayout.EndScrollView();
-
-
- GUILayout.Label( "VERY IMPORTANT: If you have assets of yours inside these folders you need to move them to another location before hitting the button below or they will be PERMANENTLY DELETED", labelStyle, GUILayout.ExpandWidth( true ) );
- GUILayout.Space( 5 );
-
- GUILayout.BeginHorizontal();
- {
- GUILayout.Space( 151 );
- if ( GUILayout.Button( m_buttonContent, GUILayout.Width( 200 ) ) )
- {
- InvalidDataChecker.CleanInvalidData();
- Close();
- }
- }
- GUILayout.EndHorizontal();
- }
- GUILayout.EndVertical();
-
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InvalidDataChecker.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InvalidDataChecker.cs.meta
deleted file mode 100644
index daaec410..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/InvalidDataChecker.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: c71b815458d61e24184a60dbce19573d
-timeCreated: 1481126959
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/NodeExporterUtils.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/NodeExporterUtils.cs
deleted file mode 100644
index 0f2ca737..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/NodeExporterUtils.cs
+++ /dev/null
@@ -1,284 +0,0 @@
-using UnityEngine;
-using UnityEditor;
-using System.Collections.Generic;
-
-namespace AmplifyShaderEditor
-{
- public enum DebugScreenShotNodeState
- {
- CreateNode,
- FocusOnNode,
- TakeScreenshot,
- WaitFrame,
- DeleteNode
- };
-
- public enum DebugUndoNodeState
- {
- CreateNode,
- FocusOnNode,
- WaitFrameCreate,
- DeleteNode,
- WaitFrameDelete,
- UndoNode,
- WaitFrameUndo,
- PrepareForNext
- };
-
-
- public class NodeExporterUtils
- {
- //Auto-Screenshot nodes
- private RenderTexture m_screenshotRT;
- private Texture2D m_screenshotTex2D;
- private List<ContextMenuItem> m_screenshotList = new List<ContextMenuItem>();
- private DebugScreenShotNodeState m_screenShotState;
- private bool m_takingShots = false;
-
- private DebugUndoNodeState m_undoState;
- private bool m_testingUndo = false;
-
-
- private AmplifyShaderEditorWindow m_window;
- private ParentNode m_node;
-
-
- private string m_pathname;
-
- public NodeExporterUtils( AmplifyShaderEditorWindow window )
- {
- m_window = window;
- Undo.undoRedoPerformed += OnUndoRedoPerformed;
- }
-
- public void OnUndoRedoPerformed()
- {
- if( m_testingUndo && m_undoState == DebugUndoNodeState.WaitFrameUndo )
- {
- m_undoState = DebugUndoNodeState.PrepareForNext;
- }
- }
-
- public void CalculateShaderInstructions( Shader shader )
- {
- //Type shaderutilType = Type.GetType( "UnityEditor.ShaderUtil, UnityEditor" );
- //shaderutilType.InvokeMember( "OpenCompiledShader", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, null, new object[] { shader, mode, customPlatformsMask, includeAllVariants } );
- }
-
- public void ActivateAutoScreenShot( string pathname, int from, int to )
- {
-
- m_pathname = pathname;
- if( !System.IO.Directory.Exists( m_pathname ) )
- {
- System.IO.Directory.CreateDirectory( m_pathname );
- }
-
- m_screenshotRT = new RenderTexture( (int)m_window.position.width, (int)m_window.position.height, 0 );
- m_screenshotTex2D = new Texture2D( (int)m_window.position.width, (int)m_window.position.height, TextureFormat.RGB24, false );
-
- RenderTexture.active = m_screenshotRT;
- m_window.CurrentPaletteWindow.FillList( ref m_screenshotList, true );
- m_window.CurrentGraph.ClearGraph();
- if( m_window.IsShaderFunctionWindow )
- {
- m_window.CurrentGraph.CurrentOutputNode.Vec2Position = new Vector2( 1500, 0 );
- }
- else
- {
- m_window.CurrentGraph.CurrentMasterNode.Vec2Position = new Vector2( 1500, 0 );
- }
- m_window.ResetCameraSettings();
-
- m_takingShots = true;
- m_screenShotState = DebugScreenShotNodeState.CreateNode;
-
- }
-
- public void ActivateNodesURL( int from , int to )
- {
- m_window.CurrentPaletteWindow.FillList( ref m_screenshotList, true );
-
- if( to < 0 || to > m_screenshotList.Count )
- to = m_screenshotList.Count;
-
- if( from >= to )
- return;
-
- for( int i = from; i < to; i++ )
- {
- if( m_screenshotList[ i ].NodeType != typeof( FunctionNode ) )
- {
- Application.OpenURL( m_screenshotList[ i ].NodeAttributes.NodeUrl );
- }
- }
- }
-
- public void ActivateAutoUndo()
- {
- m_window.CurrentPaletteWindow.FillList( ref m_screenshotList, true );
- m_window.CurrentGraph.ClearGraph();
- m_window.CurrentGraph.CurrentMasterNode.Vec2Position = new Vector2( 1500, 0 );
- m_window.ResetCameraSettings();
-
- m_testingUndo = true;
- m_undoState = DebugUndoNodeState.CreateNode;
- }
-
-
- public void Update()
- {
- if( m_testingUndo )
- {
- if( Event.current.type == EventType.Repaint )
- {
- m_window.Focus();
- switch( m_undoState )
- {
- case DebugUndoNodeState.CreateNode:
- {
- m_window.CurrentGraph.DeSelectAll();
- m_node = m_window.CreateNode( m_screenshotList[ 0 ].NodeType, Vector2.zero, null, true );
- m_node.RefreshExternalReferences();
- m_undoState = DebugUndoNodeState.FocusOnNode;
- Debug.Log( "Created " + m_node.Attributes.Name );
- }
- break;
- case DebugUndoNodeState.FocusOnNode:
- {
- m_window.FocusOnPoint( m_node.TruePosition.center, 1, false );
- m_undoState = DebugUndoNodeState.WaitFrameCreate;
- Debug.Log( "Focused " + m_node.Attributes.Name );
- }
- break;
- case DebugUndoNodeState.WaitFrameCreate:
- {
- m_undoState = DebugUndoNodeState.DeleteNode;
- Debug.Log( "Waiting on Create" );
- }
- break;
- case DebugUndoNodeState.DeleteNode:
- {
- Debug.Log( "Deleting " + m_node.Attributes.Name );
- m_window.DeleteSelectedNodeWithRepaint();
- m_undoState = DebugUndoNodeState.WaitFrameDelete;
- }
- break;
- case DebugUndoNodeState.WaitFrameDelete:
- {
- m_undoState = DebugUndoNodeState.UndoNode;
- Debug.Log( "Waiting on Delete" );
- }
- break;
- case DebugUndoNodeState.UndoNode:
- {
- Debug.Log( "Performing Undo" );
- m_undoState = DebugUndoNodeState.WaitFrameUndo;
- Undo.PerformUndo();
- }
- break;
- case DebugUndoNodeState.WaitFrameUndo: { } break;
- case DebugUndoNodeState.PrepareForNext:
- {
- m_screenshotList.RemoveAt( 0 );
- Debug.Log( "Undo Performed. Nodes Left " + m_screenshotList.Count );
- m_testingUndo = m_screenshotList.Count > 0;
- if( m_testingUndo )
- {
- m_undoState = DebugUndoNodeState.CreateNode;
- Debug.Log( "Going to next node" );
- }
- else
- {
- Debug.Log( "Finished Undo Test" );
- }
- }
- break;
-
- }
- }
- }
-
-
- if( m_takingShots )
- {
- m_window.Focus();
- switch( m_screenShotState )
- {
- case DebugScreenShotNodeState.CreateNode:
- {
- m_node = m_window.CreateNode( m_screenshotList[ 0 ].NodeType, Vector2.zero, null, false );
- m_node.RefreshExternalReferences();
- m_screenShotState = DebugScreenShotNodeState.FocusOnNode;
-
-
- }
- break;
- case DebugScreenShotNodeState.FocusOnNode:
- {
- //m_window.FocusOnNode( m_node, 1, false );
- m_window.FocusOnPoint( m_node.TruePosition.center, 1, false );
- m_screenShotState = DebugScreenShotNodeState.TakeScreenshot;
- }
- break;
- case DebugScreenShotNodeState.TakeScreenshot:
- {
- if( m_screenshotRT != null && Event.current.type == EventType.Repaint )
- {
- m_screenshotTex2D.ReadPixels( new Rect( 0, 0, m_screenshotRT.width, m_screenshotRT.height ), 0, 0 );
- m_screenshotTex2D.Apply();
-
- byte[] bytes = m_screenshotTex2D.EncodeToPNG();
- string pictureFilename = UIUtils.ReplaceInvalidStrings( m_screenshotList[ 0 ].Name );
- pictureFilename = UIUtils.RemoveInvalidCharacters( pictureFilename );
-
- System.IO.File.WriteAllBytes( m_pathname + pictureFilename + ".png", bytes );
- m_screenShotState = DebugScreenShotNodeState.WaitFrame;
- }
- }
- break;
- case DebugScreenShotNodeState.WaitFrame: { Debug.Log( "Wait Frame" ); m_screenShotState = DebugScreenShotNodeState.DeleteNode; } break;
- case DebugScreenShotNodeState.DeleteNode:
- {
- m_window.DestroyNode( m_node );
- m_screenshotList.RemoveAt( 0 );
- m_takingShots = m_screenshotList.Count > 0;
- Debug.Log( "Destroy Node " + m_screenshotList.Count );
-
- if( m_takingShots )
- {
- m_screenShotState = DebugScreenShotNodeState.CreateNode;
- }
- else
- {
- RenderTexture.active = null;
- m_screenshotRT.Release();
- UnityEngine.Object.DestroyImmediate( m_screenshotRT );
- m_screenshotRT = null;
- UnityEngine.Object.DestroyImmediate( m_screenshotTex2D );
- m_screenshotTex2D = null;
- }
- }
- break;
- };
- }
- }
-
- public void Destroy()
- {
- m_window = null;
- if( m_screenshotRT != null )
- {
- m_screenshotRT.Release();
- UnityEngine.Object.DestroyImmediate( m_screenshotRT );
- m_screenshotRT = null;
- }
-
- if( m_screenshotTex2D != null )
- {
- UnityEngine.Object.DestroyImmediate( m_screenshotTex2D );
- m_screenshotTex2D = null;
- }
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/NodeExporterUtils.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/NodeExporterUtils.cs.meta
deleted file mode 100644
index acdf7593..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/NodeExporterUtils.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: f9b3f6c515f0e16469de89d9e22263c5
-timeCreated: 1486374353
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/Preferences.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/Preferences.cs
deleted file mode 100644
index 2688b549..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/Preferences.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using UnityEngine;
-using UnityEditor;
-using System.Collections.Generic;
-
-namespace AmplifyShaderEditor
-{
- public class Preferences
- {
- public enum ShowOption
- {
- Always = 0,
- OnNewVersion = 1,
- Never = 2
- }
-
- private static readonly GUIContent StartUp = new GUIContent( "Show start screen on Unity launch", "You can set if you want to see the start screen everytime Unity launchs, only just when there's a new version available or never." );
- public static readonly string PrefStartUp = "ASELastSession" + Application.productName;
- public static ShowOption GlobalStartUp = ShowOption.Always;
-
- private static readonly GUIContent AutoSRP = new GUIContent( "Auto import SRP shader templates", "By default Amplify Shader Editor checks for your SRP version and automatically imports the correct corresponding shader templates.\nTurn this OFF if you prefer to import them manually." );
- public static readonly string PrefAutoSRP = "ASEAutoSRP" + Application.productName;
- public static bool GlobalAutoSRP = true;
-
- private static readonly GUIContent UseMacros = new GUIContent( "Use Unity's sampling macros in SRP", "Setting this ON will force the code generation to use Unity's macros when sampling textures in SRP.\nThis macros ensures better compatibility between platforms but makes the code less readable." );
- public static readonly string PrefUseMacros = "ASEUseMacros" + Application.productName;
- public static bool GlobalUseMacros = false;
-
- private static readonly GUIContent DefineSymbol = new GUIContent( "Add Amplify Shader Editor define symbol", "Turning it OFF will disable the automatic insertion of the define symbol and remove it from the list while turning it ON will do the opposite.\nThis is used for compatibility with other plugins, if you are not sure if you need this leave it ON." );
- public static readonly string PrefDefineSymbol = "ASEDefineSymbol" + Application.productName;
- public static bool GlobalDefineSymbol = true;
-
- private static bool PrefsLoaded = false;
-
-#if UNITY_2019_1_OR_NEWER
- [SettingsProvider]
- public static SettingsProvider ImpostorsSettings()
- {
- var provider = new SettingsProvider( "Preferences/Amplify Shader Editor", SettingsScope.User )
- {
- guiHandler = ( string searchContext ) =>
- {
- PreferencesGUI();
- },
-
- keywords = new HashSet<string>( new[] { "start", "screen", "import", "shader", "templates", "macros", "macros", "define", "symbol" } ),
-
- };
- return provider;
- }
-#else
- [PreferenceItem( "Amplify Shader Editor" )]
-#endif
- public static void PreferencesGUI()
- {
- if( !PrefsLoaded )
- {
- LoadDefaults();
- PrefsLoaded = true;
- }
-
- var cache = EditorGUIUtility.labelWidth;
- EditorGUIUtility.labelWidth = 250;
- EditorGUI.BeginChangeCheck();
- GlobalStartUp = (ShowOption) EditorGUILayout.EnumPopup( StartUp, GlobalStartUp );
- if( EditorGUI.EndChangeCheck() )
- {
- EditorPrefs.SetInt( PrefStartUp, (int)GlobalStartUp );
- }
-
- EditorGUI.BeginChangeCheck();
- GlobalAutoSRP = EditorGUILayout.Toggle( AutoSRP, GlobalAutoSRP );
- if( EditorGUI.EndChangeCheck() )
- {
- EditorPrefs.SetBool( PrefAutoSRP, GlobalAutoSRP );
- }
-
- EditorGUI.BeginChangeCheck();
- GlobalUseMacros = EditorGUILayout.Toggle( UseMacros, GlobalUseMacros );
- if( EditorGUI.EndChangeCheck() )
- {
- EditorPrefs.SetBool( PrefUseMacros, GlobalUseMacros );
- if( UIUtils.CurrentWindow != null )
- {
- UIUtils.CurrentWindow.CurrentGraph.SamplingThroughMacros = GlobalUseMacros;
- }
- }
-
- EditorGUI.BeginChangeCheck();
- GlobalDefineSymbol = EditorGUILayout.Toggle( DefineSymbol, GlobalDefineSymbol );
- if( EditorGUI.EndChangeCheck() )
- {
- EditorPrefs.SetBool( PrefDefineSymbol, GlobalDefineSymbol );
- if( GlobalDefineSymbol )
- IOUtils.SetAmplifyDefineSymbolOnBuildTargetGroup( EditorUserBuildSettings.selectedBuildTargetGroup );
- else
- IOUtils.RemoveAmplifyDefineSymbolOnBuildTargetGroup( EditorUserBuildSettings.selectedBuildTargetGroup );
- }
-
- EditorGUILayout.BeginHorizontal();
- GUILayout.FlexibleSpace();
- if( GUILayout.Button( "Reset and Forget All" ) )
- {
- EditorPrefs.DeleteKey( PrefStartUp );
- GlobalStartUp = ShowOption.Always;
-
- EditorPrefs.DeleteKey( PrefAutoSRP );
- GlobalAutoSRP = true;
-
- EditorPrefs.DeleteKey( PrefUseMacros );
- GlobalUseMacros = false;
- if( UIUtils.CurrentWindow != null )
- {
- UIUtils.CurrentWindow.CurrentGraph.SamplingThroughMacros = false;
- }
-
- EditorPrefs.DeleteKey( PrefDefineSymbol );
- GlobalDefineSymbol = true;
- IOUtils.SetAmplifyDefineSymbolOnBuildTargetGroup( EditorUserBuildSettings.selectedBuildTargetGroup );
- }
- EditorGUILayout.EndHorizontal();
- EditorGUIUtility.labelWidth = cache;
- }
-
- public static void LoadDefaults()
- {
- GlobalStartUp = (ShowOption) EditorPrefs.GetInt( PrefStartUp, 0 );
- GlobalAutoSRP = EditorPrefs.GetBool( PrefAutoSRP, true );
- GlobalUseMacros = EditorPrefs.GetBool( PrefUseMacros, false );
- GlobalDefineSymbol = EditorPrefs.GetBool( PrefDefineSymbol, true );
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/Preferences.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/Preferences.cs.meta
deleted file mode 100644
index 33cf46b5..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/Preferences.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: d036571a581792b44951e3723aef2c01
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/RectExtension.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/RectExtension.cs
deleted file mode 100644
index f803ac20..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/RectExtension.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using UnityEngine;
-
-namespace AmplifyShaderEditor
-{
- public static class RectExtension
- {
- private static Rect ValidateBoundaries( this Rect thisRect )
- {
- if ( thisRect.yMin > thisRect.yMax )
- {
- float yMin = thisRect.yMin;
- thisRect.yMin = thisRect.yMax;
- thisRect.yMax = yMin;
- }
-
- if ( thisRect.xMin > thisRect.xMax )
- {
- float xMin = thisRect.xMin;
- thisRect.xMin = thisRect.xMax;
- thisRect.xMax = xMin;
- }
- return thisRect;
- }
-
- public static bool Includes( this Rect thisRect , Rect other )
- {
- thisRect = thisRect.ValidateBoundaries();
- other = other.ValidateBoundaries();
-
- if ( other.xMin >= thisRect.xMin && other.xMax <= thisRect.xMax )
- {
- if ( other.yMin >= thisRect.yMin && other.yMax <= thisRect.yMax )
- {
- return true;
- }
- }
- return false;
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/RectExtension.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/RectExtension.cs.meta
deleted file mode 100644
index 82258692..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/RectExtension.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: e5a7e5c0308e038448cd1a235bf840ca
-timeCreated: 1501521591
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/SamplerStateAutoGenerator.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/SamplerStateAutoGenerator.cs
deleted file mode 100644
index 8be253c4..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/SamplerStateAutoGenerator.cs
+++ /dev/null
@@ -1,203 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using System;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEditor;
-
-namespace AmplifyShaderEditor
-{
- public enum InlineSamplerFilteringMode
- {
- Point,
- Linear,
- Trilinear
- };
-
- public enum InlineSamplerWrapMode
- {
- Clamp,
- Repeat,
- Mirror,
- MirrorOnce
- };
-
- public enum InlineSamplerWrapCoordinates
- {
- All,
- U,
- V,
- W
- };
-
- [Serializable]
- public class InlineSamplerWrapOptions
- {
- public InlineSamplerWrapMode WrapMode = InlineSamplerWrapMode.Clamp;
- public InlineSamplerWrapCoordinates Coordinates = InlineSamplerWrapCoordinates.All;
- public string InlineValue
- {
- get
- {
- string name = "_"+WrapMode.ToString();
- if( Coordinates != InlineSamplerWrapCoordinates.All )
- name += Coordinates.ToString();
- name += "_";
- return name;
- }
- }
- }
-
- [Serializable]
- public class SamplerStateAutoGenerator
- {
- private const int MaxCount = 3;
- private const float ButtonLayoutWidth = 15;
- private const string AdditionalWrapsStr = "Additional Wraps";
- private const string InlineSamplerStateStr = "Inline Sampler State";
-
- [SerializeField]
- private InlineSamplerFilteringMode m_filterMode = InlineSamplerFilteringMode.Point;
-
- [SerializeField]
- private InlineSamplerWrapOptions m_mainWrapMode = new InlineSamplerWrapOptions();
-
- [SerializeField]
- private List<InlineSamplerWrapOptions> m_additionalWrapOptions = new List<InlineSamplerWrapOptions>();
-
- [SerializeField]
- private bool m_visibleWrapsFoldout = false;
-
- [SerializeField]
- private bool m_visibleMainFoldout = false;
-
- [NonSerialized]
- private UndoParentNode m_owner;
-
- public void Destroy()
- {
- m_mainWrapMode = null;
- m_additionalWrapOptions.Clear();
- m_additionalWrapOptions = null;
- }
-
- public string AddToDataCollector( ref MasterNodeDataCollector dataCollector )
- {
- string inlineSampler = "sampler_";
-
- inlineSampler += m_filterMode.ToString();
- inlineSampler += m_mainWrapMode.InlineValue;
-
- int count = m_additionalWrapOptions.Count;
- for( int i = 0; i < count; i++ )
- {
- inlineSampler += m_additionalWrapOptions[ i ].InlineValue;
- }
- return inlineSampler;
- }
-
- void DrawAddRemoveButtons()
- {
- int count = m_additionalWrapOptions.Count;
- if( count < MaxCount && m_owner.GUILayoutButton( string.Empty, UIUtils.PlusStyle, GUILayout.Width( ButtonLayoutWidth ) ) )
- {
- m_additionalWrapOptions.Add( new InlineSamplerWrapOptions() );
- EditorGUI.FocusTextInControl( null );
- }
-
- if( count > 0 && m_owner.GUILayoutButton( string.Empty, UIUtils.MinusStyle, GUILayout.Width( ButtonLayoutWidth ) ) )
- {
- m_additionalWrapOptions.RemoveAt( count - 1 );
- EditorGUI.FocusTextInControl( null );
- }
- }
-
- public void Draw( UndoParentNode owner )
- {
- m_owner = owner;
- NodeUtils.DrawNestedPropertyGroup( ref m_visibleMainFoldout, InlineSamplerStateStr, DrawMain );
- }
-
- void DrawMain()
- {
- m_filterMode = (InlineSamplerFilteringMode)m_owner.EditorGUILayoutEnumPopup( m_filterMode );
-
- EditorGUILayout.BeginHorizontal();
- m_mainWrapMode.WrapMode = (InlineSamplerWrapMode)m_owner.EditorGUILayoutEnumPopup( m_mainWrapMode.WrapMode );
- m_mainWrapMode.Coordinates = (InlineSamplerWrapCoordinates)m_owner.EditorGUILayoutEnumPopup( m_mainWrapMode.Coordinates );
- EditorGUILayout.EndHorizontal();
- NodeUtils.DrawNestedPropertyGroup( ref m_visibleWrapsFoldout, AdditionalWrapsStr, DrawAdditionalWrapModes, DrawAddRemoveButtons );
- }
-
- void DrawAdditionalWrapModes()
- {
- EditorGUILayout.Space();
- int count = m_additionalWrapOptions.Count;
- for( int i = 0; i < count; i++ )
- {
- float maxWidth = 90;
- EditorGUILayout.BeginHorizontal();
- m_additionalWrapOptions[ i ].WrapMode = (InlineSamplerWrapMode)m_owner.EditorGUILayoutEnumPopup( m_additionalWrapOptions[ i ].WrapMode ,GUILayout.MaxWidth( maxWidth ) );
- m_additionalWrapOptions[ i ].Coordinates = (InlineSamplerWrapCoordinates)m_owner.EditorGUILayoutEnumPopup( m_additionalWrapOptions[ i ].Coordinates, GUILayout.MaxWidth( maxWidth ) );
- EditorGUILayout.EndHorizontal();
- }
- }
-
- public void ReadFromString( ref uint index, ref string[] nodeParams )
- {
-#if UNITY_2019_3_OR_NEWER
- Enum.TryParse<InlineSamplerFilteringMode>( nodeParams[ index++ ], out m_filterMode );
- Enum.TryParse<InlineSamplerWrapCoordinates>( nodeParams[ index++ ], out m_mainWrapMode.Coordinates );
-
- int count = 0;
- int.TryParse( nodeParams[ index++ ], out count );
- for( int i = 0; i < count; i++ )
- {
- InlineSamplerWrapOptions option = new InlineSamplerWrapOptions();
-
- Enum.TryParse<InlineSamplerWrapMode>( nodeParams[ index++ ], out option.WrapMode );
- Enum.TryParse<InlineSamplerWrapCoordinates>( nodeParams[ index++ ], out option.Coordinates );
-
- m_additionalWrapOptions.Add( option );
- }
-#else
- m_filterMode =(InlineSamplerFilteringMode) Enum.Parse( typeof( InlineSamplerFilteringMode ), nodeParams[ index++ ] );
- m_mainWrapMode.Coordinates = (InlineSamplerWrapCoordinates)Enum.Parse( typeof( InlineSamplerWrapCoordinates ),nodeParams[ index++ ] );
-
- int count = 0;
- int.TryParse( nodeParams[ index++ ], out count );
- for( int i = 0; i < count; i++ )
- {
- InlineSamplerWrapOptions option = new InlineSamplerWrapOptions();
-
- option.WrapMode = ( InlineSamplerWrapMode)Enum.Parse(typeof( InlineSamplerWrapMode ), nodeParams[ index++ ] );
- option.Coordinates = ( InlineSamplerWrapCoordinates)Enum.Parse(typeof( InlineSamplerWrapCoordinates ), nodeParams[ index++ ] );
-
- m_additionalWrapOptions.Add( option );
- }
-#endif
-
- }
-
- public void WriteToString( ref string nodeInfo )
- {
- IOUtils.AddFieldValueToString( ref nodeInfo, m_filterMode );
-
- IOUtils.AddFieldValueToString( ref nodeInfo, m_mainWrapMode.WrapMode );
- IOUtils.AddFieldValueToString( ref nodeInfo, m_mainWrapMode.Coordinates );
-
- int count = m_additionalWrapOptions.Count;
- IOUtils.AddFieldValueToString( ref nodeInfo, count );
- if( count > 0 )
- {
- for( int i = 0; i < count; i++ )
- {
- IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalWrapOptions[i].WrapMode );
- IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalWrapOptions[i].Coordinates );
- }
- }
-
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/SamplerStateAutoGenerator.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/SamplerStateAutoGenerator.cs.meta
deleted file mode 100644
index 896ea53e..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/SamplerStateAutoGenerator.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: fe831fe9de481bc4b9df1c1142bb9aa5
-timeCreated: 1580322794
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ShortcutsManager.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ShortcutsManager.cs
deleted file mode 100644
index 3e48aa82..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ShortcutsManager.cs
+++ /dev/null
@@ -1,215 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using UnityEngine;
-using System.Collections.Generic;
-
-namespace AmplifyShaderEditor
-{
- public class ShortcutItem
- {
- public delegate void ShortcutFunction();
- public ShortcutFunction MyKeyDownFunctionPtr;
- public ShortcutFunction MyKeyUpFunctionPtr;
- public string Name;
- public string Description;
-
- public ShortcutItem( string name, string description )
- {
- Name = name;
- Description = description;
- }
-
- public ShortcutItem( string name, string description, ShortcutFunction myKeyDownFunctionPtr, ShortcutFunction myKeyUpFunctionPtr = null )
- {
- Name = name;
- Description = description;
- MyKeyDownFunctionPtr = myKeyDownFunctionPtr;
- MyKeyUpFunctionPtr = myKeyUpFunctionPtr;
- }
-
- public void Destroy()
- {
- MyKeyDownFunctionPtr = null;
- MyKeyUpFunctionPtr = null;
- }
- }
-
- public class ShortcutsManager
- {
- public static readonly KeyCode ScrollUpKey = KeyCode.PageUp;
- public static readonly KeyCode ScrollDownKey = KeyCode.PageDown;
-
-
- private const string ItemWikiFormat = "*<b>[{0}]:</b> {1}\n";
- private Dictionary<KeyCode, Dictionary<EventModifiers, ShortcutItem>> m_editorShortcutsDict = new Dictionary<KeyCode, Dictionary<EventModifiers, ShortcutItem>>();
- private Dictionary<KeyCode, ShortcutItem> m_editorNoModifiersShortcutsDict = new Dictionary<KeyCode, ShortcutItem>();
- private List<ShortcutItem> m_editorShortcutsList = new List<ShortcutItem>();
-
- private Dictionary<KeyCode, ShortcutItem> m_nodesShortcutsDict = new Dictionary<KeyCode, ShortcutItem>();
- private List<ShortcutItem> m_nodesShortcutsList = new List<ShortcutItem>();
-
- public void DumpShortcutsToDisk( string pathname )
- {
- if ( !System.IO.Directory.Exists( pathname ) )
- {
- System.IO.Directory.CreateDirectory( pathname );
- }
-
- string list = "=== Full Shortcut List ===\n";
- list += "==== Editor ====\n";
- for ( int i = 0; i < m_editorShortcutsList.Count; i++ )
- {
- list += string.Format( ItemWikiFormat, m_editorShortcutsList[ i ].Name, m_editorShortcutsList[ i ].Description );
- }
- list += "\n";
- list += "==== Nodes ====\n";
- for ( int i = 0; i < m_nodesShortcutsList.Count; i++ )
- {
- list += string.Format( ItemWikiFormat, m_nodesShortcutsList[ i ].Name, m_nodesShortcutsList[ i ].Description );
- }
-
- string shortcutsPathnames = pathname + "KeyboardShortcuts.txt";
- Debug.Log( " Creating shortcuts file at " + shortcutsPathnames );
- IOUtils.SaveTextfileToDisk( list, shortcutsPathnames, false );
- }
-
- public void RegisterNodesShortcuts( KeyCode key, string nodeName )
- {
- if ( m_nodesShortcutsDict.ContainsKey( key ) )
- {
- if ( DebugConsoleWindow.DeveloperMode )
- {
- Debug.Log( "Attempting to register an already used node shortcut key " + key );
- }
- return;
- }
- m_nodesShortcutsDict.Add( key, new ShortcutItem( key.ToString(), nodeName ) );
- m_nodesShortcutsList.Add( m_nodesShortcutsDict[ key ] );
- }
-
- public void RegisterEditorShortcut( bool showOnList, EventModifiers modifiers, KeyCode key, string description, ShortcutItem.ShortcutFunction myKeyDownFunctionPtr, ShortcutItem.ShortcutFunction myKeyUpFunctionPtr = null )
- {
- if ( m_editorShortcutsDict.ContainsKey( key ) )
- {
- if ( m_editorShortcutsDict[ key ].ContainsKey( modifiers ) )
- {
- if ( DebugConsoleWindow.DeveloperMode )
- {
- Debug.Log( "Attempting to register an already used editor shortcut key " + key );
- }
- return;
- }
- }
- else
- {
- m_editorShortcutsDict.Add( key, new Dictionary<EventModifiers, ShortcutItem>() );
- }
- ShortcutItem item = new ShortcutItem( ( ( modifiers == EventModifiers.None || modifiers == EventModifiers.FunctionKey ) ? key.ToString() : modifiers + " + " + key ), description, myKeyDownFunctionPtr, myKeyUpFunctionPtr );
- m_editorShortcutsDict[ key ].Add( modifiers, item );
- if ( showOnList )
- m_editorShortcutsList.Add( item );
- }
-
- public void RegisterEditorShortcut( bool showOnList, KeyCode key, string description, ShortcutItem.ShortcutFunction myKeyDownFunctionPtr, ShortcutItem.ShortcutFunction myKeyUpFunctionPtr = null )
- {
- if ( m_editorNoModifiersShortcutsDict.ContainsKey( key ) )
- {
- if ( DebugConsoleWindow.DeveloperMode )
- {
- Debug.Log( "Attempting to register an already used editor shortcut key " + key );
- }
- return;
- }
-
- ShortcutItem item = new ShortcutItem( key.ToString(), description, myKeyDownFunctionPtr, myKeyUpFunctionPtr );
- m_editorNoModifiersShortcutsDict.Add( key, item );
- if ( showOnList )
- m_editorShortcutsList.Add( item );
- }
-
- public bool ActivateShortcut( EventModifiers modifiers, KeyCode key, bool isKeyDown )
- {
- if ( m_editorShortcutsDict.ContainsKey( key ) )
- {
- if ( isKeyDown )
- {
- if ( m_editorShortcutsDict[ key ].ContainsKey( modifiers ) )
- {
- if ( m_editorShortcutsDict[ key ][ modifiers ].MyKeyDownFunctionPtr != null )
- {
- m_editorShortcutsDict[ key ][ modifiers ].MyKeyDownFunctionPtr();
- return true;
- }
- }
- }
- else
- {
- if ( m_editorShortcutsDict[ key ].ContainsKey( modifiers ) )
- {
- if ( m_editorShortcutsDict[ key ][ modifiers ].MyKeyUpFunctionPtr != null )
- {
- m_editorShortcutsDict[ key ][ modifiers ].MyKeyUpFunctionPtr();
- return true;
- }
- }
- }
- }
-
- if ( modifiers == EventModifiers.None && m_editorNoModifiersShortcutsDict.ContainsKey( key ) )
- {
- if ( isKeyDown )
- {
- if ( m_editorNoModifiersShortcutsDict[ key ].MyKeyDownFunctionPtr != null )
- {
- m_editorNoModifiersShortcutsDict[ key ].MyKeyDownFunctionPtr();
- return true;
- }
- }
- else
- {
- if ( m_editorNoModifiersShortcutsDict[ key ].MyKeyUpFunctionPtr != null )
- {
- m_editorNoModifiersShortcutsDict[ key ].MyKeyUpFunctionPtr();
- return true;
- }
- }
- }
-
- return false;
- }
-
- public void Destroy()
- {
- foreach ( KeyValuePair<KeyCode, ShortcutItem> kvp in m_editorNoModifiersShortcutsDict )
- {
- kvp.Value.Destroy();
- }
- m_editorNoModifiersShortcutsDict.Clear();
- m_editorNoModifiersShortcutsDict = null;
-
- foreach ( KeyValuePair<KeyCode, Dictionary<EventModifiers, ShortcutItem>> kvpKey in m_editorShortcutsDict )
- {
- foreach ( KeyValuePair<EventModifiers, ShortcutItem> kvpMod in kvpKey.Value )
- {
- kvpMod.Value.Destroy();
- }
- kvpKey.Value.Clear();
- }
- m_editorShortcutsDict.Clear();
- m_editorShortcutsDict = null;
-
- m_editorShortcutsList.Clear();
- m_editorShortcutsList = null;
-
- m_nodesShortcutsDict.Clear();
- m_nodesShortcutsDict = null;
-
- m_nodesShortcutsList.Clear();
- m_nodesShortcutsList = null;
- }
-
- public List<ShortcutItem> AvailableEditorShortcutsList { get { return m_editorShortcutsList; } }
- public List<ShortcutItem> AvailableNodesShortcutsList { get { return m_nodesShortcutsList; } }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ShortcutsManager.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ShortcutsManager.cs.meta
deleted file mode 100644
index d08579e5..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/ShortcutsManager.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 15917e71489c3ca4dbc5fdef9bb37433
-timeCreated: 1487952057
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/TipsWindow.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/TipsWindow.cs
deleted file mode 100644
index 1d888355..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/TipsWindow.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using System.IO;
-using System.Reflection;
-using System;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEditor;
-
-namespace AmplifyShaderEditor
-{
- [Serializable]
- public class TipsWindow : MenuParent
- {
- private static bool m_showWindow = false;
- private bool m_dontShowAtStart = false;
-
- private static List<string> AllTips = new List<string>() {
- "You can press W to toggle between a flat and color coded Wires and ports.",
- "You can press CTRL+W to toggle between multiline or singleline Wire connections.",
- "You can press P to globally open all node Previews.",
- "You can press F to Focus your selection, single tap centers the selection while double tap it to also zooms on in.",
- "You can press CTRL+F to open a search bar and Find a node by it's title",
- "You can press SPACE to open a context menu to add a new node and press TAB or SHIFT+TAB tocycle between the found nodes",
- "You can remove a node without breaking the graph connections by pressing ALT and then dragging the node out",
- "You can switch two input connections holding CTRL while dragging one input connection into the other",
- };
-
- int m_currentTip = 0;
-
- public TipsWindow( AmplifyShaderEditorWindow parentWindow ) : base( parentWindow, 0, 0, 0, 64, "Tips", MenuAnchor.TOP_LEFT, MenuAutoSize.NONE )
- {
- //m_dontShowAtStart = EditorPrefs.GetBool( "DontShowTipAtStart", false );
- }
-
- public override void Draw( Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus )
- {
- base.Draw( parentPosition, mousePosition, mouseButtonId, hasKeyboadFocus );
-
- DrawWindow( mousePosition );
- }
-
- public void DrawWindow( Vector2 mousePosition )
- {
- if( !m_showWindow )
- return;
-
- Rect windowRect = new Rect( 0, 0, Screen.width, Screen.height );
- Vector2 center = windowRect.center;
- windowRect.size = new Vector2( 300, 200 );
- windowRect.center = center;
- Color temp = GUI.color;
- GUI.color = Color.white;
- GUI.Label( windowRect, string.Empty, GUI.skin.FindStyle( "flow node 0" ) );
-
- if( Event.current.type == EventType.MouseDown && !windowRect.Contains( mousePosition ) )
- m_showWindow = false;
-
- Rect titleRect = windowRect;
- titleRect.height = 35;
- GUI.Label( titleRect, "Quick Tip!", GUI.skin.FindStyle( "TL Selection H2" ) );
- Rect button = titleRect;
- button.size = new Vector2( 14, 14 );
- button.y += 2;
- button.x = titleRect.xMax - 16;
- if( GUI.Button( button, string.Empty, GUI.skin.FindStyle( "WinBtnClose" ) ) )
- CloseWindow();
-
- button.y += 100;
- if( GUI.Button( button, ">" ) )
- {
- m_currentTip++;
- if( m_currentTip >= AllTips.Count )
- m_currentTip = 0;
- }
-
- Rect textRect = windowRect;
- textRect.yMin = titleRect.yMax;
- GUI.Label( textRect, AllTips[ m_currentTip ], GUI.skin.FindStyle( "WordWrappedLabel" ) );
-
- Rect footerRect = windowRect;
- footerRect.yMin = footerRect.yMax - 18;
- footerRect.x += 3;
- GUI.Label( footerRect, (m_currentTip + 1) + " of " + AllTips.Count + " tips" );
- footerRect.x += 170;
- EditorGUI.BeginChangeCheck();
- m_dontShowAtStart = GUI.Toggle( footerRect, m_dontShowAtStart, "Don't show at start" );
- if( EditorGUI.EndChangeCheck() )
- {
- EditorPrefs.SetBool( "DontShowTipAtStart", m_dontShowAtStart );
- }
- GUI.color = temp;
-
- if( Event.current.type == EventType.MouseDown && windowRect.Contains( mousePosition ) )
- {
- Event.current.Use();
- ParentWindow.MouseInteracted = true;
- }
- }
-
- public override void Destroy()
- {
- base.Destroy();
- }
-
- public static void ShowWindow( bool toggle = true )
- {
- if( toggle )
- m_showWindow = !m_showWindow;
- else
- m_showWindow = true;
-
- //Test();
- //ExportCompiledShaders();
- }
-
- //public static void Test()
- //{
- // Shader shader = UIUtils.CurrentWindow.CurrentGraph.CurrentShader;
- // int mode = EditorPrefs.GetInt( "ShaderInspectorPlatformMode", 1 );
- // int mask = EditorPrefs.GetInt( "ShaderInspectorPlatformMask", 524287 );
- // bool strip = EditorPrefs.GetInt( "ShaderInspectorVariantStripping", 1 ) == 0;
- // ShaderUtilEx.OpenCompiledShader( shader, mode, mask, strip );
- //}
-
- //public static void ExportCompiledShaders()
- //{
- // Shader shader = UIUtils.CurrentWindow.CurrentGraph.CurrentShader;
- // string shaderPath = AssetDatabase.GetAssetPath( shader );
- // SerializedObject so = new SerializedObject( shader );
- // SerializedProperty prop = so.FindProperty( "m_Script" );
- // var compiledShaderString = prop.stringValue;
- // Directory.CreateDirectory( Application.dataPath + "/../ShaderSource/" );
- // if( compiledShaderString == null )
- // return;
- // var outputPath = Application.dataPath + "/../ShaderSource/" + Path.GetFileNameWithoutExtension( shaderPath ) + "_compiled.shader";
- // var sw = File.CreateText( outputPath );
- // sw.Write( compiledShaderString );
- // sw.Close();
- //}
-
- public static void CloseWindow()
- {
- m_showWindow = false;
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/TipsWindow.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/TipsWindow.cs.meta
deleted file mode 100644
index 3d598296..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/TipsWindow.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 565dc3c9725b0db49b7d5ea17d151682
-timeCreated: 1504704078
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UIUtils.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UIUtils.cs
deleted file mode 100644
index a525fd7c..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UIUtils.cs
+++ /dev/null
@@ -1,2839 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-using UnityEngine;
-using UnityEditor;
-using System.Collections.Generic;
-using System.IO;
-
-using System.Globalization;
-using System.Text.RegularExpressions;
-
-namespace AmplifyShaderEditor
-{
- public enum ASEColorSpace
- {
- Auto,
- Gamma,
- Linear
- }
-
- public enum SurfaceInputs
- {
- DEPTH = 0,
- UV_COORDS,
- UV2_COORDS,
- VIEW_DIR,
- COLOR,
- SCREEN_POS,
- WORLD_POS,
- WORLD_REFL,
- WORLD_NORMAL,
- VFACE,
- INTERNALDATA
- }
-
- public enum CustomStyle
- {
- NodeWindowOff = 0,
- NodeWindowOn,
- NodeTitle,
- NodeHeader,
- CommentaryHeader,
- ShaderLibraryTitle,
- ShaderLibraryAddToList,
- ShaderLibraryRemoveFromList,
- ShaderLibraryOpenListed,
- ShaderLibrarySelectionAsTemplate,
- ShaderLibraryItem,
- CommentaryTitle,
- PortEmptyIcon,
- PortFullIcon,
- InputPortlabel,
- OutputPortLabel,
- CommentaryResizeButton,
- CommentaryResizeButtonInv,
- CommentaryBackground,
- MinimizeButton,
- MaximizeButton,
- NodePropertiesTitle,
- ShaderModeTitle,
- MaterialModeTitle,
- ShaderNoMaterialModeTitle,
- PropertyValuesTitle,
- ShaderModeNoShader,
- MainCanvasTitle,
- ShaderBorder,
- MaterialBorder,
- SamplerTextureRef,
- SamplerTextureIcon,
- CustomExpressionAddItem,
- CustomExpressionRemoveItem,
- CustomExpressionSmallAddItem,
- CustomExpressionSmallRemoveItem,
- ResetToDefaultInspectorButton,
- SliderStyle,
- ObjectPicker,
- NodePropertyPicker,
- NodePreviewExpander,
- NodePreviewCollapser,
- SamplerButton,
- SamplerFrame,
- CommentarySuperTitle,
- MiniButtonTopLeft,
- MiniButtonTopMid,
- MiniButtonTopRight,
- ShaderFunctionBorder,
- ShaderFunctionMode,
- RightShaderMode,
- FlatBackground,
- DocumentationLink,
- GraphButtonIcon,
- GraphButton,
- NodeWindowOffSquare,
- NodeHeaderSquare,
- NodeWindowOnSquare,
- ConsoleLogMessage,
- ConsoleLogCircle
- }
-
- public enum MasterNodePortCategory
- {
- Vertex = 1 << 0,
- Fragment = 1 << 1,
- Tessellation = 1 << 2,
- Debug = 1 << 3
- }
-
- public enum PortGenType
- {
- NonCustomLighting,
- //Normal = 1 << 1,
- //Emission = 1 << 2,
- //Metallic = 1 << 3,
- //Specular = 1 << 4,
- CustomLighting
- }
-
- public struct NodeData
- {
- public MasterNodePortCategory Category;
- public int OrderIndex;
- public int GraphDepth;
- public NodeData( MasterNodePortCategory category )
- {
- Category = category;
- OrderIndex = 0;
- GraphDepth = -1;
- }
- }
-
- public struct NodeCastInfo
- {
- public int NodeId;
- public int PortId;
- public NodeCastInfo( int nodeId, int portId )
- {
- NodeId = nodeId;
- PortId = portId;
- }
- public override string ToString()
- {
- return NodeId.ToString() + PortId.ToString();
- }
- };
-
- public struct ButtonClickId
- {
- public const int LeftMouseButton = 0;
- public const int RightMouseButton = 1;
- public const int MiddleMouseButton = 2;
- }
-
- public enum ASESelectionMode
- {
- Shader = 0,
- Material,
- ShaderFunction
- }
-
- public enum DrawOrder
- {
- Background,
- Default
- }
-
- public enum NodeConnectionStatus
- {
- Not_Connected = 0,
- Connected,
- Error,
- Island
- }
-
- public enum InteractionMode
- {
- Target,
- Other,
- Both
- }
-
- public enum FunctionNodeCategories
- {
- Custom,
- CameraAndScreen,
- ConstantsAndProperties,
- Functions,
- ImageEffects,
- Light,
- LogicalOperators,
- MathOperators,
- MatrixOperators,
- Miscellaneous,
- ObjectTransform,
- SurfaceData,
- Textures,
- Time,
- TrigonometryOperators,
- UVCoordinates,
- VectorOperators,
- VertexData
- }
-
- public enum TransformSpaceFrom
- {
- Object = 0,
- World,
- View,
- Tangent
- }
-
- public enum TransformSpaceTo
- {
- Object = 0,
- World,
- View,
- Tangent,
- Clip
- }
-
- public class UIUtils
- {
- public static string NewTemplateGUID;
- public static int SerializeHelperCounter = 0;
- public static bool IgnoreDeselectAll = false;
-
- public static bool DirtyMask = true;
- public static bool Initialized = false;
- public static float HeaderMaxHeight;
- public static float CurrentHeaderHeight;
- public static GUISkin MainSkin = null;
- public static GUIStyle PlusStyle;
- public static GUIStyle MinusStyle;
- public static GUIStyle RangedFloatSliderStyle;
- public static GUIStyle RangedFloatSliderThumbStyle;
- public static GUIStyle SwitchNodePopUp;
- public static GUIStyle PropertyPopUp;
- public static GUIStyle ObjectField;
- public static GUIStyle PreviewExpander;
- public static GUIStyle PreviewCollapser;
- public static GUIStyle ObjectFieldThumb;
- public static GUIStyle ObjectFieldThumbOverlay;
- public static GUIStyle InspectorPopdropdownStyle;
- public static GUIStyle InspectorPopdropdownFallback;
- public static GUIStyle BoldErrorStyle;
- public static GUIStyle BoldWarningStyle;
- public static GUIStyle BoldInfoStyle;
- public static GUIStyle Separator;
- public static GUIStyle ToolbarMainTitle;
- public static GUIStyle ToolbarSearchTextfield;
- public static GUIStyle ToolbarSearchCancelButton;
- public static GUIStyle MiniButtonTopLeft;
- public static GUIStyle MiniButtonTopMid;
- public static GUIStyle MiniButtonTopRight;
-
- public static GUIStyle CommentaryTitle;
- public static GUIStyle InputPortLabel;
- public static GUIStyle OutputPortLabel;
-
- public static GUIStyle MiniObjectFieldThumbOverlay;
- public static GUIStyle MiniSamplerButton;
-
- public static GUIStyle NodeWindowOffSquare;
- public static GUIStyle NodeHeaderSquare;
- public static GUIStyle NodeWindowOnSquare;
- public static GUIStyle InternalDataOnPort;
- public static GUIStyle InternalDataBackground;
-
- public static GUIStyle GraphButtonIcon;
- public static GUIStyle GraphButton;
- public static GUIStyle GraphDropDown;
-
- public static GUIStyle EmptyStyle = new GUIStyle();
-
- public static GUIStyle ConsoleLogLabel;
- public static GUIStyle ConsoleLogMessage;
- public static GUIStyle ConsoleLogCircle;
-
- public static GUIStyle TooltipBox;
- public static GUIStyle Box;
- public static GUIStyle Button;
- public static GUIStyle TextArea;
- public static GUIStyle Label;
- public static GUIStyle Toggle;
- public static GUIStyle Textfield;
-
- public static GUIStyle UnZoomedNodeTitleStyle;
- public static GUIStyle UnZoomedPropertyValuesTitleStyle;
- public static GUIStyle UnZoomedInputPortStyle;
- public static GUIStyle UnZoomedOutputPortPortStyle;
-
- // Node Property Menu items
- public static GUIStyle MenuItemToggleStyle;
- public static GUIStyle MenuItemEnableStyle;
- public static GUIStyle MenuItemBackgroundStyle;
- public static GUIStyle MenuItemToolbarStyle;
- public static GUIStyle MenuItemInspectorDropdownStyle;
-
- public static GUIStyle FloatIntPickerONOFF;
-
- public static bool UsingProSkin = false;
-
- public static Texture ShaderIcon { get { return EditorGUIUtility.IconContent( "Shader Icon" ).image; } }
- public static Texture MaterialIcon { get { return EditorGUIUtility.IconContent( "Material Icon" ).image; } }
-
- //50be8291f9514914aa55c66c49da67cf
- public static Texture ShaderFunctionIcon { get { return AssetDatabase.LoadAssetAtPath<Texture>( AssetDatabase.GUIDToAssetPath( "50be8291f9514914aa55c66c49da67cf" ) ); } }
-
- public static Texture2D WireNodeSelection = null;
- public static Texture2D SliderButton = null;
-
- public static Texture2D SmallErrorIcon = null;
- public static Texture2D SmallWarningIcon = null;
- public static Texture2D SmallInfoIcon = null;
-
- public static Texture2D CheckmarkIcon = null;
- public static Texture2D PopupIcon = null;
-
- public static Texture2D MasterNodeOnTexture = null;
- public static Texture2D MasterNodeOffTexture = null;
-
- public static Texture2D GPUInstancedOnTexture = null;
- public static Texture2D GPUInstancedOffTexture = null;
-
- public static GUIContent LockIconOpen = null;
- public static GUIContent LockIconClosed = null;
-
- public static GUIContent FloatIntIconON = null;
- public static GUIContent FloatIntIconOFF = null;
-
- public static bool ShowContextOnPick = true;
-
- private static AmplifyShaderEditorWindow m_currentWindow = null;
- public static AmplifyShaderEditorWindow CurrentWindow
- {
- get
- {
- if( m_currentWindow == null )
- {
- for( int i = 0; i < IOUtils.AllOpenedWindows.Count; i++ )
- {
- if( IOUtils.AllOpenedWindows[ i ] != null )
- {
- m_currentWindow = IOUtils.AllOpenedWindows[ i ];
- }
- else
- {
- //Debug.Log("No Window Found!");
- }
- }
- }
- return m_currentWindow;
- }
- set { m_currentWindow = value; }
- }
-
- public static Vector2 PortsSize;
- public static Vector3 PortsDelta;
- public static Vector3 ScaledPortsDelta;
-
- public static RectOffset RectOffsetZero;
- public static RectOffset RectOffsetOne;
- public static RectOffset RectOffsetTwo;
- public static RectOffset RectOffsetThree;
- public static RectOffset RectOffsetFour;
- public static RectOffset RectOffsetFive;
- public static RectOffset RectOffsetSix;
-
- public static Material LinearMaterial = null;
- public static Shader IntShader = null;
- public static Shader FloatShader = null;
- public static Shader Vector2Shader = null;
- public static Shader Vector3Shader = null;
- public static Shader Vector4Shader = null;
- public static Shader ColorShader = null;
- public static Shader Texture2DShader = null;
- public static Shader MaskingShader = null;
-
- public static bool InhibitMessages = false;
-
-
- private static int m_shaderIndentLevel = 0;
- private static string m_shaderIndentTabs = string.Empty;
-
- //Label Vars
-
- private static TextAnchor m_alignment;
- private static TextClipping m_clipping;
- private static bool m_wordWrap;
- private static int m_fontSize;
- private static Color m_fontColor;
- private static FontStyle m_fontStyle;
-
-
- private static string NumericNamePattern = @"^\d";
- private static System.Globalization.TextInfo m_textInfo;
- private static string m_latestOpenedFolder = string.Empty;
- private static Dictionary<int, UndoParentNode> m_undoHelper = new Dictionary<int, UndoParentNode>();
-
- private static Dictionary<string, int> AvailableKeywordsDict = new Dictionary<string, int>();
- public static readonly string[] AvailableKeywords =
- {
- "Custom",
- "ETC1_EXTERNAL_ALPHA",
- "PIXELSNAP_ON",
- "UNITY_PASS_FORWARDBASE",
- "UNITY_PASS_FORWARDADD",
- "UNITY_PASS_DEFERRED",
- "UNITY_PASS_SHADOWCASTER",
- "UNITY_INSTANCING_ENABLED",
- "DIRECTIONAL_COOKIE"
-
- };
-
- public static readonly string[] CategoryPresets =
- {
- "<Custom>",
- "Camera And Screen",
- "Constants And Properties",
- "Functions",
- "Image Effects",
- "Light",
- "Logical Operators",
- "Math Operators",
- "Matrix Operators",
- "Miscellaneous",
- "Object Transform",
- "Surface Data",
- "Textures",
- "Time",
- "Trigonometry Operators",
- "UV Coordinates",
- "Vector Operators",
- "Vertex Data"
- };
-
- private static Dictionary<MasterNodePortCategory, int> m_portCategoryToArrayIdx = new Dictionary<MasterNodePortCategory, int>
- {
- { MasterNodePortCategory.Vertex,0},
- { MasterNodePortCategory.Tessellation,0},
- { MasterNodePortCategory.Fragment,1},
- { MasterNodePortCategory.Debug,1}
- };
-
- private static Dictionary<string, string> m_reservedPropertyNames = new Dictionary<string, string>
- {
- { "UNITY_MATRIX_MVP", string.Empty},
- { "UNITY_MATRIX_MV", string.Empty},
- { "UNITY_MATRIX_V", string.Empty},
- { "UNITY_MATRIX_P", string.Empty},
- { "UNITY_MATRIX_VP", string.Empty},
- { "UNITY_MATRIX_T_MV", string.Empty},
- { "UNITY_MATRIX_IT_MV", string.Empty},
- { "UNITY_MATRIX_TEXTURE0", string.Empty},
- { "UNITY_MATRIX_TEXTURE1", string.Empty},
- { "UNITY_MATRIX_TEXTURE2", string.Empty},
- { "UNITY_MATRIX_TEXTURE3", string.Empty},
- { "_Object2World", string.Empty},
- { "_WorldSpaceCameraPos", string.Empty},
- { "unity_Scale", string.Empty},
- { "_ModelLightColor", string.Empty},
- { "_SpecularLightColor", string.Empty},
- { "_ObjectSpaceLightPos", string.Empty},
- { "_Light2World", string.Empty},
- { "_World2Light", string.Empty},
- { "_Object2Light", string.Empty},
- { "_Time", string.Empty},
- { "_SinTime", string.Empty},
- { "_CosTime", string.Empty},
- { "unity_DeltaTime", string.Empty},
- { "_ProjectionParams", string.Empty},
- { "_ScreenParams", string.Empty}
- };
-
- private static Dictionary<string, string> m_exampleMaterialIDs = new Dictionary<string, string>()
- {
- //Community
- {"2Sided", "8ebbbf2c99a544ca780a2573ef1450fc" },
- {"DissolveBurn", "f144f2d7ff3daf349a2b7f0fd81ec8ac" },
- {"MourEnvironmentGradient", "b64adae401bc073408ac7bff0993c107" },
- {"ForceShield", "0119aa6226e2a4cfdb6c9a5ba9df7820" },
- {"HighlightAnimated", "3d232e7526f6e426cab994cbec1fc287" },
- {"Hologram", "b422c600f1c3941b8bc7e95db33476ad" },
- {"LowPolyWater", "0557703d3791a4286a62f8ee709d5bef"},
- //Official
- {"AnimatedFire", "63ea5eae6d954a14292033589d0d4275" },
- {"AnimatedFire-ShaderFunction", "9c6c9fcb82afe874a825a9e680e694b2" },
- {"BurnEffect", "0b019675a8064414b97862a02f644166" },
- {"CubemapReflections", "2c299f827334e9c459a60931aea62260" },
- {"DitheringFade", "610507217b7dcad4d97e6e03e9844171" },
- {"DoubleLayerCustomSurface", "846aec4914103104d99e9e31a217b548" },
- {"NormalExtrusion", "70a5800fbba039f46b438a2055bc6c71" },
- {"MatcapSample", "da8aaaf01fe8f2b46b2fbcb803bd7af4" },
- {"ParallaxMappingIterations", "a0cea9c3f318ac74d89cd09134aad000" },
- {"SandPOM", "905481dc696211145b88dc4bac2545f3" },
- {"ParallaxWindow", "63ad0e7afb1717b4e95adda8904ab0c3" },
- {"LocalPosCutoff", "fed8c9d33a691084c801573feeed5a62" },
- {"ImprovedReadFromAtlasTiled", "941b31b251ea8e74f9198d788a604c9b" },
- {"ReadFromAtlasTiled", "2d5537aa702f24645a1446dc3be92bbf" },
- {"ReflectRefractSoapBubble", "a844987c9f2e7334abaa34f12feda3b9" },
- {"RimLight", "e2d3a4d723cf1dc4eab1d919f3324dbc" },
- {"RefractedShadows", "11818aa28edbeb04098f3b395a5bfc1d" },
- {"TextureArray", "0f572993ab788a346aea45f2f797b7fa" },
- {"ObjectNormalRefraction", "f1a0a645876302547b608ce881c94e6d" },
- {"ShaderBallInterior", "e47ee174f55b6144b9c1a942bb23d82a" },
- {"ScreenSpaceCurvature", "2e794cb9b3900b043a37ba28cdc2f907" },
- {"ScreenSpaceDetail", "3a0163d12fede4d47a1f818a66a115de" },
- {"SimpleNoise", "cc167bc6c2063a14f84a5a77be541194" },
- {"SimpleBlur", "1d283ff911af20e429180bb15d023661" },
- {"SimpleGPUInstancing", "9d609a7c8d00c7c4c9bdcdcdba154b81" },
- {"SimpleLambert", "54b29030f7d7ffe4b84f2f215dede5ac" },
- {"SimpleRefraction", "58c94d2f48acdc049a53b4ca53d6d98a" },
- {"SimpleTexture", "9661085a7d249a54c95078ac8e7ff004" },
- {"SnowAccum", "e3bd639f50ae1a247823079047a8dc01" },
- {"StencilDiffuse01", "9f47f529fdeddd948a2d2722f73e6ac4" },
- {"StencilMask01", "6f870834077d59b44ac421c36f619d59" },
- {"StencilDiffuse02", "11cdb862d5ba68c4eae526765099305b" },
- {"StencilMask02", "344696733b065c646b18c1aa2eacfdb7" },
- {"StencilDiffuse03", "75e851f6c686a5f42ab900222b29355b" },
- {"StencilMask03", "c7b3018ad495c6b479f2e3f8564aa6dc" },
- {"SubstanceExample", "a515e243b476d7e4bb37eb9f82c87a12" },
- {"AnimatedRefraction", "e414af1524d258047bb6b82b8860062c" },
- {"Tessellation", "efb669a245f17384c88824d769d0087c" },
- {"Translucency", "842ba3dcdd461ea48bdcfcea316cbcc4" },
- {"Transmission", "1b21506b7afef734facfc42c596caa7b" },
- {"Transparency", "e323a62068140c2408d5601877e8de2c" },
- {"TriplanarProjection", "663d512de06d4e24db5205c679f394cb" },
- {"TwoSideWithFace", "c953c4b601ba78e4f870d24d038b67f6" },
- {"Ground", "48df9bdf7b922d94bb3167e6db39c943" },
- {"WaterSample", "288137d67ce790e41903020c572ab4d7" },
- {"WorldPosSlices", "013cc03f77f3d034692f902db8928787" }
- };
-
- private static Dictionary<TextureType, string> m_textureTypeToCgType = new Dictionary<TextureType, string>()
- {
- {TextureType.Texture1D, "sampler1D" },
- {TextureType.Texture2D, "sampler2D" },
- {TextureType.Texture3D, "sampler3D" },
- {TextureType.Cube , "samplerCUBE"},
- {TextureType.Texture2DArray, "sampler2D" },
- {TextureType.ProceduralTexture, "sampler2D" }
- };
-
-
- private static Dictionary<string, Color> m_nodeCategoryToColor = new Dictionary<string, Color>()
- {
- { "Master", new Color( 0.6f, 0.52f, 0.43f, 1.0f )},
- { "Default", new Color( 0.26f, 0.35f, 0.44f, 1.0f )},
- { "Vertex Data", new Color( 0.8f, 0.07f, 0.18f, 1.0f)},//new Color( 0.75f, 0.10f, 0.30f, 1.0f )},
- { "Math Operators", new Color( 0.26f, 0.35f, 0.44f, 1.0f )},//new Color( 0.10f, 0.27f, 0.45f, 1.0f) },
- { "Logical Operators", new Color( 0.0f, 0.55f, 0.45f, 1.0f)},//new Color( 0.11f, 0.28f, 0.47f, 1.0f) },
- { "Trigonometry Operators", new Color( 0.1f, 0.20f, 0.35f, 1.0f)},//new Color( 0.8f, 0.07f, 0.18f, 1.0f)},
- { "Image Effects", new Color( 0.5f, 0.2f, 0.90f, 1.0f)},//new Color( 0.12f, 0.47f, 0.88f, 1.0f)},
- { "Miscellaneous", new Color( 0.49f, 0.32f, 0.60f, 1.0f)},
- { "Camera And Screen", new Color( 0.75f, 0.10f, 0.30f, 1.0f )},//new Color( 0.17f, 0.22f, 0.07f, 1.0f) },
- { "Constants And Properties", new Color( 0.42f, 0.70f, 0.22f, 1.0f) },
- { "Surface Data", new Color( 0.92f, 0.73f, 0.03f, 1.0f)},
- { "Matrix Transform", new Color( 0.09f, 0.43f, 0.2f, 1.0f) },
- { "Time", new Color( 0.25f, 0.25f, 0.25f, 1.0f)},//new Color( 0.89f, 0.59f, 0.0f, 1.0f) },
- { "Functions", new Color( 1.00f, 0.4f, 0.0f, 1.0f) },
- { "Vector Operators", new Color( 0.22f, 0.20f, 0.45f, 1.0f)},
- { "Matrix Operators", new Color( 0.45f, 0.9f, 0.20f, 1.0f) },
- { "Light", new Color( 1.0f, 0.9f, 0.0f, 1.0f) },
- { "Textures", new Color( 0.15f, 0.40f, 0.8f, 1.0f)},
- { "Commentary", new Color( 0.7f, 0.7f, 0.7f, 1.0f)},
- { "UV Coordinates", new Color( 0.89f, 0.59f, 0.0f, 1.0f) },
- { "Object Transform", new Color( 0.15f, 0.4f, 0.49f, 1.0f)},
- { "Vertex Transform", new Color( 0.15f, 0.4f, 0.49f, 1.0f)}
- };
-
- private static Dictionary<ToolButtonType, List<string>> m_toolButtonTooltips = new Dictionary<ToolButtonType, List<string>>
- {
- { ToolButtonType.New, new List<string>() { "Create new shader." } },
- { ToolButtonType.Open, new List<string>() { "Open existing shader." } },
- { ToolButtonType.Save, new List<string>() { "No changes to save.", "Save current changes." } },
- { ToolButtonType.Library, new List<string>() { "Lists custom shader selection." } },
- { ToolButtonType.Options, new List<string>() { "Open Options menu." } },
- { ToolButtonType.Update, new List<string>() { "Open or create a new shader first.", "Click to enable to update current shader.", "Shader up-to-date." } },
- { ToolButtonType.Live, new List<string>() { "Open or create a new shader first.", "Click to enable live shader preview", "Click to enable live shader and material preview." , "Live preview active, click to disable." } },
- { ToolButtonType.TakeScreenshot, new List<string>() { "Take screenshot", "Take screenshot" }},
- { ToolButtonType.Share, new List<string>() { "Share selection", "Share selection" }},
- { ToolButtonType.CleanUnusedNodes, new List<string>() { "No unconnected nodes to clean.", "Remove all nodes not connected( directly or indirectly) to the master node." }},
- { ToolButtonType.Help, new List<string>() { "Show help window." } },
- { ToolButtonType.FocusOnMasterNode,new List<string>() { "Focus on active master node." } },
- { ToolButtonType.FocusOnSelection, new List<string>() { "Focus on selection fit to screen ( if none selected )." } }
- };
-
- private static Color[] m_dataTypeToColorMonoMode = { new Color( 0.5f, 0.5f, 0.5f, 1.0f ), Color.white };
- private static Dictionary<WirePortDataType, Color> m_dataTypeToColor = new Dictionary<WirePortDataType, Color>( new WirePortDataTypeComparer() )
- {
- { WirePortDataType.OBJECT, Color.white},
- { WirePortDataType.FLOAT, Color.gray},
- { WirePortDataType.FLOAT2, new Color(1f,1f,0f,1f)},
- { WirePortDataType.FLOAT3, new Color(0.5f,0.5f,1f,1f)},
- { WirePortDataType.FLOAT4, new Color(1f,0,1f,1f)},
- { WirePortDataType.FLOAT3x3, new Color(0.5f,1f,0.5f,1f)},
- { WirePortDataType.FLOAT4x4, new Color(0.5f,1f,0.5f,1f)},
- { WirePortDataType.COLOR, new Color(1f,0,1f,1f)},
- { WirePortDataType.INT, Color.white},
- { WirePortDataType.SAMPLER1D, new Color(1f,0.5f,0f,1f)},
- { WirePortDataType.SAMPLER2D, new Color(1f,0.5f,0f,1f)},
- { WirePortDataType.SAMPLER3D, new Color(1f,0.5f,0f,1f)},
- { WirePortDataType.SAMPLERCUBE, new Color(1f,0.5f,0f,1f)}
- };
-
- private static Dictionary<WirePortDataType, string> m_dataTypeToName = new Dictionary<WirePortDataType, string>()
- {
- { WirePortDataType.OBJECT, "Generic Object"},
- { WirePortDataType.FLOAT, "Float"},
- { WirePortDataType.FLOAT2, "Vector2"},
- { WirePortDataType.FLOAT3, "Vector3"},
- { WirePortDataType.FLOAT4, "Vector4"},
- { WirePortDataType.FLOAT3x3, "3x3 Matrix"},
- { WirePortDataType.FLOAT4x4, "4x4 Matrix"},
- { WirePortDataType.COLOR, "Color"},
- { WirePortDataType.INT, "Int"},
- { WirePortDataType.SAMPLER1D, "Sampler1D"},
- { WirePortDataType.SAMPLER2D, "Sampler2D"},
- { WirePortDataType.SAMPLER3D, "Sampler3D"},
- { WirePortDataType.SAMPLERCUBE, "SamplerCUBE"}
- };
-
- private static Dictionary<SurfaceInputs, string> m_inputTypeDeclaration = new Dictionary<SurfaceInputs, string>()
- {
- { SurfaceInputs.DEPTH, "{0} Depth : SV_Depth"},
- { SurfaceInputs.UV_COORDS, "{0}2 uv"},// texture uv must have uv or uv2 followed by the texture name
- { SurfaceInputs.UV2_COORDS, "{0}2 uv2"},
- { SurfaceInputs.VIEW_DIR, "{0}3 viewDir"},
- { SurfaceInputs.COLOR, Constants.ColorInput},
- { SurfaceInputs.SCREEN_POS, "{0}4 screenPos"},
- { SurfaceInputs.WORLD_POS, "{0}3 worldPos"},
- { SurfaceInputs.WORLD_REFL, "{0}3 worldRefl"},
- { SurfaceInputs.WORLD_NORMAL,"{0}3 worldNormal"},
- { SurfaceInputs.VFACE, Constants.VFaceInput},
- { SurfaceInputs.INTERNALDATA, Constants.InternalData}
- };
-
- private static Dictionary<SurfaceInputs, string> m_inputTypeName = new Dictionary<SurfaceInputs, string>()
- {
- { SurfaceInputs.DEPTH, "Depth"},
- { SurfaceInputs.UV_COORDS, "uv"},// texture uv must have uv or uv2 followed by the texture name
- { SurfaceInputs.UV2_COORDS, "uv2"},
- { SurfaceInputs.VIEW_DIR, "viewDir"},
- { SurfaceInputs.COLOR, Constants.ColorVariable},
- { SurfaceInputs.SCREEN_POS, "screenPos"},
- { SurfaceInputs.WORLD_POS, "worldPos"},
- { SurfaceInputs.WORLD_REFL, "worldRefl"},
- { SurfaceInputs.WORLD_NORMAL, "worldNormal"},
- { SurfaceInputs.VFACE, Constants.VFaceVariable},
- };
-
- private static Dictionary<PrecisionType, string> m_precisionTypeToCg = new Dictionary<PrecisionType, string>()
- {
- {PrecisionType.Float, "float"},
- {PrecisionType.Half, "half"},
- {PrecisionType.Inherit, "float"}
- };
-
- private static Dictionary<VariableQualifiers, string> m_qualifierToCg = new Dictionary<VariableQualifiers, string>()
- {
- { VariableQualifiers.In, string.Empty},
- {VariableQualifiers.Out, "out"},
- {VariableQualifiers.InOut, "inout"}
- };
-
- private static Dictionary<WirePortDataType, string> m_precisionWirePortToCgType = new Dictionary<WirePortDataType, string>()
- {
- {WirePortDataType.FLOAT, "{0}"},
- {WirePortDataType.FLOAT2, "{0}2"},
- {WirePortDataType.FLOAT3, "{0}3"},
- {WirePortDataType.FLOAT4, "{0}4"},
- {WirePortDataType.FLOAT3x3, "{0}3x3"},
- {WirePortDataType.FLOAT4x4, "{0}4x4"},
- {WirePortDataType.COLOR, "{0}4"},
- {WirePortDataType.INT, "int"},
- {WirePortDataType.SAMPLER1D, "sampler1D"},
- {WirePortDataType.SAMPLER2D, "sampler2D"},
- {WirePortDataType.SAMPLER3D, "sampler3D"},
- {WirePortDataType.SAMPLERCUBE, "samplerCUBE"}
- };
-
- private static Dictionary<WirePortDataType, string> m_wirePortToCgType = new Dictionary<WirePortDataType, string>()
- {
- { WirePortDataType.FLOAT, "float"},
- {WirePortDataType.FLOAT2, "float2"},
- {WirePortDataType.FLOAT3, "float3"},
- {WirePortDataType.FLOAT4, "float4"},
- {WirePortDataType.FLOAT3x3, "float3x3"},
- {WirePortDataType.FLOAT4x4, "float4x4"},
- {WirePortDataType.COLOR, "float4"},
- {WirePortDataType.INT, "int"},
- {WirePortDataType.SAMPLER1D, "sampler1D"},
- {WirePortDataType.SAMPLER2D, "sampler2D"},
- {WirePortDataType.SAMPLER3D, "sampler3D"},
- {WirePortDataType.SAMPLERCUBE, "samplerCUBE"},
- {WirePortDataType.UINT, "uint"}
- };
-
- private static Dictionary<KeyCode, string> m_keycodeToString = new Dictionary<KeyCode, string>()
- {
- {KeyCode.Alpha0,"0" },
- {KeyCode.Alpha1,"1" },
- {KeyCode.Alpha2,"2" },
- {KeyCode.Alpha3,"3" },
- {KeyCode.Alpha4,"4" },
- {KeyCode.Alpha5,"5" },
- {KeyCode.Alpha6,"6" },
- {KeyCode.Alpha7,"7" },
- {KeyCode.Alpha8,"8" },
- {KeyCode.Alpha9,"9" }
- };
-
- private static Dictionary<WireStatus, Color> m_wireStatusToColor = new Dictionary<WireStatus, Color>()
- {
- { WireStatus.Default,new Color(0.7f,0.7f,0.7f,1.0f) },
- {WireStatus.Highlighted,Color.yellow },
- {WireStatus.Selected,Color.white}
- };
-
- private static Dictionary<WirePortDataType, string> m_autoSwizzle = new Dictionary<WirePortDataType, string>()
- {
- {WirePortDataType.FLOAT, ".x"},
- {WirePortDataType.FLOAT2, ".xy"},
- {WirePortDataType.FLOAT3, ".xyz"},
- {WirePortDataType.FLOAT4, ".xyzw"}
- };
-
- private static Dictionary<string, bool> m_unityNativeShaderPaths = new Dictionary<string, bool>
- {
- { "Resources/unity_builtin_extra", true },
- { "Library/unity default resources", true }
- };
-
- private static Dictionary<WirePortDataType, int> m_portPriority = new Dictionary<WirePortDataType, int>()
- {
- { WirePortDataType.OBJECT, 0},
- {WirePortDataType.SAMPLER1D, 0},
- {WirePortDataType.SAMPLER2D, 0},
- {WirePortDataType.SAMPLER3D, 0},
- {WirePortDataType.SAMPLERCUBE, 0},
- {WirePortDataType.FLOAT3x3, 1},
- {WirePortDataType.FLOAT4x4, 2},
- {WirePortDataType.INT, 3},
- {WirePortDataType.FLOAT, 4},
- {WirePortDataType.FLOAT2, 5},
- {WirePortDataType.FLOAT3, 6},
- {WirePortDataType.FLOAT4, 7},
- {WirePortDataType.COLOR, 7}
- };
-
- private static readonly string IncorrectInputConnectionErrorMsg = "Input Port {0} from node {1} has type {2}\nwhich is incompatible with connection of type {3} from port {4} on node {5}";
- private static readonly string IncorrectOutputConnectionErrorMsg = "Output Port {0} from node {1} has type {2}\nwhich is incompatible with connection of type {3} from port {4} on node {5}";
- private static readonly string NoVertexModeNodeWarning = "{0} is unable to generate code in vertex function";
-
- private static float SwitchFixedHeight;
- private static float SwitchFontSize;
- private static RectOffset SwitchNodeBorder;
- private static RectOffset SwitchNodeMargin;
- private static RectOffset SwitchNodeOverflow;
- private static RectOffset SwitchNodePadding;
-
- public static void ForceExampleShaderCompilation()
- {
- CurrentWindow.ForceMaterialsToUpdate( ref m_exampleMaterialIDs );
-
- }
-
- public static void Destroy()
- {
- if( IOUtils.AllOpenedWindows != null && IOUtils.AllOpenedWindows.Count > 0 )
- {
- return;
- }
- else
- {
- IOUtils.AllOpenedWindows.Clear();
- }
-
- Initialized = false;
- PlusStyle = null;
- MinusStyle = null;
- m_textInfo = null;
- RangedFloatSliderStyle = null;
- RangedFloatSliderThumbStyle = null;
- PropertyPopUp = null;
- ObjectField = null;
- PreviewExpander = null;
- PreviewCollapser = null;
- MenuItemToggleStyle = null;
- MenuItemEnableStyle = null;
- MenuItemBackgroundStyle = null;
- MenuItemToolbarStyle = null;
- MenuItemInspectorDropdownStyle = null;
- ObjectFieldThumb = null;
- ObjectFieldThumbOverlay = null;
- InspectorPopdropdownStyle = null;
- InspectorPopdropdownFallback = null;
- TooltipBox = null;
- UnZoomedNodeTitleStyle = null;
- UnZoomedPropertyValuesTitleStyle = null;
- UnZoomedInputPortStyle = null;
- UnZoomedOutputPortPortStyle = null;
- ToolbarSearchTextfield = null;
- ToolbarSearchCancelButton = null;
- FloatIntPickerONOFF = null;
- Box = null;
- Button = null;
- TextArea = null;
- Label = null;
- Toggle = null;
- Textfield = null;
-
- CommentaryTitle = null;
- InputPortLabel = null;
- OutputPortLabel = null;
-
- IntShader = null;
- FloatShader = null;
- Vector2Shader = null;
- Vector3Shader = null;
- Vector4Shader = null;
- ColorShader = null;
- Texture2DShader = null;
-
- MaskingShader = null;
-
- BoldErrorStyle = null;
- BoldWarningStyle = null;
- BoldInfoStyle = null;
- Separator = null;
- ToolbarMainTitle = null;
-
- GraphButtonIcon = null;
- GraphButton = null;
- GraphDropDown = null;
-
- ConsoleLogLabel = null;
- ConsoleLogMessage = null;
- ConsoleLogCircle = null;
-
- MiniButtonTopLeft = null;
- MiniButtonTopMid = null;
- MiniButtonTopRight = null;
-
- NodeWindowOffSquare = null;
- NodeHeaderSquare = null;
- NodeWindowOnSquare = null;
- InternalDataOnPort = null;
- InternalDataBackground = null;
-
- MiniObjectFieldThumbOverlay = null;
- MiniSamplerButton = null;
-
- Resources.UnloadAsset( SmallErrorIcon );
- SmallErrorIcon = null;
-
- Resources.UnloadAsset( SmallWarningIcon );
- SmallWarningIcon = null;
-
- Resources.UnloadAsset( SmallInfoIcon );
- SmallInfoIcon = null;
-
- LockIconOpen = null;
- LockIconClosed = null;
-
- FloatIntIconON = null;
- FloatIntIconOFF = null;
-
- Resources.UnloadAsset( CheckmarkIcon );
- CheckmarkIcon = null;
-
- Resources.UnloadAsset( PopupIcon );
- PopupIcon = null;
-
- Resources.UnloadAsset( MasterNodeOnTexture );
- MasterNodeOnTexture = null;
-
- Resources.UnloadAsset( MasterNodeOffTexture );
- MasterNodeOffTexture = null;
-
- Resources.UnloadAsset( GPUInstancedOnTexture );
- GPUInstancedOnTexture = null;
-
- Resources.UnloadAsset( GPUInstancedOffTexture );
- GPUInstancedOffTexture = null;
-
- MainSkin = null;
-
- if( LinearMaterial != null )
- GameObject.DestroyImmediate( LinearMaterial );
-
- LinearMaterial = null;
-
- if( m_undoHelper == null )
- {
- m_undoHelper.Clear();
- m_undoHelper = null;
- }
- ASEMaterialInspector.Instance = null;
- }
-
- public static void ResetMainSkin()
- {
- if( (object)MainSkin != null )
- {
- CurrentHeaderHeight = HeaderMaxHeight;
- ScaledPortsDelta = PortsDelta;
- MainSkin.textField.fontSize = (int)( Constants.TextFieldFontSize );
- MainSkin.label.fontSize = (int)( Constants.DefaultFontSize );
- MainSkin.customStyles[ (int)CustomStyle.NodeTitle ].fontSize = (int)( Constants.DefaultTitleFontSize );
-
- InputPortLabel.fontSize = (int)( Constants.DefaultFontSize );
- OutputPortLabel.fontSize = (int)( Constants.DefaultFontSize );
- CommentaryTitle.fontSize = (int)( Constants.DefaultFontSize );
- }
- }
-
- public static void InitMainSkin()
- {
- MainSkin = AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath( IOUtils.MainSkinGUID ), typeof( GUISkin ) ) as GUISkin;
- Initialized = true;
- Texture2D portTex = GetCustomStyle( CustomStyle.PortEmptyIcon ).normal.background;
- PortsSize = new Vector2( portTex.width, portTex.height );
- PortsDelta = new Vector3( 0.5f * PortsSize.x, 0.5f * PortsSize.y );
- HeaderMaxHeight = MainSkin.customStyles[ (int)CustomStyle.NodeHeader ].normal.background.height;
-
- RectOffsetZero = new RectOffset( 0, 0, 0, 0 );
- RectOffsetOne = new RectOffset( 1, 1, 1, 1 );
- RectOffsetTwo = new RectOffset( 2, 2, 2, 2 );
- RectOffsetThree = new RectOffset( 3, 3, 3, 3 );
- RectOffsetFour = new RectOffset( 4, 4, 4, 4 );
- RectOffsetFive = new RectOffset( 5, 5, 5, 5 );
- RectOffsetSix = new RectOffset( 6, 6, 6, 6 );
-
- PropertyPopUp = GetCustomStyle( CustomStyle.NodePropertyPicker );
- ObjectField = new GUIStyle( (GUIStyle)"ObjectField" );
- PreviewExpander = GetCustomStyle( CustomStyle.NodePreviewExpander );
- PreviewCollapser = GetCustomStyle( CustomStyle.NodePreviewCollapser );
-
- WireNodeSelection = AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath( "bfe0b03d5d60cea4f9d4b2d1d121e592" ), typeof( Texture2D ) ) as Texture2D;
- SliderButton = AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath( "dd563e33152bb6443b099b4139ceecb9" ), typeof( Texture2D ) ) as Texture2D;
-
- SmallErrorIcon = EditorGUIUtility.Load( "icons/d_console.erroricon.sml.png" ) as Texture2D;
- SmallWarningIcon = EditorGUIUtility.Load( "icons/d_console.warnicon.sml.png" ) as Texture2D;
- SmallInfoIcon = EditorGUIUtility.Load( "icons/d_console.infoicon.sml.png" ) as Texture2D;
-
- LockIconOpen = new GUIContent( EditorGUIUtility.IconContent( "LockIcon-On" ) );
- LockIconOpen.tooltip = "Click to unlock and customize the variable name";
- LockIconClosed = new GUIContent( EditorGUIUtility.IconContent( "LockIcon" ) );
- LockIconClosed.tooltip = "Click to lock and auto-generate the variable name";
-
- if( UsingProSkin )
- {
- FloatIntIconON = new GUIContent( EditorGUIUtility.IconContent( "CircularToggle_ON" ) );
- FloatIntIconOFF = new GUIContent( EditorGUIUtility.IconContent( "CircularToggle_OFF" ) );
- }
- else
- {
- FloatIntIconON = new GUIContent( ( AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath( "ac0860a6a77e29d4091ba790a17daa0f" ), typeof( Texture2D ) ) as Texture2D ) );
- FloatIntIconOFF = new GUIContent( ( AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath( "1aaca50d084b0bb43854f075ce2f302b" ), typeof( Texture2D ) ) as Texture2D ) );
- }
-
- CommentaryTitle = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.CommentaryTitle ] );
- InputPortLabel = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.InputPortlabel ] );
- OutputPortLabel = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.OutputPortLabel ] );
-
- CheckmarkIcon = AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath( "e9c4642eaa083a54ab91406d8449e6ac" ), typeof( Texture2D ) ) as Texture2D;
- PopupIcon = AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath( "d2384a227b4ac4943b73c8151393e502" ), typeof( Texture2D ) ) as Texture2D;
-
- BoldErrorStyle = new GUIStyle( (GUIStyle)"BoldLabel" );
- BoldErrorStyle.normal.textColor = Color.red;
- BoldErrorStyle.alignment = TextAnchor.MiddleCenter;
- BoldWarningStyle = new GUIStyle( (GUIStyle)"BoldLabel" );
- BoldWarningStyle.normal.textColor = Color.yellow;
- BoldWarningStyle.alignment = TextAnchor.MiddleCenter;
- BoldInfoStyle = new GUIStyle( (GUIStyle)"BoldLabel" );
- BoldInfoStyle.normal.textColor = Color.white;
- BoldInfoStyle.alignment = TextAnchor.MiddleCenter;
-
- ToolbarMainTitle = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.MainCanvasTitle ] );
- Separator = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.FlatBackground ] );
- MiniButtonTopLeft = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.MiniButtonTopLeft ] );
- MiniButtonTopMid = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.MiniButtonTopMid ] );
- MiniButtonTopRight = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.MiniButtonTopRight ] );
-
- InternalDataOnPort = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.NodeTitle ] );
- InternalDataOnPort.fontSize = 8;
- InternalDataOnPort.fontStyle = FontStyle.BoldAndItalic;
- InternalDataBackground = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.NodeWindowOffSquare ] );
- InternalDataBackground.normal.background = AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath( "330fd0c8f074a3c4f8042114a61a73d9" ), typeof( Texture2D ) ) as Texture2D;
- InternalDataBackground.overflow = RectOffsetOne;
-
- MiniObjectFieldThumbOverlay = new GUIStyle( (GUIStyle)"ObjectFieldThumbOverlay" );
- MiniSamplerButton = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.SamplerButton ] );
-
- m_textInfo = new System.Globalization.CultureInfo( "en-US", false ).TextInfo;
- RangedFloatSliderStyle = new GUIStyle( GUI.skin.horizontalSlider );
- RangedFloatSliderThumbStyle = new GUIStyle( GUI.skin.horizontalSliderThumb );
- RangedFloatSliderThumbStyle.normal.background = SliderButton;
- RangedFloatSliderThumbStyle.active.background = null;
- RangedFloatSliderThumbStyle.hover.background = null;
- RangedFloatSliderThumbStyle.focused.background = null;
- RangedFloatSliderThumbStyle.overflow = new RectOffset( 1, 1, -4, 4 );
- RangedFloatSliderThumbStyle.margin = RectOffsetZero;
-
- SwitchNodePopUp = new GUIStyle( (GUIStyle)"Popup" );
- // RectOffset cannot be initiliazed on constructor
- SwitchNodeBorder = new RectOffset( 4, 15, 3, 3 );
- SwitchNodeMargin = new RectOffset( 4, 4, 3, 3 );
- SwitchNodeOverflow = new RectOffset( 0, 0, -1, 2 );
- SwitchNodePadding = new RectOffset( 6, 14, 2, 3 );
- SwitchFixedHeight = 18;
- SwitchFontSize = 10;
-
- GraphButtonIcon = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.GraphButtonIcon ] );
- GraphButton = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.GraphButton ] );
- GraphDropDown = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.GraphButton ] );
- GraphDropDown.padding.right = 20;
-
- Box = new GUIStyle( MainSkin.box );
- Button = new GUIStyle( GUI.skin.button );
- TextArea = new GUIStyle( GUI.skin.textArea );
- Label = new GUIStyle( GUI.skin.label );
- Toggle = new GUIStyle( GUI.skin.toggle );
- Textfield = new GUIStyle( GUI.skin.textField );
- //ShaderIcon = EditorGUIUtility.IconContent( "Shader Icon" ).image;
- //MaterialIcon = EditorGUIUtility.IconContent( "Material Icon" ).image;
-
- ConsoleLogLabel = new GUIStyle( GUI.skin.label );
- ConsoleLogMessage = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.ConsoleLogMessage ] );
- ConsoleLogCircle = new GUIStyle( MainSkin.customStyles[ (int)CustomStyle.ConsoleLogCircle ] );
-
- NodeWindowOffSquare = GetCustomStyle( CustomStyle.NodeWindowOffSquare );
- NodeHeaderSquare = GetCustomStyle( CustomStyle.NodeHeaderSquare );
- NodeWindowOnSquare = GetCustomStyle( CustomStyle.NodeWindowOnSquare );
-
- UnZoomedNodeTitleStyle = new GUIStyle( GetCustomStyle( CustomStyle.NodeTitle ) );
- UnZoomedNodeTitleStyle.fontSize = 13;
-
- UnZoomedPropertyValuesTitleStyle = new GUIStyle( GetCustomStyle( CustomStyle.PropertyValuesTitle ) );
- UnZoomedPropertyValuesTitleStyle.fontSize = 11;
-
- UnZoomedInputPortStyle = new GUIStyle( InputPortLabel );
- UnZoomedInputPortStyle.fontSize = (int)Constants.DefaultFontSize;
-
- UnZoomedOutputPortPortStyle = new GUIStyle( OutputPortLabel );
- UnZoomedOutputPortPortStyle.fontSize = (int)Constants.DefaultFontSize;
-
- ObjectFieldThumb = new GUIStyle( (GUIStyle)"ObjectFieldThumb" );
- ObjectFieldThumbOverlay = new GUIStyle( (GUIStyle)"ObjectFieldThumbOverlay" );
-
- FloatIntPickerONOFF = new GUIStyle( "metimelabel" );
- FloatIntPickerONOFF.padding.left = -2;
- FloatIntPickerONOFF.margin = new RectOffset(0,2,2,2);
-
- TooltipBox = new GUIStyle( (GUIStyle)"Tooltip" );
- TooltipBox.richText = true;
-
- MasterNodeOnTexture = AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( IOUtils.MasterNodeOnTextureGUID ) );
- MasterNodeOffTexture = AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( IOUtils.MasterNodeOnTextureGUID ) );
-
- GPUInstancedOnTexture = AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( IOUtils.GPUInstancedOnTextureGUID ) );
- GPUInstancedOffTexture = AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( IOUtils.GPUInstancedOffTextureGUID ) );
-
- CheckNullMaterials();
-
- UsingProSkin = EditorGUIUtility.isProSkin;
- FetchMenuItemStyles();
- }
-
- public static bool IsLoading
- {
- get { return CurrentWindow.OutsideGraph.IsLoading; }
- }
-
- public static void CheckNullMaterials()
- {
- if( LinearMaterial == null )
- {
- Shader linearShader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "e90ef6ea05743b84baf9549874c52e47" ) ); //linear previews
- LinearMaterial = new Material( linearShader );
- }
-
- if( IntShader == null )
- IntShader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "0f64d695b6ffacc469f2dd31432a232a" ) ); //int
- if( FloatShader == null )
- FloatShader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "d9ca47581ac157145bff6f72ac5dd73e" ) ); //ranged float
- if( Vector2Shader == null )
- Vector2Shader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "88b4191eb06084d4da85d1dd2f984085" ) ); //vector2
- if( Vector3Shader == null )
- Vector3Shader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "8a44d38f06246bf48944b3f314bc7920" ) ); //vector3
- if( Vector4Shader == null )
- Vector4Shader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "aac241d0e47a5a84fbd2edcd640788dc" ) ); //vector4
- if( ColorShader == null )
- ColorShader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "6cf365ccc7ae776488ae8960d6d134c3" ) ); //color node
- if( MaskingShader == null )
- MaskingShader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "9c34f18ebe2be3e48b201b748c73dec0" ) ); //masking shader
- if( Texture2DShader == null )
- Texture2DShader = AssetDatabase.LoadAssetAtPath<Shader>( AssetDatabase.GUIDToAssetPath( "13bd295c44d04e1419f20f792d331e33" ) ); //texture2d shader
- }
-
- private static void FetchMenuItemStyles()
- {
- ObjectFieldThumb = new GUIStyle( (GUIStyle)"ObjectFieldThumb" );
- ObjectFieldThumbOverlay = new GUIStyle( (GUIStyle)"ObjectFieldThumbOverlay" );
- MenuItemToggleStyle = new GUIStyle( (GUIStyle)"foldout" );
- MenuItemEnableStyle = UsingProSkin ? new GUIStyle( (GUIStyle)"OL ToggleWhite" ) : new GUIStyle( (GUIStyle)"OL Toggle" );
- MenuItemBackgroundStyle = new GUIStyle( (GUIStyle)"TE NodeBackground" );
- MenuItemToolbarStyle = new GUIStyle( (GUIStyle)"toolbarbutton" ) { fixedHeight = 20 };
- MenuItemInspectorDropdownStyle = new GUIStyle( (GUIStyle)"toolbardropdown" ) { fixedHeight = 20 };
- MenuItemInspectorDropdownStyle.margin.bottom = 2;
-
-
- InspectorPopdropdownStyle = new GUIStyle( GUI.skin.GetStyle( "PopupCurveDropdown" ) );
- InspectorPopdropdownStyle.alignment = TextAnchor.MiddleRight;
- InspectorPopdropdownStyle.border.bottom = 16;
-
- InspectorPopdropdownFallback = new GUIStyle( InspectorPopdropdownStyle );
- InspectorPopdropdownFallback.overflow = new RectOffset( 0, -5, 0, 0 );
-
- PlusStyle = ( EditorGUIUtility.isProSkin ) ? new GUIStyle( GetCustomStyle( CustomStyle.CustomExpressionAddItem ) ) : new GUIStyle( (GUIStyle)"OL Plus" );
- PlusStyle.imagePosition = ImagePosition.ImageOnly;
- PlusStyle.overflow = new RectOffset( -2, 0, -4, 0 );
-
- MinusStyle = ( EditorGUIUtility.isProSkin ) ? new GUIStyle( GetCustomStyle( CustomStyle.CustomExpressionRemoveItem ) ) : new GUIStyle( (GUIStyle)"OL Minus" );
- MinusStyle.contentOffset = Vector2.zero;
- MinusStyle.imagePosition = ImagePosition.ImageOnly;
- MinusStyle.overflow = new RectOffset( -2, 0, -4, 0 );
-
- ToolbarSearchTextfield = new GUIStyle( (GUIStyle)"ToolbarSeachTextField" );
- ToolbarSearchCancelButton = new GUIStyle( (GUIStyle)"ToolbarSeachCancelButton" );
- }
-
- public static void UpdateMainSkin( DrawInfo drawInfo )
- {
- CurrentHeaderHeight = HeaderMaxHeight * drawInfo.InvertedZoom;
- ScaledPortsDelta = drawInfo.InvertedZoom * PortsDelta;
- MainSkin.textField.fontSize = (int)( Constants.TextFieldFontSize * drawInfo.InvertedZoom );
- MainSkin.label.fontSize = (int)( Constants.DefaultFontSize * drawInfo.InvertedZoom );
-
- MainSkin.customStyles[ (int)CustomStyle.NodeTitle ].fontSize = (int)( Constants.DefaultTitleFontSize * drawInfo.InvertedZoom );
- MainSkin.customStyles[ (int)CustomStyle.PropertyValuesTitle ].fontSize = (int)( Constants.PropertiesTitleFontSize * drawInfo.InvertedZoom );
-
- InputPortLabel.fontSize = (int)( Constants.DefaultFontSize * drawInfo.InvertedZoom );
- OutputPortLabel.fontSize = (int)( Constants.DefaultFontSize * drawInfo.InvertedZoom );
- CommentaryTitle.fontSize = (int)( Constants.DefaultFontSize * drawInfo.InvertedZoom );
-
- RangedFloatSliderStyle.fixedHeight = 18 * drawInfo.InvertedZoom;
- RangedFloatSliderThumbStyle.fixedHeight = 12 * drawInfo.InvertedZoom;
- RangedFloatSliderThumbStyle.fixedWidth = 10 * drawInfo.InvertedZoom;
- RangedFloatSliderThumbStyle.overflow.left = (int)( 1 * drawInfo.InvertedZoom );
- RangedFloatSliderThumbStyle.overflow.right = (int)( 1 * drawInfo.InvertedZoom );
- RangedFloatSliderThumbStyle.overflow.top = (int)( -4 * drawInfo.InvertedZoom );
- RangedFloatSliderThumbStyle.overflow.bottom = (int)( 4 * drawInfo.InvertedZoom );
-
- SwitchNodePopUp.fixedHeight = SwitchFixedHeight * drawInfo.InvertedZoom;
-
- SwitchNodePopUp.border.left = (int)( SwitchNodeBorder.left * drawInfo.InvertedZoom );
- SwitchNodePopUp.border.right = (int)( SwitchNodeBorder.right * drawInfo.InvertedZoom );
- SwitchNodePopUp.border.top = (int)( SwitchNodeBorder.top * drawInfo.InvertedZoom );
- SwitchNodePopUp.border.bottom = (int)( SwitchNodeBorder.bottom * drawInfo.InvertedZoom );
-
- SwitchNodePopUp.margin.left = (int)( SwitchNodeMargin.left * drawInfo.InvertedZoom );
- SwitchNodePopUp.margin.right = (int)( SwitchNodeMargin.right * drawInfo.InvertedZoom );
- SwitchNodePopUp.margin.top = (int)( SwitchNodeMargin.top * drawInfo.InvertedZoom );
- SwitchNodePopUp.margin.bottom = (int)( SwitchNodeMargin.bottom * drawInfo.InvertedZoom );
-
- SwitchNodePopUp.overflow.left = (int)( SwitchNodeOverflow.left * drawInfo.InvertedZoom );
- SwitchNodePopUp.overflow.right = (int)( SwitchNodeOverflow.right * drawInfo.InvertedZoom );
- SwitchNodePopUp.overflow.top = (int)( SwitchNodeOverflow.top * drawInfo.InvertedZoom );
- SwitchNodePopUp.overflow.bottom = (int)( SwitchNodeOverflow.bottom * drawInfo.InvertedZoom );
-
- SwitchNodePopUp.padding.left = (int)( SwitchNodePadding.left * drawInfo.InvertedZoom );
- SwitchNodePopUp.padding.right = (int)( SwitchNodePadding.right * drawInfo.InvertedZoom );
- SwitchNodePopUp.padding.top = (int)( SwitchNodePadding.top * drawInfo.InvertedZoom );
- SwitchNodePopUp.padding.bottom = (int)( SwitchNodePadding.bottom * drawInfo.InvertedZoom );
-
- SwitchNodePopUp.fontSize = (int)( SwitchFontSize * drawInfo.InvertedZoom );
-
- BoldErrorStyle.fontSize = (int)( 12 * drawInfo.InvertedZoom );
- BoldWarningStyle.fontSize = (int)( 12 * drawInfo.InvertedZoom );
- BoldInfoStyle.fontSize = (int)( 12 * drawInfo.InvertedZoom );
-
- PropertyPopUp.fixedHeight = Constants.PropertyPickerHeight * drawInfo.InvertedZoom;
- PropertyPopUp.fixedWidth = Constants.PropertyPickerWidth * drawInfo.InvertedZoom;
- if( UsingProSkin != EditorGUIUtility.isProSkin )
- {
- UsingProSkin = EditorGUIUtility.isProSkin;
- FetchMenuItemStyles();
- }
-
- GraphDropDown.padding.left = (int)( 2 * drawInfo.InvertedZoom + 2 );
- GraphDropDown.padding.right = (int)( 20 * drawInfo.InvertedZoom );
- GraphDropDown.fontSize = (int)( 10 * drawInfo.InvertedZoom );
-
- PreviewExpander.fixedHeight = Constants.PreviewExpanderHeight * drawInfo.InvertedZoom;
- PreviewExpander.fixedWidth = Constants.PreviewExpanderWidth * drawInfo.InvertedZoom;
-
- PreviewCollapser.fixedHeight = Constants.PreviewExpanderHeight * drawInfo.InvertedZoom;
- PreviewCollapser.fixedWidth = Constants.PreviewExpanderWidth * drawInfo.InvertedZoom;
-
- MainSkin.customStyles[ (int)CustomStyle.SamplerButton ].fontSize = (int)( 9 * drawInfo.InvertedZoom );
- ObjectFieldThumbOverlay.fontSize = (int)( 9 * drawInfo.InvertedZoom );
- MiniButtonTopLeft.fontSize = (int)( 9 * drawInfo.InvertedZoom );
- MiniButtonTopMid.fontSize = (int)( 9 * drawInfo.InvertedZoom );
- MiniButtonTopRight.fontSize = (int)( 9 * drawInfo.InvertedZoom );
-
- MiniObjectFieldThumbOverlay.fontSize = (int)( 7 * drawInfo.InvertedZoom );
- MiniSamplerButton.fontSize = (int)( 8 * drawInfo.InvertedZoom );
-
- InternalDataOnPort.fontSize = (int)( 8 * drawInfo.InvertedZoom );
- ToolbarMainTitle.padding.left = 0;
- ToolbarMainTitle.padding.right = 0;
-
- CheckNullMaterials();
- }
-
- public static void CacheLabelVars()
- {
- m_alignment = GUI.skin.label.alignment;
- m_clipping = GUI.skin.label.clipping;
- m_wordWrap = GUI.skin.label.wordWrap;
- m_fontSize = GUI.skin.label.fontSize;
- m_fontStyle = GUI.skin.label.fontStyle;
- m_fontColor = GUI.skin.label.normal.textColor;
- }
-
- public static void RestoreLabelVars()
- {
- GUI.skin.label.alignment = m_alignment;
- GUI.skin.label.clipping = m_clipping;
- GUI.skin.label.wordWrap = m_wordWrap;
- GUI.skin.label.fontSize = m_fontSize;
- GUI.skin.label.fontStyle = m_fontStyle;
- GUI.skin.label.normal.textColor = m_fontColor;
- }
-
- public static string GetTooltipForToolButton( ToolButtonType toolButtonType, int state ) { return m_toolButtonTooltips[ toolButtonType ][ state ]; }
-
- public static string KeyCodeToString( KeyCode keyCode )
- {
- if( m_keycodeToString.ContainsKey( keyCode ) )
- return m_keycodeToString[ keyCode ];
-
- return keyCode.ToString();
- }
-
- public static string TextureTypeToCgType( TextureType type ) { return m_textureTypeToCgType[ type ]; }
-
- public static string QualifierToCg( VariableQualifiers qualifier )
- {
- return m_qualifierToCg[ qualifier ];
- }
-
- public static string WirePortToCgType( WirePortDataType type )
- {
- if( type == WirePortDataType.OBJECT )
- return string.Empty;
-
- return m_wirePortToCgType[ type ];
- }
-
- public static string FinalPrecisionWirePortToCgType( PrecisionType precisionType, WirePortDataType type )
- {
- return PrecisionWirePortToCgType( precisionType, type );
- }
-
- public static string PrecisionWirePortToCgType( PrecisionType precisionType, WirePortDataType type )
- {
- if( type == WirePortDataType.OBJECT )
- return string.Empty;
-
- if( type == WirePortDataType.INT )
- return m_wirePortToCgType[ type ];
-
- if( type == WirePortDataType.UINT )
- return m_wirePortToCgType[ type ];
-
- return string.Format( m_precisionWirePortToCgType[ type ], m_precisionTypeToCg[ precisionType ] );
- }
-
- public static string GetAutoSwizzle( WirePortDataType type )
- {
- return m_autoSwizzle[ type ];
- }
-
- public static Color GetColorForDataType( WirePortDataType dataType, bool monochromeMode = true, bool isInput = true )
- {
- if( monochromeMode )
- {
- return isInput ? m_dataTypeToColorMonoMode[ 0 ] : m_dataTypeToColorMonoMode[ 1 ];
- }
- else
- {
- if ( m_dataTypeToColor.ContainsKey( dataType ) )
- return m_dataTypeToColor[ dataType ];
- }
- return m_dataTypeToColor[ WirePortDataType.OBJECT ];
- }
-
- public static bool IsValidType( WirePortDataType type )
- {
- switch ( type )
- {
- case WirePortDataType.OBJECT:
- case WirePortDataType.FLOAT:
- case WirePortDataType.FLOAT2:
- case WirePortDataType.FLOAT3:
- case WirePortDataType.FLOAT4:
- case WirePortDataType.FLOAT3x3:
- case WirePortDataType.FLOAT4x4:
- case WirePortDataType.COLOR:
- case WirePortDataType.INT:
- case WirePortDataType.SAMPLER1D:
- case WirePortDataType.SAMPLER2D:
- case WirePortDataType.SAMPLER3D:
- case WirePortDataType.SAMPLERCUBE:
- return true;
- }
- return false;
- }
- public static string GetNameForDataType( WirePortDataType dataType ) { return m_dataTypeToName[ dataType ]; }
-
- public static string GetInputDeclarationFromType( PrecisionType precision, SurfaceInputs inputType )
- {
- string precisionStr = m_precisionTypeToCg[ precision ];
- return string.Format( m_inputTypeDeclaration[ inputType ], precisionStr );
- }
-
- public static string GetInputValueFromType( SurfaceInputs inputType ) { return m_inputTypeName[ inputType ]; }
- private static string CreateLocalValueName( PrecisionType precision, WirePortDataType dataType, string localOutputValue, string value ) { return string.Format( Constants.LocalValueDecWithoutIdent, PrecisionWirePortToCgType( precision, dataType ), localOutputValue, value ); }
-
- public static string CastPortType( ref MasterNodeDataCollector dataCollector, PrecisionType nodePrecision, NodeCastInfo castInfo, object value, WirePortDataType oldType, WirePortDataType newType, string parameterName = null )
- {
- if( oldType == newType || newType == WirePortDataType.OBJECT )
- {
- return ( parameterName != null ) ? parameterName : value.ToString();
- }
-
- PrecisionType currentPrecision = nodePrecision;
- string precisionStr = m_precisionTypeToCg[ currentPrecision ];
- string newTypeStr = m_wirePortToCgType[ newType ];
- newTypeStr = m_textInfo.ToTitleCase( newTypeStr );
- int castId = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ) ? dataCollector.AvailableVertexTempId : dataCollector.AvailableFragTempId;
- string localVarName = "temp_cast_" + castId;//m_wirePortToCgType[ oldType ] + "To" + newTypeStr + "_" + castInfo.ToString();
- string result = string.Empty;
- bool useRealValue = ( parameterName == null );
-
- switch( oldType )
- {
- case WirePortDataType.FLOAT:
- {
- switch( newType )
- {
- case WirePortDataType.OBJECT: result = useRealValue ? value.ToString() : parameterName; break;
- case WirePortDataType.FLOAT2:
- {
- string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, string.Format( Constants.CastHelper, ( ( useRealValue ) ? value.ToString() : parameterName ), "xx" ) );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, -1, localVal );
- result = localVarName;
- }
- break;
- case WirePortDataType.FLOAT3:
- {
- string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, string.Format( Constants.CastHelper, ( ( useRealValue ) ? value.ToString() : parameterName ), "xxx" ) );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, -1, localVal );
- result = localVarName;
- }
- break;
- case WirePortDataType.COLOR:
- {
- string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, string.Format( Constants.CastHelper, ( ( useRealValue ) ? value.ToString() : parameterName ), "xxxx" ) );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, -1, localVal );
- result = localVarName;
- }
- break;
- case WirePortDataType.FLOAT4:
- {
- string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, string.Format( Constants.CastHelper, ( ( useRealValue ) ? value.ToString() : parameterName ), "xxxx" ) );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, -1, localVal );
- result = localVarName;
- }
- break;
- case WirePortDataType.FLOAT3x3:
- {
- string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, ( ( useRealValue ) ? value.ToString() : parameterName ) );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, -1, localVal );
- result = localVarName;
- }
- break;
- case WirePortDataType.FLOAT4x4:
- {
- string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, ( ( useRealValue ) ? value.ToString() : parameterName ) );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, -1, localVal );
- result = localVarName;
- }
- break;
- case WirePortDataType.INT:
- {
- result = ( useRealValue ) ? ( (int)value ).ToString() : "(int)" + parameterName;
- }
- break;
- }
- }
- break;
- case WirePortDataType.FLOAT2:
- {
- Vector2 vecVal = useRealValue ? (Vector2)value : Vector2.zero;
- switch( newType )
- {
- case WirePortDataType.OBJECT: result = useRealValue ? precisionStr + "2( " + vecVal.x + " , " + vecVal.y + " )" : parameterName; break;
- case WirePortDataType.FLOAT:
- {
- result = ( useRealValue ) ? vecVal.x.ToString() : parameterName + ".x";
- }
- break;
- case WirePortDataType.FLOAT3:
- {
- result = ( useRealValue ) ? precisionStr + "3( " + vecVal.x + " , " + vecVal.y + " , " + " 0.0 )" : precisionStr + "3( " + parameterName + " , 0.0 )";
- }
- break;
- case WirePortDataType.COLOR:
- case WirePortDataType.FLOAT4:
- {
- result = ( useRealValue ) ? precisionStr + "4( " + vecVal.x + " , " + vecVal.y + " , " + " 0.0 , 0.0 )" : precisionStr + "4( " + parameterName + ", 0.0 , 0.0 )";
- }
- break;
- }
- }
- break;
- case WirePortDataType.FLOAT3:
- {
- Vector3 vecVal = useRealValue ? (Vector3)value : Vector3.zero;
- switch( newType )
- {
- case WirePortDataType.OBJECT: result = useRealValue ? precisionStr + "3( " + vecVal.x + " , " + vecVal.y + " , " + vecVal.z + " )" : parameterName; break;
- case WirePortDataType.FLOAT:
- {
- result = ( useRealValue ) ? vecVal.x.ToString() : parameterName + ".x";
- }
- break;
- case WirePortDataType.FLOAT2:
- {
- result = ( useRealValue ) ? precisionStr + "2( " + vecVal.x + " , " + vecVal.y + " )" : parameterName + ".xy";
- }
- break;
- case WirePortDataType.COLOR:
- case WirePortDataType.FLOAT4:
- {
- result = ( useRealValue ) ? precisionStr + "4( " + vecVal.x + " , " + vecVal.y + " , " + vecVal.z + " , 0.0 )" : precisionStr + "4( " + parameterName + " , 0.0 )";
- }
- break;
- //case WirePortDataType.FLOAT3x3:
- //{
- // if ( useRealValue )
- // {
- // result = precisionStr + "3x3( " + vecVal.x + " , " + vecVal.y + " , " + vecVal.z + " , " +
- // vecVal.x + " , " + vecVal.y + " , " + vecVal.z + " , " +
- // vecVal.x + " , " + vecVal.y + " , " + vecVal.z + " )";
- // }
- // else
- // {
- // string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, parameterName );
- // CurrentDataCollector.AddToLocalVariables( portCategory, -1, localVal );
- // result = precisionStr + "3x3( " + localVarName + ".x , " + localVarName + ".y , " + localVarName + ".x , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".y , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z )";
- // }
- //}
- //break;
- //case WirePortDataType.FLOAT4x4:
- //{
- // if ( useRealValue )
- // {
- // result = precisionStr + "4x4( " + vecVal + ".x , " + vecVal + ".y , " + vecVal + ".z , 0 , " +
- // vecVal + ".x , " + vecVal + ".y , " + vecVal + ".z , 0 , " +
- // vecVal + ".x , " + vecVal + ".y , " + vecVal + ".z , 0 , " +
- // vecVal + ".x , " + vecVal + ".y , " + vecVal + ".z , 0 )";
- // }
- // else
- // {
- // string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, parameterName );
- // CurrentDataCollector.AddToLocalVariables( portCategory, -1, localVal );
- // result = precisionStr + "4x4( " + localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , 0 , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , 0 , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , 0 , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , 0 )";
- // }
- //}
- //break;
- }
- }
- break;
- case WirePortDataType.FLOAT4:
- {
- Vector4 vecVal = useRealValue ? (Vector4)value : Vector4.zero;
- switch( newType )
- {
- case WirePortDataType.OBJECT: result = useRealValue ? precisionStr + "4( " + vecVal.x + " , " + vecVal.y + " , " + vecVal.z + " , " + vecVal.w + " )" : parameterName; break;
- case WirePortDataType.FLOAT:
- {
- result = ( useRealValue ) ? vecVal.x.ToString() : parameterName + ".x";
- }
- break;
- case WirePortDataType.FLOAT2:
- {
- result = ( useRealValue ) ? precisionStr + "2( " + vecVal.x + " , " + vecVal.y + " )" : parameterName + ".xy";
- }
- break;
- case WirePortDataType.FLOAT3:
- {
- result = ( useRealValue ) ? precisionStr + "3( " + vecVal.x + " , " + vecVal.y + " , " + vecVal.z + " )" : parameterName + ".xyz";
- }
- break;
- //case WirePortDataType.FLOAT4x4:
- //{
- // if ( useRealValue )
- // {
- // result = precisionStr + "4x4( " + vecVal + ".x , " + vecVal + ".y , " + vecVal + ".z , " + vecVal + ".w , " +
- // vecVal + ".x , " + vecVal + ".y , " + vecVal + ".z , " + vecVal + ".w , " +
- // vecVal + ".x , " + vecVal + ".y , " + vecVal + ".z , " + vecVal + ".w , " +
- // vecVal + ".x , " + vecVal + ".y , " + vecVal + ".z , " + vecVal + ".w )";
- // }
- // else
- // {
- // string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, parameterName );
- // CurrentDataCollector.AddToLocalVariables( portCategory, -1, localVal );
- // result = precisionStr + "4x4( " + localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , " + localVarName + ".w , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , " + localVarName + ".w , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , " + localVarName + ".w , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , " + localVarName + ".w )";
- // }
- //}
- //break;
- case WirePortDataType.COLOR:
- {
- result = useRealValue ? precisionStr + "4( " + vecVal.x + " , " + vecVal.y + " , " + vecVal.z + " , " + vecVal.w + " )" : parameterName;
- }
- break;
- }
- }
- break;
- case WirePortDataType.FLOAT3x3:
- {
- //Matrix4x4 matrixVal = useRealValue ? ( Matrix4x4 ) value : Matrix4x4.identity;
- //switch ( newType )
- //{
- // case WirePortDataType.OBJECT:
- // case WirePortDataType.FLOAT4x4:
- // {
- // result = ( useRealValue ) ? precisionStr + "4x4(" + matrixVal.m00 + " , " + matrixVal.m01 + " , " + matrixVal.m02 + " , " + matrixVal.m03 + " , " +
- // matrixVal.m10 + " , " + matrixVal.m11 + " , " + matrixVal.m12 + " , " + matrixVal.m10 + " , " +
- // matrixVal.m20 + " , " + matrixVal.m21 + " , " + matrixVal.m22 + " , " + matrixVal.m20 + " , " +
- // matrixVal.m30 + " , " + matrixVal.m31 + " , " + matrixVal.m32 + " , " + matrixVal.m30 + " )" : precisionStr + "4x4(" + parameterName + ")";
- // }
- // break;
- //}
- }
- break;
- case WirePortDataType.FLOAT4x4:
- {
- Matrix4x4 matrixVal = useRealValue ? (Matrix4x4)value : Matrix4x4.identity;
- switch( newType )
- {
- case WirePortDataType.OBJECT:
- {
- result = ( useRealValue ) ? precisionStr + "4x4(" + matrixVal.m00 + " , " + matrixVal.m01 + " , " + matrixVal.m02 + " , " + matrixVal.m03 + " , " +
- matrixVal.m10 + " , " + matrixVal.m11 + " , " + matrixVal.m12 + " , " + matrixVal.m10 + " , " +
- matrixVal.m20 + " , " + matrixVal.m21 + " , " + matrixVal.m22 + " , " + matrixVal.m20 + " , " +
- matrixVal.m30 + " , " + matrixVal.m31 + " , " + matrixVal.m32 + " , " + matrixVal.m30 + " )" : parameterName;
- }
- break;
- }
- }
- break;
- case WirePortDataType.COLOR:
- {
- Color colorValue = ( useRealValue ) ? (Color)value : Color.black;
- switch( newType )
- {
- case WirePortDataType.OBJECT: result = useRealValue ? precisionStr + "4( " + colorValue.r + " , " + colorValue.g + " , " + colorValue.b + " , " + colorValue.a + " )" : parameterName; break;
- case WirePortDataType.FLOAT:
- {
- result = ( useRealValue ) ? colorValue.r.ToString() : parameterName + ".r";
- }
- break;
- case WirePortDataType.FLOAT2:
- {
- result = ( useRealValue ) ? precisionStr + "2( " + colorValue.r + " , " + colorValue.g + " )" : parameterName + ".rg";
- }
- break;
- case WirePortDataType.FLOAT3:
- {
- result = ( useRealValue ) ? precisionStr + "3( " + colorValue.r + " , " + colorValue.g + " , " + colorValue.b + " )" : parameterName + ".rgb";
- }
- break;
- case WirePortDataType.FLOAT4:
- {
- result = useRealValue ? precisionStr + "4( " + colorValue.r + " , " + colorValue.g + " , " + colorValue.b + " , " + colorValue.a + " )" : parameterName;
- }
- break;
- //case WirePortDataType.FLOAT4x4:
- //{
- // if ( useRealValue )
- // {
- // result = precisionStr + "4x4( " + colorValue.r + " , " + colorValue.g + " , " + colorValue.b + " , " + colorValue.a + " , " +
- // colorValue.r + " , " + colorValue.g + " , " + colorValue.b + " , " + colorValue.a + " , " +
- // colorValue.r + " , " + colorValue.g + " , " + colorValue.b + " , " + colorValue.a + " , " +
- // colorValue.r + " , " + colorValue.g + " , " + colorValue.b + " , " + colorValue.a + " )";
- // }
- // else
- // {
- // string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, parameterName );
- // CurrentDataCollector.AddToLocalVariables( portCategory, -1, localVal );
-
- // result = precisionStr + "4x4( " + localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , " + localVarName + ".w , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , " + localVarName + ".w , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , " + localVarName + ".w , " +
- // localVarName + ".x , " + localVarName + ".y , " + localVarName + ".z , " + localVarName + ".w )";
- // }
- //}
- //break;
- }
- }
- break;
- case WirePortDataType.INT:
- {
- switch( newType )
- {
- case WirePortDataType.OBJECT: result = useRealValue ? value.ToString() : parameterName; break;
- case WirePortDataType.FLOAT2:
- case WirePortDataType.FLOAT3:
- case WirePortDataType.COLOR:
- case WirePortDataType.FLOAT4:
- {
- string localVal = CreateLocalValueName( currentPrecision, newType, localVarName, ( ( useRealValue ) ? value.ToString() : parameterName ) );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, -1, localVal );
- result = localVarName;
- }
- break;
- case WirePortDataType.FLOAT3x3:
- {
- string localVal = CreateLocalValueName( currentPrecision, oldType, localVarName, ( ( useRealValue ) ? value.ToString() : parameterName ) );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, -1, localVal );
- result = localVarName;
- }
- break;
- case WirePortDataType.FLOAT4x4:
- {
- string localVal = CreateLocalValueName( currentPrecision, oldType, localVarName, ( ( useRealValue ) ? value.ToString() : parameterName ) );
- dataCollector.AddToLocalVariables( dataCollector.PortCategory, -1, localVal );
- result = localVarName;
- }
- break;
- case WirePortDataType.FLOAT:
- {
- result = ( useRealValue ) ? ( (int)value ).ToString() : "(float)" + parameterName;
- }
- break;
- }
- }
- break;
-
- }
- if( result.Equals( string.Empty ) )
- {
- result = "0";
- string warningStr = string.Format( "Unable to cast from {0} to {1}. Generating dummy data ( {2} )", oldType, newType, result );
-
- if( oldType == WirePortDataType.SAMPLER1D || oldType == WirePortDataType.SAMPLER2D || oldType == WirePortDataType.SAMPLER3D || oldType == WirePortDataType.SAMPLERCUBE )
- {
- warningStr = string.Format( "Unable to cast from {0} to {1}. You might want to use a Texture Sample node and connect it to the 'Tex' port. Generating dummy data ( {2} )", oldType, newType, result );
- }
- ShowMessage( warningStr, MessageSeverity.Warning );
- }
- return result;
- }
-
- public static bool CanCast( WirePortDataType from, WirePortDataType to )
- {
- if( from == WirePortDataType.OBJECT || to == WirePortDataType.OBJECT || from == to )
- return true;
-
- switch( from )
- {
- case WirePortDataType.FLOAT:
- {
- if( to == WirePortDataType.INT )
- return true;
- }
- break;
- case WirePortDataType.FLOAT2:
- {
- return false;
- }
- case WirePortDataType.FLOAT3:
- {
- if( to == WirePortDataType.COLOR ||
- to == WirePortDataType.FLOAT4 )
- return true;
- }
- break;
- case WirePortDataType.FLOAT4:
- {
- if( to == WirePortDataType.FLOAT3 ||
- to == WirePortDataType.COLOR )
- return true;
- }
- break;
- case WirePortDataType.FLOAT3x3:
- {
- if( to == WirePortDataType.FLOAT4x4 )
- return true;
- }
- break;
- case WirePortDataType.FLOAT4x4:
- {
- if( to == WirePortDataType.FLOAT3x3 )
- return true;
- }
- break;
- case WirePortDataType.COLOR:
- {
- if( to == WirePortDataType.FLOAT3 ||
- to == WirePortDataType.FLOAT4 )
- return true;
-
- }
- break;
- case WirePortDataType.INT:
- {
- if( to == WirePortDataType.FLOAT )
- return true;
- }
- break;
- }
-
- return false;
- }
-
- public static int GetChannelsAmount( WirePortDataType type )
- {
- switch( type )
- {
- case WirePortDataType.OBJECT: return 0;
- case WirePortDataType.FLOAT: return 1;
- case WirePortDataType.FLOAT2: return 2;
- case WirePortDataType.FLOAT3: return 3;
- case WirePortDataType.FLOAT4: return 4;
- case WirePortDataType.FLOAT3x3: return 9;
- case WirePortDataType.FLOAT4x4: return 16;
- case WirePortDataType.COLOR: return 4;
- case WirePortDataType.INT: return 1;
- case WirePortDataType.UINT: return 1;
- }
- return 0;
- }
-
- public static WirePortDataType GetWireTypeForChannelAmount( int channelAmount )
- {
- switch( channelAmount )
- {
- case 1: return WirePortDataType.FLOAT;
- case 2: return WirePortDataType.FLOAT2;
- case 3: return WirePortDataType.FLOAT3;
- case 4: return WirePortDataType.FLOAT4;
- case 9: return WirePortDataType.FLOAT3x3;
- case 16: return WirePortDataType.FLOAT4x4;
- }
- return WirePortDataType.FLOAT;
- }
-
- public static string GenerateUniformName( bool excludeUniformKeyword, WirePortDataType dataType, string dataName )
- {
- return GenerateUniformName( excludeUniformKeyword, WirePortToCgType( dataType ), dataName );
- }
-
- public static string GenerateUniformName( bool excludeUniformKeyword, string dataType, string dataName )
- {
- int index = excludeUniformKeyword ? 1 : 0;
- return string.Format( Constants.UniformDec[index], dataType, dataName );
- }
-
- public static string GeneratePropertyName( string name, PropertyType propertyType, bool forceUnderscore = false )
- {
- if( string.IsNullOrEmpty( name ) )
- return name;
-
- name = RemoveInvalidCharacters( name );
- if( propertyType != PropertyType.Global || forceUnderscore )
- {
- if( name[ 0 ] != '_' )
- {
- name = '_' + name;
- }
- }
-
- return name;
- }
-
- public static string UrlReplaceInvalidStrings( string originalString )
- {
- for( int i = 0; i < Constants.UrlReplacementStringValuesLen; i++ )
- {
- originalString = originalString.Replace( Constants.UrlReplacementStringValues[i,0], Constants.UrlReplacementStringValues[i,1] );
- }
- return originalString;
- }
-
- public static string ReplaceInvalidStrings( string originalString )
- {
- for(int i = 0; i< Constants.ReplacementStringValuesLen;i++ )
- {
- originalString = originalString.Replace( Constants.ReplacementStringValues[i,0], Constants.ReplacementStringValues[ i, 1 ] );
- }
- return originalString;
- }
-
- public static string RemoveWikiInvalidCharacters( string originalString )
- {
- for( int i = 0; i < Constants.WikiInvalidChars.Length; i++ )
- {
- originalString = originalString.Replace( Constants.WikiInvalidChars[ i ], string.Empty );
- }
- return originalString;
- }
-
- public static string RemoveInvalidEnumCharacters( string originalString )
- {
- for( int i = 0; i < Constants.EnumInvalidChars.Length; i++ )
- {
- originalString = originalString.Replace( Constants.EnumInvalidChars[ i ], string.Empty );
- }
- return originalString;
- }
-
- public static string RemoveInvalidAttrCharacters( string originalString )
- {
- for( int i = 0; i < Constants.AttrInvalidChars.Length; i++ )
- {
- originalString = originalString.Replace( Constants.AttrInvalidChars[ i ], string.Empty );
- }
- return originalString;
- }
-
- public static string RemoveInvalidCharacters( string originalString )
- {
- for( int i = 0; i < Constants.OverallInvalidChars.Length; i++ )
- {
- originalString = originalString.Replace( Constants.OverallInvalidChars[ i ], string.Empty );
- }
- return originalString;
- }
-
- public static string RemoveShaderInvalidCharacters( string originalString )
- {
- originalString = originalString.Replace( '\\', '/' );
- for( int i = 0; i < Constants.ShaderInvalidChars.Length; i++ )
- {
- originalString = originalString.Replace( Constants.ShaderInvalidChars[ i ], string.Empty );
- }
- return originalString;
- }
-
- public static bool IsUnityNativeShader( Shader shader )
- {
- string pathName = AssetDatabase.GetAssetPath( shader );
-
- if( pathName.Contains( "unity_builtin_extra") ||
- pathName.Contains( "unity default resources" ))
- return true;
-
- return false;
- }
- public static bool IsUnityNativeShader( string path ) { return m_unityNativeShaderPaths.ContainsKey( path ); }
-
- public static string GetComponentForPosition( int pos, WirePortDataType type, bool addDot = false )
- {
- string result = addDot ? "." : string.Empty;
- switch( pos )
- {
- case 0:
- {
- return ( ( type == WirePortDataType.COLOR ) ? ( result + "r" ) : ( result + "x" ) );
- }
- case 1:
- {
- return ( ( type == WirePortDataType.COLOR ) ? ( result + "g" ) : ( result + "y" ) );
- }
- case 2:
- {
- return ( ( type == WirePortDataType.COLOR ) ? ( result + "b" ) : ( result + "z" ) );
- }
- case 3:
- {
- return ( ( type == WirePortDataType.COLOR ) ? ( result + "a" ) : ( result + "w" ) );
- }
- }
- return string.Empty;
- }
-
- public static string InvalidParameter( ParentNode node )
- {
- ShowMessage( node.UniqueId, "Invalid entrance type on node" + node, MessageSeverity.Error );
- return "0";
- }
-
- public static string NoConnection( ParentNode node )
- {
- ShowMessage( node.UniqueId, "No Input connection on node" + node, MessageSeverity.Error );
- return "0";
- }
-
- public static string UnknownError( ParentNode node )
- {
- ShowMessage( node.UniqueId, "Unknown error on node" + node, MessageSeverity.Error );
- return "0";
- }
-
- public static string GetTex2DProperty( string name, TexturePropertyValues defaultValue ) { return name + "(\"" + name + "\", 2D) = \"" + defaultValue + "\" {}"; }
- public static string AddBrackets( string value ) { return "( " + value + " )"; }
- public static Color GetColorFromWireStatus( WireStatus status ) { return m_wireStatusToColor[ status ]; }
- public static bool HasColorCategory( string category ) { return m_nodeCategoryToColor.ContainsKey( category ); }
- public static void AddColorCategory( string category, Color color )
- {
- m_nodeCategoryToColor.Add( category, color );
- }
-
- public static Color AddColorCategory( string category, string hexColor )
- {
- try
- {
- Color color = new Color();
- ColorUtility.TryParseHtmlString( hexColor, out color );
- m_nodeCategoryToColor.Add( category, color );
- return color;
- }
- catch( System.Exception e )
- {
- Debug.LogException( e );
- }
- return m_nodeCategoryToColor[ "Default" ];
- }
-
- public static Color GetColorFromCategory( string category )
- {
- if( m_nodeCategoryToColor.ContainsKey( category ) )
- return m_nodeCategoryToColor[ category ];
-
-
- if(DebugConsoleWindow.DeveloperMode)
- Debug.LogWarning( category + " category does not contain an associated color" );
-
- return m_nodeCategoryToColor[ "Default" ];
- }
-
- public static string LatestOpenedFolder
- {
- get { return m_latestOpenedFolder; }
- set { m_latestOpenedFolder = value; }
- }
-
- public static Shader CreateNewUnlit()
- {
- if( CurrentWindow == null )
- return null;
-
- string shaderName;
- string pathName;
- Shader newShader = null;
- IOUtils.GetShaderName( out shaderName, out pathName, "MyUnlitShader", m_latestOpenedFolder );
- if( !System.String.IsNullOrEmpty( shaderName ) && !System.String.IsNullOrEmpty( pathName ) )
- {
- CurrentWindow.CreateNewGraph( shaderName );
- CurrentWindow.PreMadeShadersInstance.FlatColorSequence.Execute();
-
- CurrentWindow.CurrentGraph.CurrentMasterNode.SetName( shaderName );
- newShader = CurrentWindow.CurrentGraph.FireMasterNode( pathName, true );
- AssetDatabase.Refresh();
- }
- return newShader;
- }
-
- public static Shader CreateNewEmpty( string customPath = null , string customShaderName = null )
- {
- if( CurrentWindow == null )
- return null;
-
- string shaderName;
- string pathName;
- Shader newShader = null;
-
-
- string path = AssetDatabase.GetAssetPath( Selection.activeObject );
- if( path == "" )
- {
- path = "Assets";
- }
- else if( System.IO.Path.GetExtension( path ) != "" )
- {
- path = path.Replace( System.IO.Path.GetFileName( AssetDatabase.GetAssetPath( Selection.activeObject ) ), "" );
- }
-
-
- if( string.IsNullOrEmpty( customPath ) )
- {
- IOUtils.GetShaderName( out shaderName, out pathName, Constants.DefaultShaderName, m_latestOpenedFolder );
- }
- else
- {
- pathName = customPath;
- if( string.IsNullOrEmpty( customShaderName ) )
- {
- shaderName = Constants.DefaultShaderName;
- int indexOfAssets = pathName.IndexOf( "Assets" );
- string uniquePath = ( indexOfAssets > 0 ) ? pathName.Remove( 0, indexOfAssets ) : pathName;
- string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath( uniquePath + shaderName + ".shader" );
- pathName = assetPathAndName;
- shaderName = assetPathAndName.Remove( 0, assetPathAndName.IndexOf( shaderName ) );
- }
- else
- {
- shaderName = customShaderName;
- }
- shaderName = shaderName.Remove( shaderName.Length - 7 );
- }
- if( !System.String.IsNullOrEmpty( shaderName ) && !System.String.IsNullOrEmpty( pathName ) )
- {
- m_latestOpenedFolder = pathName;
-
- CurrentWindow.titleContent.text = AmplifyShaderEditorWindow.GenerateTabTitle( shaderName );
- CurrentWindow.titleContent.image = ShaderIcon;
- CurrentWindow.CreateNewGraph( shaderName );
- CurrentWindow.LastOpenedLocation = pathName;
- CurrentWindow.CurrentGraph.CurrentMasterNode.SetName( shaderName );
- newShader = CurrentWindow.CurrentGraph.FireMasterNode( pathName, true );
- AssetDatabase.Refresh();
- }
-
- return newShader;
- }
-
-
- public static Shader CreateNewEmptyTemplate( string templateGUID, string customPath = null, string customShaderName = null )
- {
- if( CurrentWindow == null )
- return null;
-
- string shaderName;
- string pathName;
- Shader newShader = null;
-
-
- string path = AssetDatabase.GetAssetPath( Selection.activeObject );
- if( path == "" )
- {
- path = "Assets";
- }
- else if( System.IO.Path.GetExtension( path ) != "" )
- {
- path = path.Replace( System.IO.Path.GetFileName( AssetDatabase.GetAssetPath( Selection.activeObject ) ), "" );
- }
-
-
- if( string.IsNullOrEmpty( customPath ) )
- {
- IOUtils.GetShaderName( out shaderName, out pathName, Constants.DefaultShaderName, m_latestOpenedFolder );
- }
- else
- {
- pathName = customPath;
- if( string.IsNullOrEmpty( customShaderName ) )
- {
- shaderName = Constants.DefaultShaderName;
- int indexOfAssets = pathName.IndexOf( "Assets" );
- string uniquePath = ( indexOfAssets > 0 ) ? pathName.Remove( 0, indexOfAssets ) : pathName;
- string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath( uniquePath + shaderName + ".shader" );
- pathName = assetPathAndName;
- shaderName = assetPathAndName.Remove( 0, assetPathAndName.IndexOf( shaderName ) );
- }
- else
- {
- shaderName = customShaderName;
- }
- shaderName = shaderName.Remove( shaderName.Length - 7 );
- }
- if( !System.String.IsNullOrEmpty( shaderName ) && !System.String.IsNullOrEmpty( pathName ) )
- {
- m_latestOpenedFolder = pathName;
-
- CurrentWindow.titleContent.text = AmplifyShaderEditorWindow.GenerateTabTitle( shaderName );
- CurrentWindow.titleContent.image = UIUtils.ShaderIcon;
- CurrentWindow.CreateNewTemplateGraph( templateGUID );
- CurrentWindow.CurrentGraph.CurrentMasterNode.SetName( shaderName );
- newShader = CurrentWindow.CurrentGraph.FireMasterNode( pathName, true );
- AssetDatabase.Refresh();
- }
-
- return newShader;
- }
-
-
- public static void SetDelayedMaterialMode( Material material )
- {
- if( CurrentWindow == null )
- return;
- CurrentWindow.SetDelayedMaterialMode( material );
- }
-
- public static void CreateEmptyFromInvalid( Shader shader )
- {
- if( CurrentWindow == null )
- return;
-
- CurrentWindow.CreateNewGraph( shader );
- CurrentWindow.ForceRepaint();
- }
-
- public static void CreateEmptyFunction( AmplifyShaderFunction shaderFunction )
- {
- if( CurrentWindow == null )
- return;
-
- CurrentWindow.CreateNewFunctionGraph( shaderFunction );
- CurrentWindow.SaveToDisk( false );
- CurrentWindow.ForceRepaint();
- }
-
- public static void DrawFloat( UndoParentNode owner, ref Rect propertyDrawPos, ref float value, float newLabelWidth = 8 )
- {
- float labelWidth = EditorGUIUtility.labelWidth;
- EditorGUIUtility.labelWidth = newLabelWidth;
- value = owner.EditorGUIFloatField( propertyDrawPos, " ", value, UIUtils.MainSkin.textField );
- EditorGUIUtility.labelWidth = labelWidth;
- }
-
- public static GUIStyle GetCustomStyle( CustomStyle style )
- {
- return ( Initialized ) ? MainSkin.customStyles[ (int)style ] : null;
- }
-
- public static void SetCustomStyle( CustomStyle style, GUIStyle guiStyle )
- {
- if( MainSkin != null )
- MainSkin.customStyles[ (int)style ] = new GUIStyle( guiStyle );
- }
-
- public static void OpenFile()
- {
- if( CurrentWindow == null )
- return;
- string newShader = EditorUtility.OpenFilePanel( "Select Shader to open", m_latestOpenedFolder, "shader" );
- if( !System.String.IsNullOrEmpty( newShader ) )
- {
- m_latestOpenedFolder = newShader.Substring( 0, newShader.LastIndexOf( '/' ) + 1 );
- int relFilenameId = newShader.IndexOf( Application.dataPath );
- if( relFilenameId > -1 )
- {
- string relFilename = newShader.Substring( relFilenameId + Application.dataPath.Length - 6 );// -6 need to also copy the assets/ part
- CurrentWindow.LoadFromDisk( relFilename );
- }
- else
- {
- ShowMessage( "Can only load shaders\nfrom inside the projects folder", MessageSeverity.Error );
- }
- }
- }
-
- public static bool DetectNodeLoopsFrom( ParentNode node, Dictionary<int, int> currentNodes )
- {
- for( int i = 0; i < node.InputPorts.Count; i++ )
- {
- if( node.InputPorts[ i ].IsConnected )
- {
- ParentNode newNode = node.InputPorts[ i ].GetOutputNode();
- if( !currentNodes.ContainsKey( newNode.UniqueId ) )
- RecursiveNodeFill( newNode, currentNodes );
- }
- }
-
- bool found = currentNodes.ContainsKey( node.UniqueId );
- currentNodes.Clear();
- currentNodes = null;
-
- return found;
- }
-
- private static void RecursiveNodeFill( ParentNode node, Dictionary<int, int> currentNodes )
- {
- if( !currentNodes.ContainsKey( node.UniqueId ) )
- currentNodes.Add( node.UniqueId, 1 );
-
- for( int i = 0; i < node.InputPorts.Count; i++ )
- {
- if( node.InputPorts[ i ].IsConnected )
- {
- ParentNode newNode = node.InputPorts[ i ].GetOutputNode();
- if( !currentNodes.ContainsKey( newNode.UniqueId ) )
- RecursiveNodeFill( newNode, currentNodes );
- }
- }
- }
-
- public static ParentNode CreateNode( System.Type type, bool registerUndo, Vector2 pos, int nodeId = -1, bool addLast = true )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.CurrentGraph.CreateNode( type, registerUndo, pos, nodeId, addLast );
- }
- return null;
- }
-
- public static void DestroyNode( int nodeId )
- {
- if( CurrentWindow != null )
- {
- CurrentWindow.CurrentGraph.DestroyNode( nodeId );
- }
- }
-
- public static void ShowMessage( int ownerId, string message, MessageSeverity severity = MessageSeverity.Normal, bool registerTimestamp = true )
- {
- if( CurrentWindow != null )
- {
- CurrentWindow.ShowMessage( ownerId, message, severity, registerTimestamp );
- }
- }
-
- public static void ShowMessage( string message, MessageSeverity severity = MessageSeverity.Normal, bool registerTimestamp = true )
- {
- if( CurrentWindow != null )
- {
- CurrentWindow.ShowMessage( message, severity, registerTimestamp );
- }
- }
-
- public static ParentNode GetNode( int nodeId )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.CurrentGraph.GetNode( nodeId );
- }
- return null;
- }
-
- public static PropertyNode GetInternalTemplateNode( int nodeId )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.CurrentGraph.GetInternalTemplateNode( nodeId );
- }
- return null;
- }
-
- public static PropertyNode GetInternalTemplateNode( string propertyName )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.CurrentGraph.GetInternalTemplateNode( propertyName );
- }
- return null;
- }
-
-
- public static void DeleteConnection( bool isInput, int nodeId, int portId, bool registerOnLog, bool propagateCallback )
- {
- if( CurrentWindow != null )
- {
- CurrentWindow.DeleteConnection( isInput, nodeId, portId, registerOnLog, propagateCallback );
- }
- }
-
- public static void ConnectInputToOutput( int inNodeId, int inPortId, int outNodeId, int outPortId )
- {
- if( CurrentWindow != null )
- {
- CurrentWindow.ConnectInputToOutput( inNodeId, inPortId, outNodeId, outPortId );
- }
- }
-
- public static Shader CreateNewGraph( string name )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.CreateNewGraph( name );
- }
- return null;
- }
- public static void SetConnection( int InNodeId, int InPortId, int OutNodeId, int OutPortId )
- {
- if( CurrentWindow != null )
- {
- CurrentWindow.CurrentGraph.SetConnection( InNodeId, InPortId, OutNodeId, OutPortId );
- }
- }
-
- public static bool IsChannelAvailable( int channelId )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.IsChannelAvailable( channelId );
- }
- return false;
- }
-
- public static bool ReleaseUVChannel( int nodeId, int channelId )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.ReleaseUVChannel( nodeId, channelId );
- }
- return false;
- }
-
- public static bool RegisterUVChannel( int nodeId, int channelId, string name )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.RegisterUVChannel( nodeId, channelId, name );
- }
- return false;
- }
-
- public static void GetFirstAvailableName( int nodeId, WirePortDataType type, out string outProperty, out string outInspector, bool useCustomPrefix = false, string customPrefix = null )
- {
- outProperty = string.Empty;
- outInspector = string.Empty;
- if( CurrentWindow != null )
- {
- CurrentWindow.DuplicatePrevBufferInstance.GetFirstAvailableName( nodeId, type, out outProperty, out outInspector, useCustomPrefix, customPrefix );
- }
- }
-
-
- public static bool IsNumericName( string name )
- {
- Match match = Regex.Match( name, NumericNamePattern );
- if( match != null && match.Success )
- return true;
- return false;
- }
-
- public static bool CheckInvalidUniformName( string name )
- {
- if( m_reservedPropertyNames.ContainsKey( name ) )
- {
- ShowMessage( string.Format( Constants.ReservedPropertyNameStr, name ) );
- return true;
- }
-
- if( IsNumericName( name ))
- {
- ShowMessage( string.Format( Constants.NumericPropertyNameStr, name ) );
- return true;
- }
-
- return false;
- }
-
- public static bool RegisterUniformName( int nodeId, string name )
- {
- if( CheckInvalidUniformName( name ) )
- {
- return false;
- }
-
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.RegisterUniformName( nodeId, name );
- }
- return false;
- }
-
- public static bool ReleaseUniformName( int nodeId, string name )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.ReleaseUniformName( nodeId, name );
- }
- return false;
- }
-
- public static bool IsUniformNameAvailable( string name )
- {
- if( CheckInvalidUniformName( name ) )
- {
- return false;
- }
-
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.IsUniformNameAvailable( name );
- }
- return false;
- }
-
- public static int CheckUniformNameOwner( string name )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.CheckUniformNameOwner( name );
- }
- return -1;
- }
-
- public static string GetUniqueUniformName( string name )
- {
- int num = 0;
- Regex reg = new Regex( @"([0-9]+)$" );
- Match match = reg.Match( name );
- if( match.Success )
- {
- string s = match.Groups[ 1 ].Captures[ 0 ].Value;
- num = int.Parse( s );
- name = name.Replace( s, "" );
- }
-
- for( int i = num + 1; i < 1000; i++ )
- {
- string testName = name + i;
-
- if( CheckInvalidUniformName( testName ) )
- {
- continue;
- }
-
- if( CurrentWindow != null )
- {
- if( CurrentWindow.DuplicatePrevBufferInstance.IsUniformNameAvailable( testName ) )
- {
- return testName;
- }
- }
- }
- return name;
- }
-
- public static bool RegisterLocalVariableName( int nodeId, string name )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.RegisterLocalVariableName( nodeId, name );
- }
- return false;
- }
-
- public static bool ReleaseLocalVariableName( int nodeId, string name )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.ReleaseLocalVariableName( nodeId, name );
- }
- return false;
- }
-
- public static bool IsLocalvariableNameAvailable( string name )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.IsLocalvariableNameAvailable( name );
- }
- return false;
- }
-
- public static string GetChannelName( int channelId )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.GetChannelName( channelId );
- }
- return string.Empty;
- }
-
- public static void SetChannelName( int channelId, string name )
- {
- if( CurrentWindow != null )
- {
- CurrentWindow.DuplicatePrevBufferInstance.SetChannelName( channelId, name );
- }
- }
-
- public static int RegisterFirstAvailableChannel( int nodeId, string name )
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.DuplicatePrevBufferInstance.RegisterFirstAvailableChannel( nodeId, name );
- }
- return -1;
- }
-
- public static int PortCategorytoAttayIdx( MasterNodePortCategory category )
- {
- if( m_portCategoryToArrayIdx.ContainsKey( category ))
- return m_portCategoryToArrayIdx[category];
-
- return m_portCategoryToArrayIdx[ MasterNodePortCategory.Fragment ];
- }
-
- public static bool DisplayDialog( string shaderPath )
- {
- string value = System.String.Format( "Save changes to the shader {0} before closing?", shaderPath );
- return EditorUtility.DisplayDialog( "Load selected", value, "Yes", "No" );
- }
-
- public static void ForceUpdateFromMaterial()
- {
- if( CurrentWindow != null )
- {
- // CurrentWindow.Focus();
- CurrentWindow.ForceUpdateFromMaterial();
- }
- }
-
- public static void MarkToRepaint() { if( CurrentWindow != null ) CurrentWindow.MarkToRepaint(); }
- public static void RequestSave() { if( CurrentWindow != null ) CurrentWindow.RequestSave(); }
- public static string FloatToString( float value )
- {
- string floatStr = value.ToString();
- if( value % 1 == 0 )
- {
- floatStr += ".0";
- }
- return floatStr;
- }
-
- public static int CurrentShaderVersion()
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.CurrentGraph.LoadedShaderVersion;
- }
- return -1;
- }
-
- public static bool IsProperty( PropertyType type ) { return ( type == PropertyType.Property || type == PropertyType.InstancedProperty ); }
-
- public static MasterNode CurrentMasterNode()
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.CurrentGraph.CurrentMasterNode;
- }
- return null;
- }
-
- public static void AddVirtualTextureCount() { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.AddVirtualTextureCount(); } }
-
- public static bool HasVirtualTexture()
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.CurrentGraph.HasVirtualTexture;
- }
- return false;
- }
-
- public static void RemoveVirtualTextureCount() { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.RemoveVirtualTextureCount(); } }
-
- //public static void AddInstancePropertyCount() { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.AddInstancePropertyCount(); } }
-
- public static bool IsInstancedShader()
- {
- if( CurrentWindow != null )
- {
- return CurrentWindow.CurrentGraph.IsInstancedShader;
- }
- return false;
- }
-
- //public static void RemoveInstancePropertyCount() { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.RemoveInstancePropertyCount(); } }
- //public static void AddNormalDependentCount() { if ( CurrentWindow != null ) { CurrentWindow.CurrentGraph.AddNormalDependentCount(); } }
- //public static void RemoveNormalDependentCount() { if ( CurrentWindow != null ) { CurrentWindow.CurrentGraph.RemoveNormalDependentCount(); } }
- //public static bool IsNormalDependent()
- //{
- // if ( CurrentWindow != null )
- // {
- // return CurrentWindow.CurrentGraph.IsNormalDependent;
- // }
- // return false;
- //}
-
- public static void CopyValuesFromMaterial( Material mat )
- {
- if( CurrentWindow != null && CurrentWindow.CurrentMaterial == mat )
- {
- CurrentWindow.CurrentGraph.CopyValuesFromMaterial( mat );
- }
- else
- {
- int aseWindowCount = IOUtils.AllOpenedWindows.Count;
- for( int i = 0; i < aseWindowCount; i++ )
- {
- if( IOUtils.AllOpenedWindows[ i ] != m_currentWindow && IOUtils.AllOpenedWindows[ i ].CurrentMaterial == mat )
- {
- IOUtils.AllOpenedWindows[ i ].CurrentGraph.CopyValuesFromMaterial( mat );
- break;
- }
- }
- }
- }
-
- // Sampler Node
- public static void RegisterSamplerNode( SamplerNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.SamplerNodes.AddNode( node ); } }
- public static void UnregisterSamplerNode( SamplerNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.SamplerNodes.RemoveNode( node ); } }
- public static string[] SamplerNodeArr() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.SamplerNodes.NodesArr; } return null; }
- public static SamplerNode GetSamplerNode( int idx ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.SamplerNodes.GetNode( idx ); } return null; }
- public static void UpdateSamplerDataNode( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.SamplerNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static int GetSamplerNodeRegisterId( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.SamplerNodes.GetNodeRegisterIdx( uniqueId ); } return -1; }
- public static int GetSamplerNodeAmount() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.SamplerNodes.NodesList.Count; } return -1; }
-
- // Float Node
- public static void RegisterFloatIntNode( PropertyNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FloatIntNodes.AddNode( node ); } }
- public static void UnregisterFloatIntNode( PropertyNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FloatIntNodes.RemoveNode( node ); } }
- public static string[] FloatIntNodeArr() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FloatIntNodes.NodesArr; } return null; }
- public static int[] FloatIntNodeIds() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FloatIntNodes.NodeIds; } return null; }
- public static PropertyNode GetFloatIntNode( int idx ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FloatIntNodes.GetNode( idx ); } return null; }
- public static void UpdateFloatIntDataNode( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FloatIntNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static int GetFloatIntNodeRegisterId( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FloatIntNodes.GetNodeRegisterIdx( uniqueId ); } return -1; }
- public static int GetNodeIdByName( string name )
- {
- if( CurrentWindow != null )
- {
- UsageListFloatIntNodes list = CurrentWindow.CurrentGraph.FloatIntNodes;
- int count = list.Count;
- for( int i = 0; i < count; i++ )
- {
- if( list.NodesList[ i ].PropertyName.Equals( name ) )
- return list.NodesList[ i ].UniqueId;
- }
- }
- return -1;
- }
- public static PropertyNode GetFloatIntNodeByUniqueId( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FloatIntNodes.GetNodeByUniqueId( uniqueId ); } return null; }
- //public static int GetFloatNodeAmount() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FloatNodes.NodesList.Count; } return -1; }
-
- // Texture Property
- public static void RegisterTexturePropertyNode( TexturePropertyNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.TexturePropertyNodes.AddNode( node ); } }
- public static void UnregisterTexturePropertyNode( TexturePropertyNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.TexturePropertyNodes.RemoveNode( node ); } }
- public static string[] TexturePropertyNodeArr() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.TexturePropertyNodes.NodesArr; } return null; }
- public static TexturePropertyNode GetTexturePropertyNode( int idx ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.TexturePropertyNodes.GetNode( idx ); } return null; }
- public static void UpdateTexturePropertyDataNode( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.TexturePropertyNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static int GetTexturePropertyNodeRegisterId( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.TexturePropertyNodes.GetNodeRegisterIdx( uniqueId ); } return -1; }
- public static int GetTexturePropertyNodeAmount() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.TexturePropertyNodes.NodesList.Count; } return -1; }
-
- // Texture Array
- public static void RegisterTextureArrayNode( TextureArrayNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.TextureArrayNodes.AddNode( node ); } }
- public static void UnregisterTextureArrayNode( TextureArrayNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.TextureArrayNodes.RemoveNode( node ); } }
- public static string[] TextureArrayNodeArr() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.TextureArrayNodes.NodesArr; } return null; }
- public static TextureArrayNode GetTextureArrayNode( int idx ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.TextureArrayNodes.GetNode( idx ); } return null; }
- public static void UpdateTextureArrayDataNode( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.TextureArrayNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static int GetTextureArrayNodeRegisterId( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.TextureArrayNodes.GetNodeRegisterIdx( uniqueId ); } return -1; }
- public static int GetTextureArrayNodeAmount() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.TextureArrayNodes.NodesList.Count; } return -1; }
-
- // Raw Property Node
- public static void RegisterRawPropertyNode( PropertyNode node ) { if( CurrentWindow != null ) { CurrentWindow.OutsideGraph.RawPropertyNodes.AddNode( node ); } }
- public static void UnregisterRawPropertyNode( PropertyNode node ) { if( CurrentWindow != null ) { CurrentWindow.OutsideGraph.RawPropertyNodes.RemoveNode( node ); } }
-
- // Property Node
- public static void RegisterPropertyNode( PropertyNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.PropertyNodes.AddNode( node ); } }
- public static void UnregisterPropertyNode( PropertyNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.PropertyNodes.RemoveNode( node ); } }
- public static string[] PropertyNodeNodeArr() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.PropertyNodes.NodesArr; } return null; }
- public static PropertyNode GetPropertyNode( int idx ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.PropertyNodes.GetNode( idx ); } return null; }
- public static PropertyNode GetPropertyNodeByUniqueId( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.PropertyNodes.GetNodeByUniqueId( uniqueId ); } return null; }
- public static void UpdatePropertyDataNode( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.PropertyNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static int GetPropertyNodeRegisterId( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.PropertyNodes.GetNodeRegisterIdx( uniqueId ); } return -1; }
- public static List<PropertyNode> PropertyNodesList() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.PropertyNodes.NodesList; } return null; }
- public static int GetPropertyNodeAmount() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.PropertyNodes.NodesList.Count; } return -1; }
-
- // Function Inputs
- public static void RegisterFunctionInputNode( FunctionInput node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionInputNodes.AddNode( node ); } }
- public static void UnregisterFunctionInputNode( FunctionInput node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionInputNodes.RemoveNode( node ); } }
- public static void UpdateFunctionInputData( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionInputNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static List<FunctionInput> FunctionInputList() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FunctionInputNodes.NodesList; } return null; }
-
- // Function Nodes
- public static void RegisterFunctionNode( FunctionNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionNodes.AddNode( node ); } }
- public static void UnregisterFunctionNode( FunctionNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionNodes.RemoveNode( node ); } }
- public static void UpdateFunctionData( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static List<FunctionNode> FunctionList() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FunctionNodes.NodesList; } return null; }
-
- // Function Outputs
- public static void RegisterFunctionOutputNode( FunctionOutput node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionOutputNodes.AddNode( node ); } }
- public static void UnregisterFunctionOutputNode( FunctionOutput node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionOutputNodes.RemoveNode( node ); } }
- public static void UpdateFunctionOutputData( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionOutputNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static List<FunctionOutput> FunctionOutputList() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FunctionOutputNodes.NodesList; } return null; }
-
- // Function Switches Copy
- public static void RegisterFunctionSwitchCopyNode( FunctionSwitch node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionSwitchCopyNodes.AddNode( node ); } }
- public static void UnregisterFunctionSwitchCopyNode( FunctionSwitch node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionSwitchCopyNodes.RemoveNode( node ); } }
- public static void UpdateFunctionSwitchCopyData( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionSwitchCopyNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static List<FunctionSwitch> FunctionSwitchCopyList() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FunctionSwitchCopyNodes.NodesList; } return null; }
-
- // Function Switches
- public static void RegisterFunctionSwitchNode( FunctionSwitch node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionSwitchNodes.AddNode( node ); } }
- public static void UnregisterFunctionSwitchNode( FunctionSwitch node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionSwitchNodes.RemoveNode( node ); } }
- public static void UpdateFunctionSwitchData( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionSwitchNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static List<FunctionSwitch> FunctionSwitchList() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FunctionSwitchNodes.NodesList; } return null; }
- public static void UpdateFunctionSwitchArr() { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.FunctionSwitchNodes.UpdateNodeArr(); } }
- public static string[] FunctionSwitchesNodeArr() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FunctionSwitchNodes.NodesArr; } return null; }
- public static FunctionSwitch GetFunctionSwitchNode( int idx ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FunctionSwitchNodes.GetNode( idx ); } return null; }
- public static int GetFunctionSwitchNodeIndex( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.FunctionSwitchNodes.GetNodeRegisterIdx( uniqueId ); } return -1; }
-
- // Screen Color Node
- public static void RegisterScreenColorNode( ScreenColorNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.ScreenColorNodes.AddNode( node ); } }
- public static void UnregisterScreenColorNode( ScreenColorNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.ScreenColorNodes.RemoveNode( node ); } }
- public static string[] ScreenColorNodeArr() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.ScreenColorNodes.NodesArr; } return null; }
- public static ScreenColorNode GetScreenColorNode( int idx ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.ScreenColorNodes.GetNode( idx ); } return null; }
- public static int GetScreenColorNodeRegisterId( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.ScreenColorNodes.GetNodeRegisterIdx( uniqueId ); } return -1; }
- public static void UpdateScreenColorDataNode( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.ScreenColorNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static int GetScreenColorNodeAmount() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.ScreenColorNodes.NodesList.Count; } return -1; }
-
- // Local Var Node
- public static int RegisterLocalVarNode( RegisterLocalVarNode node ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.LocalVarNodes.AddNode( node ); } return -1; }
- public static void UnregisterLocalVarNode( RegisterLocalVarNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.LocalVarNodes.RemoveNode( node ); } }
- public static string[] LocalVarNodeArr() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.LocalVarNodes.NodesArr; } return null; }
- public static int LocalVarNodeAmount() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.LocalVarNodes.NodesList.Count; } return 0; }
- public static int GetLocalVarNodeRegisterId( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.LocalVarNodes.GetNodeRegisterIdx( uniqueId ); } return -1; }
- public static RegisterLocalVarNode GetLocalVarNode( int idx ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.LocalVarNodes.GetNode( idx ); } return null; }
- public static void UpdateLocalVarDataNode( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.LocalVarNodes.UpdateDataOnNode( uniqueId, data ); } }
-
- //Global Array
- public static void RegisterGlobalArrayNode( GlobalArrayNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.GlobalArrayNodes.AddNode( node ); } }
- public static void UnregisterGlobalArrayNode( GlobalArrayNode node ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.GlobalArrayNodes.RemoveNode( node ); } }
- public static string[] GlobalArrayNodeArr() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.GlobalArrayNodes.NodesArr; } return null; }
- public static GlobalArrayNode GetGlobalArrayNode( int idx ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.GlobalArrayNodes.GetNode( idx ); } return null; }
- public static int GetGlobalArrayNodeRegisterId( int uniqueId ) { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.GlobalArrayNodes.GetNodeRegisterIdx( uniqueId ); } return -1; }
- public static void UpdateGlobalArrayDataNode( int uniqueId, string data ) { if( CurrentWindow != null ) { CurrentWindow.CurrentGraph.GlobalArrayNodes.UpdateDataOnNode( uniqueId, data ); } }
- public static int GetGlobalArrayNodeAmount() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.GlobalArrayNodes.NodesList.Count; } return -1; }
-
-
- public static void FocusOnNode( ParentNode node, float zoom, bool selectNode ) { if( CurrentWindow != null ) { CurrentWindow.FocusOnNode( node, zoom, selectNode ); } }
- public static PrecisionType CurrentPrecision() { if( CurrentWindow != null ) { return CurrentWindow.CurrentGraph.CurrentPrecision; } return PrecisionType.Float; }
- public static string CurrentPrecisionCg() { if( CurrentWindow != null ) { return m_precisionTypeToCg[ CurrentWindow.CurrentGraph.CurrentPrecision ]; } return m_precisionTypeToCg[ PrecisionType.Float ]; }
-
- public static PrecisionType GetFinalPrecision( PrecisionType precision )
- {
- if( CurrentWindow != null && CurrentWindow.CurrentGraph != null )
- {
- PrecisionType mainPrecision = CurrentWindow.CurrentGraph.CurrentPrecision;
- if( (int)mainPrecision > (int)precision )
- return mainPrecision;
- }
- return precision;
- }
-
- public static bool GetNodeAvailabilityInBitArray( int bitArray, NodeAvailability availability ) { return ( bitArray & (int)availability ) != 0; }
- public static bool GetCategoryInBitArray( int bitArray, MasterNodePortCategory category ) { return ( bitArray & (int)category ) != 0; }
- public static void SetCategoryInBitArray( ref int bitArray, MasterNodePortCategory category ) { bitArray = bitArray | (int)category; }
-
- public static int GetPriority( WirePortDataType type ) { return m_portPriority[ type ]; }
-
- public static void ShowIncompatiblePortMessage( bool fromInput, ParentNode inNode, WirePort inPort, ParentNode outNode, WirePort outPort )
- {
- string inPortName = inPort.Name.Equals( Constants.EmptyPortValue ) ? inPort.PortId.ToString() : inPort.Name;
- string outPortName = outPort.Name.Equals( Constants.EmptyPortValue ) ? outPort.PortId.ToString() : outPort.Name;
- ShowMessage( outNode.UniqueId, string.Format( ( fromInput ? IncorrectInputConnectionErrorMsg : IncorrectOutputConnectionErrorMsg ), inPortName, inNode.Attributes.Name, inPort.DataType, outPort.DataType, outPortName, outNode.Attributes.Name ) );
- }
-
- public static void ShowNoVertexModeNodeMessage( ParentNode node )
- {
- ShowMessage( node.UniqueId, string.Format( NoVertexModeNodeWarning, node.Attributes.Name ), MessageSeverity.Warning );
- }
-
- public static int TotalExampleMaterials { get { return m_exampleMaterialIDs.Count; } }
-
- public static int ShaderIndentLevel
- {
- get { return m_shaderIndentLevel; }
- set
- {
- m_shaderIndentLevel = Mathf.Max( value, 0 );
- m_shaderIndentTabs = string.Empty;
- for( int i = 0; i < m_shaderIndentLevel; i++ ) { m_shaderIndentTabs += "\t"; }
- }
- }
-
- public static string ShaderIndentTabs { get { return m_shaderIndentTabs; } }
- public static void AddLineToShaderBody( ref string ShaderBody, string line ) { ShaderBody += m_shaderIndentTabs + line; }
- public static void AddMultiLineToShaderBody( ref string ShaderBody, string[] lines )
- {
- for( int i = 0; i < lines.Length; i++ )
- {
- ShaderBody += m_shaderIndentTabs + lines[ i ];
- }
- }
-
- public static void ClearUndoHelper()
- {
- m_undoHelper.Clear();
- }
-
- public static bool CheckUndoNode( ParentNode node )
- {
- if( node == null )
- return false;
- if( m_undoHelper.ContainsKey( node.UniqueId ) )
- {
- return false;
- }
-
- m_undoHelper.Add( node.UniqueId, node );
- EditorUtility.SetDirty( node );
- return true;
- }
-
- public static void MarkUndoAction()
- {
- SerializeHelperCounter = 2;
- }
-
- public static bool SerializeFromUndo()
- {
- if( SerializeHelperCounter > 0 )
- {
- SerializeHelperCounter--;
- return true;
- }
- return false;
- }
-
- public static int GetKeywordId( string keyword )
- {
- if( AvailableKeywordsDict.Count != AvailableKeywords.Length )
- {
- AvailableKeywordsDict.Clear();
- for( int i = 1; i < AvailableKeywords.Length; i++ )
- {
- AvailableKeywordsDict.Add( AvailableKeywords[ i ], i );
- }
- }
-
- if( AvailableKeywordsDict.ContainsKey( keyword ) )
- {
- return AvailableKeywordsDict[ keyword ];
- }
-
- return 0;
- }
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UIUtils.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UIUtils.cs.meta
deleted file mode 100644
index 91858515..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UIUtils.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 23e0210afe076544ca92d761094a9119
-timeCreated: 1481126954
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UndoUtils.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UndoUtils.cs
deleted file mode 100644
index d7b35d30..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UndoUtils.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using UnityEditor;
-using UnityEngine;
-using UnityEngine.Internal;
-using System;
-
-namespace AmplifyShaderEditor
-{
- public class UndoUtils
- {
-
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UndoUtils.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UndoUtils.cs.meta
deleted file mode 100644
index e4ad8c01..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UndoUtils.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 89dee7566d97f1847b9fe114e1c9a1a2
-timeCreated: 1489603190
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UpperLeftWidgetHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UpperLeftWidgetHelper.cs
deleted file mode 100644
index 9e92fe2d..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UpperLeftWidgetHelper.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using UnityEngine;
-using UnityEditor;
-
-namespace AmplifyShaderEditor
-{
- public class UpperLeftWidgetHelper
- {
- public int DrawWidget( ParentNode owner, int selectedIndex, GUIContent[] displayedOptions )
- {
- if( owner.DropdownEditing )
- {
- int newValue = owner.EditorGUIPopup( owner.DropdownRect, selectedIndex, displayedOptions, UIUtils.PropertyPopUp );
- if( newValue != selectedIndex )
- {
- owner.DropdownEditing = false;
- }
- return newValue;
- }
- return selectedIndex;
- }
-
- public int DrawWidget( ParentNode owner, int selectedIndex, string[] displayedOptions )
- {
- if( owner.DropdownEditing )
- {
- int newValue = owner.EditorGUIPopup( owner.DropdownRect, selectedIndex, displayedOptions, UIUtils.PropertyPopUp );
- if( newValue != selectedIndex )
- {
- owner.DropdownEditing = false;
- }
- return newValue;
- }
- return selectedIndex;
- }
-
- public int DrawWidget( ParentNode owner, int selectedIndex, string[] displayedOptions, int[] optionValues )
- {
- if( owner.DropdownEditing )
- {
- int newValue = owner.EditorGUIIntPopup( owner.DropdownRect, selectedIndex, displayedOptions, optionValues, UIUtils.PropertyPopUp );
- if( newValue != selectedIndex )
- {
- owner.DropdownEditing = false;
- }
- return newValue;
- }
- return selectedIndex;
- }
-
- // GC free version
- public void DrawWidget<TEnum>( ref TEnum selectedIndex, ParentNode owner, Action<ParentNode> callback ) where TEnum : struct
- {
- if( owner.DropdownEditing )
- {
- Enum asEnumType = selectedIndex as Enum;
- if( asEnumType != null )
- {
- EditorGUI.BeginChangeCheck();
- selectedIndex = ( owner.EditorGUIEnumPopup( owner.DropdownRect, asEnumType, UIUtils.PropertyPopUp ) as TEnum? ).Value;
- if( EditorGUI.EndChangeCheck() )
- {
- owner.DropdownEditing = false;
- if( callback != null )
- callback( owner );
- }
- }
- }
- }
-
- /*
- * USE THIS OVERRIDE IN CASE THE NODE DOESN'T HAVE PREVIEW
- */
- //public override void AfterCommonInit()
- //{
- // base.AfterCommonInit();
- // if( PaddingTitleLeft == 0 )
- // {
- // PaddingTitleLeft = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
- // if( PaddingTitleRight == 0 )
- // PaddingTitleRight = Constants.PropertyPickerWidth + Constants.IconsLeftRightMargin;
- // }
- //}
-
-
- /*
- * USE THE SOURCE CODE BELOW INTO THE NODE YOU WANT THE WIDGET TO SHOW
- */
- //private UpperLeftWidgetHelper m_upperLeftWidget = new UpperLeftWidgetHelper();
- }
-}
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UpperLeftWidgetHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UpperLeftWidgetHelper.cs.meta
deleted file mode 100644
index 6e110525..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/UpperLeftWidgetHelper.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 32dbececad3a67a4fbde694ae50ce82c
-timeCreated: 1504080603
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowHelper.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowHelper.cs
deleted file mode 100644
index 7b8972b4..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowHelper.cs
+++ /dev/null
@@ -1,250 +0,0 @@
-#if UNITY_EDITOR
-using System;
-using System.Reflection;
-using UnityEditor;
-using UnityEngine;
-
-public static class WindowHelper
-{
- private class R_EditorWindow
- {
- private EditorWindow m_instance;
- private System.Type m_type;
-
- public R_EditorWindow( EditorWindow instance )
- {
- m_instance = instance;
- m_type = instance.GetType();
- }
-
- public object Parent
- {
- get
- {
- var field = m_type.GetField( "m_Parent", BindingFlags.Instance | BindingFlags.NonPublic );
- return field.GetValue( m_instance );
- }
- }
-
- public object Docked
- {
- get
- {
- var property = m_type.GetProperty( "docked", BindingFlags.Instance | BindingFlags.NonPublic );
- return property.GetValue( m_instance, null );
- }
- }
- }
-
- private class R_DockArea
- {
- private object m_instance;
- private System.Type m_type;
-
- public R_DockArea( object instance )
- {
- m_instance = instance;
- m_type = instance.GetType();
- }
-
- public object Window
- {
- get
- {
- var property = m_type.GetProperty( "window", BindingFlags.Instance | BindingFlags.Public );
- return property.GetValue( m_instance, null );
- }
- }
-
- public object ActualView
- {
- get
- {
- var field = m_type.GetField( "m_ActualView", BindingFlags.Instance | BindingFlags.NonPublic );
- return field.GetValue( m_instance );
- }
- }
-
- public object OriginalDragSource
- {
- set
- {
- var field = m_type.GetField( "s_OriginalDragSource", BindingFlags.Static | BindingFlags.NonPublic );
- field.SetValue( null, value );
- }
- }
-
-
- public void AddTab( EditorWindow pane )
- {
-#if UNITY_2018_3_OR_NEWER
- var method = m_type.GetMethod( "AddTab", BindingFlags.Instance | BindingFlags.Public, null, new System.Type[] { typeof( EditorWindow ), typeof( bool ) }, null );
- method.Invoke( m_instance, new object[] { pane, true } );
-#else
- var method = m_type.GetMethod( "AddTab", BindingFlags.Instance | BindingFlags.Public, null, new System.Type[] { typeof( EditorWindow ) }, null );
- method.Invoke( m_instance, new object[] { pane } );
-#endif
- }
-
- public void RemoveTab( EditorWindow pane )
- {
- var method = m_type.GetMethod( "RemoveTab", BindingFlags.Instance | BindingFlags.Public, null, new System.Type[] { typeof( EditorWindow ) }, null );
- method.Invoke( m_instance, new object[] { pane } );
- }
- }
-
- private class R_ContainerWindow
- {
- private object m_instance;
- private System.Type m_type;
-
- public R_ContainerWindow( object instance )
- {
- m_instance = instance;
- m_type = instance.GetType();
- }
-
- public object RootSplitView
- {
- get
- {
- var property = m_type.GetProperty( "rootSplitView", BindingFlags.Instance | BindingFlags.Public );
- return property.GetValue( m_instance, null );
- }
- }
-
- public object RootView
- {
- get
- {
- var property = m_type.GetProperty( "rootView", BindingFlags.Instance | BindingFlags.Public );
- return property.GetValue( m_instance, null );
- }
- }
-
- public object WindowPtr
- {
- get
- {
- var all = m_type.GetNestedTypes();
- foreach( var item in all )
- {
- Debug.Log( item.Name );
- }
- var property = m_type.GetField( "m_WindowPtr", BindingFlags.Instance | BindingFlags.NonPublic );
- return property.GetValue( m_instance );
- }
- }
- }
-
- private class R_SplitView
- {
- private object m_instance;
- private System.Type m_type;
-
- public R_SplitView( object instance )
- {
- m_instance = instance;
- m_type = instance.GetType();
- }
-
- public object DragOver( EditorWindow child, Vector2 screenPoint )
- {
- var method = m_type.GetMethod( "DragOver", BindingFlags.Instance | BindingFlags.Public );
- return method.Invoke( m_instance, new object[] { child, screenPoint } );
- }
-
- public void PerformDrop( EditorWindow child, object dropInfo, Vector2 screenPoint )
- {
- var method = m_type.GetMethod( "PerformDrop", BindingFlags.Instance | BindingFlags.Public );
- method.Invoke( m_instance, new object[] { child, dropInfo, screenPoint } );
- }
- }
-
- public enum DockPosition
- {
- Left,
- Top,
- Right,
- Bottom
- }
-
- public static bool IsDocked( this EditorWindow wnd )
- {
- var parent = new R_EditorWindow( wnd );
- return (bool)parent.Docked;
- }
-
- public static void Undock( this EditorWindow wnd )
- {
- var parent = new R_EditorWindow( wnd );
- var dockArea = new R_DockArea( parent.Parent );
- dockArea.RemoveTab( wnd );
- wnd.Show( true );
- }
-
- public static void RemoveTab( this EditorWindow wnd )
- {
- var parent = new R_EditorWindow( wnd );
- var dockArea = new R_DockArea( parent.Parent );
- dockArea.RemoveTab( wnd );
- }
-
- /// <summary>
- /// Docks the second window to the first window at the given position
- /// </summary>
- public static void Dock( this EditorWindow wnd, EditorWindow other, DockPosition position )
- {
- var mousePosition = GetFakeMousePosition( wnd, position );
-
- var parent = new R_EditorWindow( wnd );
- var child = new R_EditorWindow( other );
- var dockArea = new R_DockArea( parent.Parent );
- var containerWindow = new R_ContainerWindow( dockArea.Window );
- var splitView = new R_SplitView( containerWindow.RootSplitView );
- var dropInfo = splitView.DragOver( other, mousePosition );
- dockArea.OriginalDragSource = child.Parent;
- splitView.PerformDrop( other, dropInfo, mousePosition );
- }
-
-
- /// <summary>
- /// Adds the the second window as a tab at the end of the first window tab list
- /// </summary>
- /// <param name="existingWindow"></param>
- /// <param name="newWindow"></param>
- public static void AddTab( this EditorWindow existingWindow, EditorWindow newWindow )
- {
- var parent = new R_EditorWindow( existingWindow );
- var child = new R_EditorWindow( newWindow );
- var dockArea = new R_DockArea( parent.Parent );
- dockArea.OriginalDragSource = child.Parent;
- dockArea.AddTab( newWindow );
- }
-
- private static Vector2 GetFakeMousePosition( EditorWindow wnd, DockPosition position )
- {
- Vector2 mousePosition = Vector2.zero;
-
- // The 20 is required to make the docking work.
- // Smaller values might not work when faking the mouse position.
- switch ( position )
- {
- case DockPosition.Left:
- mousePosition = new Vector2( 20, wnd.position.size.y / 2 );
- break;
- case DockPosition.Top:
- mousePosition = new Vector2( wnd.position.size.x / 2, 20 );
- break;
- case DockPosition.Right:
- mousePosition = new Vector2( wnd.position.size.x - 20, wnd.position.size.y / 2 );
- break;
- case DockPosition.Bottom:
- mousePosition = new Vector2( wnd.position.size.x / 2, wnd.position.size.y - 20 );
- break;
- }
-
- return GUIUtility.GUIToScreenPoint( mousePosition );
- }
-}
-#endif
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowHelper.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowHelper.cs.meta
deleted file mode 100644
index 4b589194..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowHelper.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: ad6ef05d39dc39e42b8bfe0bdb826b7a
-timeCreated: 1494336778
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowsUtil.cs b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowsUtil.cs
deleted file mode 100644
index 3a57b9b7..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowsUtil.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-// Amplify Shader Editor - Visual Shader Editing Tool
-// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
-
-#if UNITY_EDITOR_WIN
-
-using System;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using System.Text;
-
-public class WindowsUtil
-{
- public const int GWL_STYLE = -16; //hex constant for style changing
- public const int WS_BORDER = 0x00800000; //window with border
- public const int WS_CAPTION = 0x00C00000; //window with a title bar with border
- public const int WS_SYSMENU = 0x00080000; //window with no borders etc.
- public const int WS_MAXIMIZE = 0x01000000;
- public const int WS_MAXIMIZEBOX = 0x00010000;
- public const int WS_MINIMIZE = 0x20000000;
- public const int WS_MINIMIZEBOX = 0x00020000;
- public const int WS_SIZEBOX = 0x00040000;
- public const int WS_VISIBLE = 0x10000000;
- public const int WS_TABSTOP = 0x00010000;
- public const int WS_CLIPCHILDREN = 0x02000000;
- public const int WS_CLIPSIBLINGS = 0x04000000;
-
- [DllImport( "user32.dll", EntryPoint = "SetWindowPos" )]
- public static extern bool SetWindowPos( System.IntPtr hwnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags );
-
- public delegate bool EnumWindowsProc( System.IntPtr hWnd, System.IntPtr lParam );
-
- [DllImport( "user32.dll", CharSet = CharSet.Auto, ExactSpelling = true )]
- public static extern IntPtr GetDesktopWindow();
-
- [DllImport( "user32.dll" )]
- public static extern int SetWindowLong( IntPtr hWnd, int nIndex, int dwNewLong );
-
- [DllImport( "user32.dll" )]
- public static extern int GetWindowLong( IntPtr hWnd, int nIndex );
-
- [DllImport( "user32.dll", ExactSpelling = true, SetLastError = true )]
- internal static extern int MapWindowPoints( IntPtr hWndFrom, IntPtr hWndTo, [In, Out] ref Rect rect, [MarshalAs( UnmanagedType.U4 )] int cPoints );
-
- [DllImport( "user32.dll" )]
- public static extern bool EnumWindows( EnumWindowsProc enumProc, System.IntPtr lParam );
-
- [DllImport( "user32" )]
- [return: MarshalAs( UnmanagedType.Bool )]
- public static extern bool EnumChildWindows( IntPtr window, EnumWindowProc callback, IntPtr lParam );
-
- public delegate bool EnumWindowProc( IntPtr hwnd, IntPtr lParam );
-
- [DllImport( "user32.dll", SetLastError = true )]
- public static extern bool MoveWindow( IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint );
-
- [DllImport( "user32.dll", CharSet = CharSet.Auto, SetLastError = true )]
- public static extern int GetWindowThreadProcessId( System.IntPtr handle, out int processId );
-
- [DllImport( "user32.dll", SetLastError = true )]
- public static extern IntPtr FindWindowEx( string lpClassName, string lpWindowName );
-
- // Find window by Caption only. Note you must pass IntPtr.Zero as the first parameter.
- [DllImport( "user32.dll", EntryPoint = "FindWindow", SetLastError = true )]
- public static extern IntPtr FindWindowByCaptionEx( IntPtr ZeroOnly, string lpWindowName );
-
- [DllImport( "user32.dll", SetLastError = true, CharSet = CharSet.Auto )]
- public static extern int GetClassName( IntPtr hWnd, StringBuilder lpClassName, int nMaxCount );
-
- [DllImport( "user32.dll" )]
- public static extern int GetWindowText( System.IntPtr hWnd, StringBuilder text, int nMaxCount );
-
- [DllImport( "user32.dll" )]
- public static extern int GetWindowTextLength( System.IntPtr hWnd );
-
- [DllImport( "user32.dll" )]
- public static extern IntPtr FindWindowEx( IntPtr parentWindow, IntPtr previousChildWindow, string windowClass, string windowTitle );
-
- [DllImport( "user32.dll" )]
- public static extern IntPtr GetActiveWindow();
-
- [DllImport( "user32.dll" )]
- public static extern bool GetWindowRect( System.IntPtr hwnd, ref Rect rectangle );
-
- static public IntPtr[] GetProcessWindows( int processId )
- {
- List<IntPtr> output = new List<IntPtr>();
- IntPtr winPtr = IntPtr.Zero;
- do
- {
- winPtr = FindWindowEx( IntPtr.Zero, winPtr, null, null );
- int id;
- GetWindowThreadProcessId( winPtr, out id );
- if( id == processId )
- output.Add( winPtr );
- } while( winPtr != IntPtr.Zero );
-
- return output.ToArray();
- }
-
- public struct Rect
- {
- public int Left { get; set; }
- public int Top { get; set; }
- public int Right { get; set; }
- public int Bottom { get; set; }
- public int Width { get { return Right - Left; } }
- public int Height { get { return Bottom - Top; } }
-
- public override string ToString()
- {
- return "(l: " + Left + ", r: " + Right + ", t: " + Top + ", b: " + Bottom + ")";
- }
- }
-
- public static bool GetProcessRect( System.Diagnostics.Process process, ref Rect rect )
- {
- IntPtr[] winPtrs = WindowsUtil.GetProcessWindows( process.Id );
-
- for( int i = 0; i < winPtrs.Length; i++ )
- {
- bool gotRect = WindowsUtil.GetWindowRect( winPtrs[ i ], ref rect );
- if( gotRect && ( rect.Left != 0 && rect.Top != 0 ) )
- return true;
- }
- return false;
- }
-
- public static void SetWindowPosition( int x, int y, int sizeX = 0, int sizeY = 0 )
- {
- System.Diagnostics.Process process = System.Diagnostics.Process.GetCurrentProcess();
- process.Refresh();
-
- EnumWindows( delegate ( System.IntPtr wnd, System.IntPtr param )
- {
- int id;
- GetWindowThreadProcessId( wnd, out id );
- if( id == process.Id )
- {
- SetWindowPos( wnd, 0, x, y, sizeX, sizeY, sizeX * sizeY == 0 ? 1 : 0 );
- return false;
- }
-
- return true;
- }, System.IntPtr.Zero );
- }
-}
-
-#endif \ No newline at end of file
diff --git a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowsUtil.cs.meta b/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowsUtil.cs.meta
deleted file mode 100644
index 8200f79f..00000000
--- a/Assets/AmplifyShaderEditor/Plugins/Editor/Utils/WindowsUtil.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 84d9a18b60b810c4c894886264a89da0
-timeCreated: 1559138384
-licenseType: Store
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant: