public void ChangeParameterType(PropertyType parameterType) { if (m_currentParameterType == PropertyType.Constant) { CopyDefaultsToMaterial(); } if (parameterType == PropertyType.InstancedProperty) { UIUtils.AddInstancePropertyCount(); } else if (m_currentParameterType == PropertyType.InstancedProperty) { UIUtils.RemoveInstancePropertyCount(); } if ((parameterType == PropertyType.Property || parameterType == PropertyType.InstancedProperty) && m_currentParameterType != PropertyType.Property && m_currentParameterType != PropertyType.InstancedProperty) { UIUtils.RegisterPropertyNode(this); } if ((parameterType != PropertyType.Property && parameterType != PropertyType.InstancedProperty) && (m_currentParameterType == PropertyType.Property || m_currentParameterType == PropertyType.InstancedProperty)) { UIUtils.UnregisterPropertyNode(this); } m_currentParameterType = parameterType; }
public override void ReadFromString(ref string[] nodeParams) { base.ReadFromString(ref nodeParams); m_currentParameterType = ( PropertyType )Enum.Parse(typeof(PropertyType), GetCurrentParam(ref nodeParams)); if (m_currentParameterType == PropertyType.InstancedProperty) { UIUtils.AddInstancePropertyCount(); } m_propertyName = GetCurrentParam(ref nodeParams); m_propertyInspectorName = GetCurrentParam(ref nodeParams); if (UIUtils.CurrentShaderVersion() > 13) { m_orderIndex = Convert.ToInt32(GetCurrentParam(ref nodeParams)); } m_propertyNameIsDirty = true; m_reRegisterName = false; UIUtils.ReleaseUniformName(m_uniqueId, m_oldName); UIUtils.RegisterUniformName(m_uniqueId, m_propertyName); m_oldName = m_propertyName; }
public override void ReadFromString(ref string[] nodeParams) { base.ReadFromString(ref nodeParams); if (UIUtils.CurrentShaderVersion() < 2505) { string property = GetCurrentParam(ref nodeParams); m_currentParameterType = property.Equals("Uniform") ? PropertyType.Global : ( PropertyType )Enum.Parse(typeof(PropertyType), property); } else { m_currentParameterType = ( PropertyType )Enum.Parse(typeof(PropertyType), GetCurrentParam(ref nodeParams)); } if (m_currentParameterType == PropertyType.InstancedProperty) { UIUtils.AddInstancePropertyCount(); UIUtils.RegisterPropertyNode(this); } if (m_currentParameterType == PropertyType.Property) { UIUtils.RegisterPropertyNode(this); } m_propertyName = GetCurrentParam(ref nodeParams); m_propertyInspectorName = GetCurrentParam(ref nodeParams); if (UIUtils.CurrentShaderVersion() > 13) { m_orderIndex = Convert.ToInt32(GetCurrentParam(ref nodeParams)); } if (UIUtils.CurrentShaderVersion() > 4102) { int attribAmount = Convert.ToInt32(GetCurrentParam(ref nodeParams)); if (attribAmount > 0) { for (int i = 0; i < attribAmount; i++) { m_selectedAttribs.Add(IdForAttrib(GetCurrentParam(ref nodeParams))); } m_visibleAttribsFoldout = true; } InitializeAttribsArray(); } //if ( UIUtils.CurrentShaderVersion() > 7101 ) //{ // m_orderIndexOffset = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ); //} m_propertyNameIsDirty = true; m_reRegisterName = false; UIUtils.ReleaseUniformName(UniqueId, m_oldName); UIUtils.RegisterUniformName(UniqueId, m_propertyName); m_oldName = m_propertyName; }
public override void ReadFromString(ref string[] nodeParams) { base.ReadFromString(ref nodeParams); if (UIUtils.CurrentShaderVersion() < 2505) { string property = GetCurrentParam(ref nodeParams); m_currentParameterType = property.Equals("Uniform") ? PropertyType.Global : ( PropertyType )Enum.Parse(typeof(PropertyType), property); } else { m_currentParameterType = ( PropertyType )Enum.Parse(typeof(PropertyType), GetCurrentParam(ref nodeParams)); } if (m_currentParameterType == PropertyType.InstancedProperty) { UIUtils.AddInstancePropertyCount(); UIUtils.RegisterPropertyNode(this); } if (m_currentParameterType == PropertyType.Property) { UIUtils.RegisterPropertyNode(this); } m_propertyName = GetCurrentParam(ref nodeParams); m_propertyInspectorName = GetCurrentParam(ref nodeParams); if (UIUtils.CurrentShaderVersion() > 13) { m_orderIndex = Convert.ToInt32(GetCurrentParam(ref nodeParams)); } if (UIUtils.CurrentShaderVersion() > 4102) { int attribAmount = Convert.ToInt32(GetCurrentParam(ref nodeParams)); if (attribAmount > 0) { for (int i = 0; i < attribAmount; i++) { m_selectedAttribs.Add(IdForAttrib(GetCurrentParam(ref nodeParams))); } m_visibleAttribsFoldout = true; } InitializeAttribsArray(); } if (UIUtils.CurrentShaderVersion() > 14003) { m_variableMode = (VariableMode)Enum.Parse(typeof(VariableMode), GetCurrentParam(ref nodeParams)); } if (UIUtils.CurrentShaderVersion() > 14201) { m_autoGlobalName = Convert.ToBoolean(GetCurrentParam(ref nodeParams)); } if (UIUtils.CurrentShaderVersion() > 14403) { m_enumCount = Convert.ToInt32(GetCurrentParam(ref nodeParams)); for (int i = 0; i < m_enumCount; i++) { m_enumNames.Add(GetCurrentParam(ref nodeParams)); m_enumValues.Add(Convert.ToInt32(GetCurrentParam(ref nodeParams))); } } CheckEnumAttribute(); if (m_enumCount > 0) { m_visibleEnumsFoldout = true; } m_propertyNameIsDirty = true; m_reRegisterName = false; if (!m_isNodeBeingCopied) { UIUtils.ReleaseUniformName(UniqueId, m_oldName); UIUtils.RegisterUniformName(UniqueId, m_propertyName); } m_oldName = m_propertyName; }
public override void DrawProperties() { base.DrawProperties(); EditorGUILayout.BeginVertical(); { if (m_freeType) { PropertyType parameterType = ( PropertyType )EditorGUILayout.EnumPopup(ParameterTypeStr, m_currentParameterType); if (parameterType != m_currentParameterType) { if (m_currentParameterType == PropertyType.Constant) { CopyDefaultsToMaterial(); } if (parameterType == PropertyType.InstancedProperty) { UIUtils.AddInstancePropertyCount(); } else if (m_currentParameterType == PropertyType.InstancedProperty) { UIUtils.RemoveInstancePropertyCount(); } } m_currentParameterType = parameterType; } switch (m_currentParameterType) { case PropertyType.Property: case PropertyType.InstancedProperty: { ShowPropertyInspectorNameGUI(); ShowPropertyNameGUI(true); } break; case PropertyType.Uniform: { ShowPropertyInspectorNameGUI(); ShowPropertyNameGUI(false); } break; case PropertyType.Constant: { ShowPropertyInspectorNameGUI(); } break; } EditorGUI.BeginChangeCheck(); DrawSubProperties(); if (CanDrawMaterial) { DrawMaterialProperties(); } if (EditorGUI.EndChangeCheck()) { //_propertyNameIsDirty = true; BeginDelayedDirtyProperty(); } } EditorGUILayout.EndVertical(); CheckPropertyFromInspector(); }