MaterialEditor Inherits from Editor

The Unity Material Editor.

Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.

Extend this class to write your own custom material editor. For more detailed information see the Custom Material Editor section of the the ShaderLab reference.

Variables
isVisible

Is the current material expanded.

Functions
SetShader

Set the shader of the material.

Awake

Called when the Editor is woken up.

PropertiesChanged

Whenever a material property is changed call this function. This will rebuild the inspector and validate the properties.

GetFloat

Get the value of a given float shader property.

SetFloat

Set the value of a given float property.

GetColor

Get the value of a given color shader property.

SetColor

Set the value of a given texture property.

GetVector

Get the value of a given vector shader property.

SetVector

Set the value of a given vector property.

GetTexture

Get the value of a given float shader property.

SetTexture

Set the value of a given texture property.

GetTextureScale

Get the value of a given texture scale for a given texture property.

GetTextureOffset

Get the value of a given texture offset for a given texture property.

SetTextureScale

Set the scale of a given texture property.

SetTextureOffset

Set the offset of a given texture property.

RangeProperty

Draw a range slider for a range shader property.

FloatProperty

Draw a property field for a float shader property.

ColorProperty

Draw a property field for a color shader property.

VectorProperty

Draw a property field for a vector shader property.

TextureProperty

Draw a property field for a texture shader property.

ShaderProperty

Automatically draw a shader property from given index for the given shader.

PropertiesGUI

Render the standard material properties.

RegisterPropertyChangeUndo

Call this when you change a material property. It will add an undo for the action.

OnEnable

Called when the editor is enabled, if overridden please call the base OnEnable() to ensure that the material inspector is set up properly.

UndoRedoPerformed

OnDisable

Called when the editor is disabled, if overridden please call the base OnDisable() to ensure that the material inspector is set up properly.

Inherited members
Inherited Variables
target

The object being inspected.

targets

An array of all the object being inspected.

serializedObject

A SerializedObject representing the object or objects being inspected.

name

The name of the object.

hideFlags

Should the object be hidden, saved with the scene or modifiable by the user?

Inherited Functions
DrawDefaultInspector

Draw the built-in inspector.

OnInspectorGUI

Repaint

Repaint any inspectors that shows this editor.

HasPreviewGUI

Override this method in subclasses if you implement OnPreviewGUI.

GetPreviewTitle

Override this method if you want to change the label of the Preview area.

RenderStaticPreview

Override this method if you want to render a static preview that shows.

OnPreviewGUI

Implement to create your own custom preview. Custom previews are used in the preview area of the inspector, primary editor headers, and the object selector.

OnInteractivePreviewGUI

Implement to create your own interactive custom preview. Interactive custom previews are used in the preview area of the inspector and the object selector.

OnPreviewSettings

Override this method if you want to show custom controls in the preview header.

GetInfoString

Implement this method to show asset information on top of the asset preview.

GetInstanceID

Returns the instance id of the object.

ToString

Returns the name of the game object.

Inherited Messages Sent
OnSceneGUI

Lets the Editor handle an event in the scene view.

OnEnable

This function is called when the object is loaded.

OnDisable

This function is called when the scriptable object goes out of scope.

OnDestroy

This function is called when the scriptable object will be destroyed.

Inherited Class Functions
CreateEditor

Make a custom editor for obj or objects.

CreateInstance

Creates an instance of a scriptable object with className.

operator bool

Instantiate

Clones the object original and returns the clone.

Destroy

Removes a gameobject, component or asset.

DestroyImmediate

Destroys the object obj immediately. It is strongly recommended to use Destroy instead.

FindObjectsOfType

Returns a list of all active loaded objects of Type type.

FindObjectOfType

Returns the first active loaded object of Type type.

operator ==

Compares if two objects refer to the same.

operator !=

Compares if two objects refer to a different object.

DontDestroyOnLoad

Makes the object target not be destroyed automatically when loading a new scene.