Синтаксис:
Используется csharp
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
[CustomEditor (typeof(Grid))]
public class NewEditorScript : Editor
{
public void OnEnable()
{
GameObject tile = Resources.Load<GameObject>("Prefabs/Tiles/Default");
if (tile == null)
{
Debug.Log ("No tile.");
return;
}
SpriteRenderer sr = tile.GetComponent<SpriteRenderer>();
if (sr == null)
{
Debug.Log ("No SpriteRenderer.");
return;
}
Material sm = sr.sharedMaterial;
if (sm == null)
{
Debug.Log ("No Material.");
return;
}
Texture t = sm.mainTexture;//проблема тут
if (t == null)
{
Debug.Log ("No Texture.");
return;
}
}
}
using UnityEditor;
using System.Collections;
using System.IO;
[CustomEditor (typeof(Grid))]
public class NewEditorScript : Editor
{
public void OnEnable()
{
GameObject tile = Resources.Load<GameObject>("Prefabs/Tiles/Default");
if (tile == null)
{
Debug.Log ("No tile.");
return;
}
SpriteRenderer sr = tile.GetComponent<SpriteRenderer>();
if (sr == null)
{
Debug.Log ("No SpriteRenderer.");
return;
}
Material sm = sr.sharedMaterial;
if (sm == null)
{
Debug.Log ("No Material.");
return;
}
Texture t = sm.mainTexture;//проблема тут
if (t == null)
{
Debug.Log ("No Texture.");
return;
}
}
}