- Home /
 
               Question by 
               topofsteel · Jul 13, 2013 at 09:00 PM · 
                c#editor  
              
 
              How do I reference variables from one editor script in another
I have one script that opens a simple editor window collects a bool and a string. I have another script derived from AssetPostprocessor that runs whenever assets are imported. I want to be able to toggle weather the importer script runs, and if so, where it gets materials from.
EditorWindow:
 public static bool Mat_to_Sub = false;
 public static string materialPath;
 void OnGUI()
 {
     GUILayout.Label ("Settings", EditorStyles.boldLabel);
     
     Mat_to_Sub = EditorGUILayout.BeginToggleGroup("Enable Material to Substance", Mat_to_Sub);
     
     if (GUILayout.Button("Location...")) 
     {
         materialPath = EditorUtility.OpenFolderPanel("Location of Materilas", "Assets/", "");
     }
     GUILayout.Label (materialPath);
     
     EditorGUILayout.EndToggleGroup();
 }
AssetPostprocessor script:
 public class ImportMattoSubstance :  AssetPostprocessor
 {        
     public Material OnAssignMaterialModel(Material material, Renderer renderer)
     {
         if (**bool from first script**) 
         {
             var materialPath = **string from first script** + material.name + ".sbsar";            
             
             if(AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material)))
             {
                 return AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material)) as Material;
             }
         }    
         
         return material;
     }
 }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                