- Home /
 
               Question by 
               VargaPD · Jun 10, 2016 at 12:08 PM · 
                texturematerialpathfindingselected  
              
 
              Path of the selected material's texture
Dear community!
I am a bit lost in the documentation. How do I get the path of a selected Material's texture into a variable?
I made this so far:
 using UnityEngine;
 using UnityEditor;
 using UnityEditor.VersionControl;
 using System.Collections;
 
 [ExecuteInEditMode]
 public class MaterialAssigner : Editor
 {
     public string sDiff;
     private Texture textureValue;
     private Texture tDiff;
     
     [MenuItem( "MyMenu/Selected Texture")]
     
     public static void MySelectedTexture()
     {        
         tDiff = MaterialEditor.GetMaterialProperty(targets, "_MainTex").textureValue;
         sDiff = tDiff.name;
         Debug.Log(sDiff);
     }
     
 }
But it says
 error CS1502: The best overloaded method match for `UnityEditor.MaterialEditor.GetMaterialProperty(UnityEngine.Object[], string)' has some invalid arguments
and
 error CS0120: An object reference is required to access non-static member `UnityEditor.Editor.targets'
and
 error CS0120: An object reference is required to access non-static member `MaterialAssigner.tDiff'
and
 error CS0120: An object reference is required to access non-static member `MaterialAssigner.sDiff'
But without the STATIC in the 15th line, it not making a Menu. Then how I execute it in the Editor?
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                