Forked from Nobuyuki-Kobayashi/CopyMaterialParameter.cs
Created
February 24, 2019 13:52
-
-
Save neon-izm/29643d5206d9b9a497ea77a72938775c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEditor; | |
namespace UnityChan | |
{ | |
public class CopyMaterialParameter : EditorWindow | |
{ | |
[SerializeField] | |
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); | |
EditorGUILayout.Space(); | |
if (GUILayout.Button ("Copy Sorce ⇒ Target")) { | |
CopyMaterial (source, target); | |
window.Close(); | |
} | |
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