using UnityEngine;
using UnityEditor;
using System;

public class ResetInspector : ShaderGUI {

    MaterialProperty dataTex;
    MaterialProperty position;
    MaterialProperty scale;

    public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] properties){
        Material material = materialEditor.target as Material;
        scale = FindProperty("_Scale", properties);
        position = FindProperty("_Position", properties);
        dataTex = FindProperty("_DataTex", properties);

        materialEditor.ShaderProperty(position, "Position");
        materialEditor.ShaderProperty(scale, "Scale");

        bool pregenShape = Array.IndexOf(material.shaderKeywords, "PREGEN_SHAPE") != -1;
        EditorGUI.BeginChangeCheck();
        pregenShape = EditorGUILayout.Toggle("Pregenerated Data", pregenShape);
        if (EditorGUI.EndChangeCheck()){
            if (pregenShape){
                material.EnableKeyword("PREGEN_SHAPE");
            }else{
                material.DisableKeyword("PREGEN_SHAPE");
            }
        }
        if(pregenShape) materialEditor.ShaderProperty(dataTex, "Reset Texture");
    }
}
