Version: 5.3 (switch to 5.4b)
언어English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

MaterialEditor

class in UnityEditor

/

Inherits from:Editor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

닫기

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

닫기

취소

Switch to Manual

Description

The Unity Material Editor.

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

Static Variables

kMiniTextureFieldLabelIndentLevelUseful for indenting shader properties that need the same indent as mini texture field.

Variables

isVisibleIs the current material expanded.

Public Functions

AwakeCalled when the Editor is woken up.
ColorPropertyDraw a property field for a color shader property.
DefaultPreviewGUIDefault handling of preview area for materials.
DefaultPreviewSettingsGUIDefault toolbar for material preview area.
DefaultShaderPropertyHandles UI for one shader property ignoring any custom drawers.
FloatPropertyDraw a property field for a float shader property.
GetPropertyHeightCalculate height needed for the property.
GetTexturePropertyCustomAreaReturns the free rect below the label and before the large thumb object field. Is used for e.g. tiling and offset properties.
HasPreviewGUI현재 상태에서 컴포넌트의 미리보기를 할 수 있는지 여부.
HelpBoxWithButtonMake a help box with a message and button. Returns true, if button was pressed.
LightmapEmissionPropertyThis function will draw the UI for the lightmap emission property. (None, Realtime, baked)See Also: MaterialLightmapFlags.
OnDisableCalled when the editor is disabled, if overridden please call the base OnDisable() to ensure that the material inspector is set up properly.
OnEnableCalled when the editor is enabled, if overridden please call the base OnEnable() to ensure that the material inspector is set up properly.
OnInspectorGUIImplement specific MaterialEditor GUI code here. If you want to simply extend the existing editor call the base OnInspectorGUI () before doing any custom GUI code.
OnPreviewGUIImage 컴포넌트를 위한 사용자 정의 미리보기입니다.
PropertiesChangedWhenever a material property is changed call this function. This will rebuild the inspector and validate the properties.
PropertiesDefaultGUIDefault rendering of shader properties.
PropertiesGUIRender the standard material properties. This method will either render properties using a IShaderGUI instance if found otherwise it uses PropertiesDefaultGUI.
RangePropertyDraw a range slider for a range shader property.
RegisterPropertyChangeUndoCall this when you change a material property. It will add an undo for the action.
RequiresConstantRepaintDoes this edit require to be repainted constantly in its current state?
SetDefaultGUIWidthsSet EditorGUIUtility.fieldWidth and labelWidth to the default values that PropertiesGUI uses.
SetShaderSet the shader of the material.
ShaderPropertyHandes UI for one shader property.
TextureCompatibilityWarningChecks if particular property has incorrect type of texture specified by the material, displays appropriate warning and suggests the user to automatically fix the problem.
TexturePropertyDraw a property field for a texture shader property.
TexturePropertyMiniThumbnailDraw a property field for a texture shader property that only takes up a single line height.
TexturePropertySingleLineMethod for showing a texture property control with additional inlined properites.
TexturePropertyTwoLinesMethod for showing a compact layout of properties.
TexturePropertyWithHDRColorMethod for showing a texture property control with a HDR color field and its color brightness float field.
TextureScaleOffsetPropertyDraws tiling and offset properties for a texture.
VectorPropertyDraw a property field for a vector shader property.

Static Functions

ApplyMaterialPropertyDrawersApply initial MaterialPropertyDrawer values.
GetDefaultPropertyHeightCalculate height needed for the property, ignoring custom drawers.
GetFlexibleRectBetweenFieldAndRightEdgeUtility method for GUI layouting ShaderGUI. Used e.g for the rect after a left aligned Color field.
GetFlexibleRectBetweenLabelAndFieldUtility method for GUI layouting ShaderGUI.
GetLeftAlignedFieldRectUtility method for GUI layouting ShaderGUI.
GetMaterialPropertiesGet shader property information of the passed materials.
GetMaterialPropertyGet information about a single shader property.
GetRectAfterLabelWidthUtility method for GUI layouting ShaderGUI. This is the rect after the label which can be used for multiple properties. The input rect can be fetched by calling: EditorGUILayout.GetControlRect.
GetRightAlignedFieldRectUtility method for GUI layouting ShaderGUI.

Inherited members

Variables

serializedObjectA SerializedObject representing the object or objects being inspected.
targetThe object being inspected.
targetsAn array of all the object being inspected.
hideFlags오브젝트가 숨겨져있는 상태인지, 씬에 저장된 상태인지, 또는 사용자에 의해서 수정가능한 상태인지를 확인합니다.
name오브젝트의 이름을 나타냅니다.

Public Functions

DrawDefaultInspectorDraw the built-in inspector.
DrawHeaderCall this function to draw the header of the editor.
DrawPreviewThe first entry point for Preview Drawing.
GetInfoStringImplement this method to show asset information on top of the asset preview.
GetPreviewTitleOverride this method if you want to change the label of the Preview area.
OnInteractivePreviewGUIImplement to create your own interactive custom preview. Interactive custom previews are used in the preview area of the inspector and the object selector.
OnPreviewSettingsOverride this method if you want to show custom controls in the preview header.
RenderStaticPreviewOverride this method if you want to render a static preview that shows.
RepaintRepaint any inspectors that shows this editor.
UseDefaultMarginsOverride this method in subclasses to return false if you don't want default margins.
GetInstanceID오브젝트의 인스턴스 ID를 반환합니다.
ToString게임 오브젝트의 이름을 반환합니다.

Static Functions

CreateCachedEditorOn return previousEditor is an editor for targetObject or targetObjects. The function either returns if the editor is already tracking the objects, or Destroys the previous editor and creates a new one.
CreateEditorMake a custom editor for targetObject or targetObjects.
Destroy게임오브젝트, 컴포넌트나 애셋을 삭제합니다.
DestroyImmediate obj 오브젝트를 즉시 파괴합니다. Destroy를 사용하는 것을 추천합니다.
DontDestroyOnLoad새로운 Scene이 로드될때 자동으로 파괴되지 않는 target 오브젝트를 만듭니다.
FindObjectOfType첫번째 활성화한 로드된 type 타입의 오브젝트를 반환합니다.
FindObjectsOfType모든 활성화한 로드된 type 타입의 오브젝트 리스트를 반환합니다.
Instantiate오브젝트의 인스턴스 ID를 반환합니다.
CreateInstance/T/를 사용해서 scriptable 오브젝트의 인스턴스를 생성합니다.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.

Messages

OnSceneGUILets the Editor handle an event in the scene view.
OnDestroyscriptable 오브젝트가 제거될 때 호출됩니다.