public static void CopyComponent( TileComponent component ) { if( _CopiedComponent != null ) { Object.DestroyImmediate( _CopiedComponent ); _CopiedComponent = null; } System.Type classType = component.GetType(); _CopiedComponent = ScriptableObject.CreateInstance( classType ) as TileComponent; _CopiedComponent.hideFlags = HideFlags.HideAndDontSave; EditorUtility.CopySerialized( component,_CopiedComponent ); }
public static bool IsPasteComponent( TileComponent component ) { return _CopiedComponent != null && component.GetType () == _CopiedComponent.GetType(); }
public static void Reset( TileComponent component ) { Tile tile = component.tile; System.Type classType = component.GetType(); Undo.RecordObject( component,"Reset " + classType.Name ); TileComponent initializeComponent = ScriptableObject.CreateInstance( classType ) as TileComponent; EditorUtility.CopySerialized( initializeComponent,component ); tileField.SetValue( component,tile ); MethodInfo resetMethod = classType.GetMethod( "Reset",BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic ); if( resetMethod != null ) { resetMethod.Invoke( component,null ); } }