Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace UnityChan
public class CopyMaterialParameter : EditorWindow
static Material source;
Material target;
static EditorWindow window;
[MenuItem("CONTEXT/Material/Copy Material Parameter")]
static void Init (MenuCommand command)
source = (Material) command.context;
window = EditorWindow.GetWindow<CopyMaterialParameter> (true, "Copy Material Parameter : Select Materials", true);
window.Show ();
void OnGUI ()
source = (Material)EditorGUILayout.ObjectField ("Source material", source, typeof(Material),true);
target = (Material)EditorGUILayout.ObjectField ("Target material", target, typeof(Material),true);
if (GUILayout.Button ("Copy Sorce ⇒ Target")) {
CopyMaterial (source, target);
if (GUILayout.Button ("Switch Sorce/Target")) {
var tmp = target;
target = source;
source = tmp;
void CopyMaterial (Material source, Material target)
target.shader = source.shader;
target.CopyPropertiesFromMaterial (source);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.