summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-23 13:08:43 +0800
committerchai <chaifix@163.com>2020-10-23 13:08:43 +0800
commitb82da95b5181ac8bbae38efb13e950d5e88a4caa (patch)
tree48a6f3269276484bbc7cfc95f0651f40a2176aa1 /Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs
parent917e9e0b320775634dc2e710f7deac74fd0822f0 (diff)
*移动amplify shader editor到third party目录
Diffstat (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs')
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs
new file mode 100644
index 00000000..659a128c
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Nodes/Constants/PiNode.cs
@@ -0,0 +1,63 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using UnityEngine;
+using UnityEditor;
+using System;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ [NodeAttributes( "PI", "Constants And Properties", "PI constant : 3.14159265359" )]
+ public sealed class PiNode : ParentNode
+ {
+ public PiNode() : base() { }
+ public PiNode( int uniqueId, float x, float y, float width, float height ) : base( uniqueId, x, y, width, height ) { }
+ protected override void CommonInit( int uniqueId )
+ {
+ base.CommonInit( uniqueId );
+ AddInputPort( WirePortDataType.FLOAT, true, "Multiplier" );
+ AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
+ m_textLabelWidth = 70;
+ InputPorts[ 0 ].FloatInternalData = 1;
+ m_useInternalPortData = true;
+ m_previewShaderGUID = "bf4a65726dab3d445a69fb1d0945c33e";
+ }
+
+ public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
+ {
+ base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar );
+ string finalValue = string.Empty;
+ string piString = dataCollector.IsSRP ? "PI" : "UNITY_PI";
+ if( !InputPorts[ 0 ].IsConnected && InputPorts[ 0 ].FloatInternalData == 1 )
+ {
+ finalValue = piString;
+ } else
+ {
+ string multiplier = InputPorts[ 0 ].GeneratePortInstructions( ref dataCollector );
+ finalValue = "( " + multiplier + " * " + piString + " )";
+ }
+
+
+ if ( finalValue.Equals( string.Empty ) )
+ {
+ UIUtils.ShowMessage( UniqueId, "PINode generating empty code", MessageSeverity.Warning );
+ }
+ return finalValue;
+ }
+
+ //public override void ReadFromString( ref string[] nodeParams )
+ //{
+ // base.ReadFromString( ref nodeParams );
+
+ // Removed on version 5004
+ //m_value = Convert.ToSingle( GetCurrentParam( ref nodeParams ) );
+ //}
+
+ //public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
+ //{
+ // base.WriteToString( ref nodeInfo, ref connectionsInfo );
+ //}
+
+ }
+}