static int GetProceduralOutputType(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); ProceduralTexture obj = LuaScriptMgr.GetNetObject <ProceduralTexture>(L, 1); ProceduralOutputType o = obj.GetProceduralOutputType(); LuaScriptMgr.PushEnum(L, o); return(1); }
private void ConfigPortsFromMaterial(bool invalidateConnections = false, Texture[] newTextures = null) { //PreviewSizeX = ( m_proceduralMaterial != null ) ? UIUtils.ObjectField.CalcSize( new GUIContent( m_proceduralMaterial.name ) ).x + 15 : 110; m_insideSize.x = TexturePreviewSizeX + 5; SetAdditonalTitleText((m_proceduralMaterial != null) ? string.Format(Constants.PropertyValueLabel, m_proceduralMaterial.name) : string.Empty); Texture[] textures = newTextures != null ? newTextures : ((m_proceduralMaterial != null) ? m_proceduralMaterial.GetGeneratedTextures() : null); if (textures != null) { string nameToRemove = m_proceduralMaterial.name + "_"; m_textureTypes = new ProceduralOutputType[textures.Length]; for (int i = 0; i < textures.Length; i++) { ProceduralTexture procTex = textures[i] as ProceduralTexture; m_textureTypes[i] = procTex.GetProceduralOutputType(); WirePortDataType portType = (m_autoNormal && m_textureTypes[i] == ProceduralOutputType.Normal) ? WirePortDataType.FLOAT3 : WirePortDataType.COLOR; string newName = textures[i].name.Replace(nameToRemove, string.Empty); char firstLetter = Char.ToUpper(newName[0]); newName = firstLetter.ToString() + newName.Substring(1); if (i < m_outputPorts.Count) { m_outputPorts[i].ChangeProperties(newName, portType, false); if (invalidateConnections) { m_outputPorts[i].FullDeleteConnections(); } } else { AddOutputPort(portType, newName); } } if (textures.Length < m_outputPorts.Count) { int itemsToRemove = m_outputPorts.Count - textures.Length; for (int i = 0; i < itemsToRemove; i++) { int idx = m_outputPorts.Count - 1; if (m_outputPorts[idx].IsConnected) { m_outputPorts[idx].ForceClearConnection(); } RemoveOutputPort(idx); } } } else { int itemsToRemove = m_outputPorts.Count - 1; m_outputPorts[0].ChangeProperties(Constants.EmptyPortValue, WirePortDataType.COLOR, false); m_outputPorts[0].ForceClearConnection(); for (int i = 0; i < itemsToRemove; i++) { int idx = m_outputPorts.Count - 1; if (m_outputPorts[idx].IsConnected) { m_outputPorts[idx].ForceClearConnection(); } RemoveOutputPort(idx); } } m_sizeIsDirty = true; m_isDirty = true; Event.current.Use(); }
private void ConfigPortsFromMaterial( bool invalidateConnections = false, Texture[] newTextures = null ) { SetAdditonalTitleText( ( m_proceduralMaterial != null ) ? string.Format( Constants.PropertyValueLabel, m_proceduralMaterial.name ) : "Value( <None> )" ): Texture[] textures = newTextures != null ? newTextures : ( ( m_proceduralMaterial != null ) ? m_proceduralMaterial.GetGeneratedTextures() : null ): if( textures != null ) { m_firstOutputConnected = -1: string nameToRemove = m_proceduralMaterial.name + "_": m_textureTypes = new ProceduralOutputType[ textures.Length ]: for( int i = 0: i < textures.Length: i++ ) { ProceduralTexture procTex = textures[ i ] as ProceduralTexture: m_textureTypes[ i ] = procTex.GetProceduralOutputType(): WirePortDataType portType = ( m_autoNormal && m_textureTypes[ i ] == ProceduralOutputType.Normal ) ? WirePortDataType.FLOAT3 : WirePortDataType.COLOR: string newName = textures[ i ].name.Replace( nameToRemove, string.Empty ): char firstLetter = Char.ToUpper( newName[ 0 ] ): newName = firstLetter.ToString() + newName.Substring( 1 ): if( i < m_outputPorts.Count ) { m_outputPorts[ i ].ChangeProperties( newName, portType, false ): if( invalidateConnections ) { m_outputPorts[ i ].FullDeleteConnections(): } } else { AddOutputPort( portType, newName ): } } if( textures.Length < m_outputPorts.Count ) { int itemsToRemove = m_outputPorts.Count - textures.Length: for( int i = 0: i < itemsToRemove: i++ ) { int idx = m_outputPorts.Count - 1: if( m_outputPorts[ idx ].IsConnected ) { m_outputPorts[ idx ].ForceClearConnection(): } RemoveOutputPort( idx ): } } } else { int itemsToRemove = m_outputPorts.Count - 1: m_outputPorts[ 0 ].ChangeProperties( Constants.EmptyPortValue, WirePortDataType.COLOR, false ): m_outputPorts[ 0 ].ForceClearConnection(): for( int i = 0: i < itemsToRemove: i++ ) { int idx = m_outputPorts.Count - 1: if( m_outputPorts[ idx ].IsConnected ) { m_outputPorts[ idx ].ForceClearConnection(): } RemoveOutputPort( idx ): } } m_sizeIsDirty = true: m_isDirty = true: }