Beispiel #1
0
        public override bool UpdateShaderDefaults(ref Shader shader, ref TextureDefaultsDataColector defaultCol)
        {
            if (m_defaultTextureArray != null)
            {
                defaultCol.AddValue(PropertyName, m_defaultTextureArray);
            }

            return(true);
        }
        public override bool UpdateShaderDefaults(ref Shader shader, ref TextureDefaultsDataColector defaultCol /* ref string metaStr */)
        {
            if (m_defaultValue != null)
            {
                defaultCol.AddValue(PropertyName, m_defaultValue);
            }

            return(true);
        }
 public override bool UpdateShaderDefaults(ref Shader shader, ref TextureDefaultsDataColector defaultCol)
 {
     if (m_proceduralMaterial != null)
     {
         Texture[] textures = m_proceduralMaterial.GetGeneratedTextures();
         for (int i = 0; i < textures.Length; i++)
         {
             defaultCol.AddValue(textures[i].name, textures[i]);
         }
     }
     return(true);
 }
Beispiel #4
0
 public override bool UpdateShaderDefaults(ref Shader shader, ref TextureDefaultsDataColector defaultCol /* ref string metaStr */)
 {
     if (m_defaultValue != null)
     {
         defaultCol.AddValue(m_propertyName, m_defaultValue);
         //string data2 = AssetDatabase.AssetPathToGUID( AssetDatabase.GetAssetPath( _defaultValue ) );
         //metaStr += ( "  - " + _propertyName + ": {fileID: " + _metafileId + ", guid: " + data2 + ", type: 3}\n" );
     }
     //else
     //{
     //	metaStr += ( "  - " + _propertyName + ": {instanceID: 0}\n" );
     //}
     return(true);
 }
        public void UpdateShaderOnPropertyNodes(ref Shader shader)
        {
            if (m_propertyNodes.Count == 0)
            {
                return;
            }

            try
            {
                bool hasContents = false;
                //string metaNewcontents = IOUtils.LINE_TERMINATOR.ToString();
                TextureDefaultsDataColector defaultCol = new TextureDefaultsDataColector();
                foreach (KeyValuePair <int, PropertyNode> kvp in m_propertyNodes)
                {
                    hasContents = kvp.Value.UpdateShaderDefaults(ref shader, ref defaultCol) || hasContents;
                }

                if (hasContents)
                {
                    ShaderImporter importer = ( ShaderImporter )ShaderImporter.GetAtPath(AssetDatabase.GetAssetPath(shader));
                    importer.SetDefaultTextures(defaultCol.NamesArr, defaultCol.ValuesArr);
                    importer.SaveAndReimport();

                    defaultCol.Destroy();
                    defaultCol = null;
                    //string metaFilepath = AssetDatabase.GetTextMetaFilePathFromAssetPath( AssetDatabase.GetAssetPath( shader ) );
                    //string metaContents = IOUtils.LoadTextFileFromDisk( metaFilepath );

                    //int startIndex = metaContents.IndexOf( IOUtils.MetaBegin );
                    //int endIndex = metaContents.IndexOf( IOUtils.MetaEnd );

                    //if ( startIndex > 0 && endIndex > 0 )
                    //{
                    //	startIndex += IOUtils.MetaBegin.Length;
                    //	string replace = metaContents.Substring( startIndex, ( endIndex - startIndex ) );
                    //	if ( hasContents )
                    //	{
                    //		metaContents = metaContents.Replace( replace, metaNewcontents );
                    //	}
                    //}
                    //IOUtils.SaveTextfileToDisk( metaContents, metaFilepath, false );
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }