public void GameObjectCanBeMigrated() { Type oldType = typeof(ManipulationHandler); Type newType = typeof(ObjectManipulator); Type migrationHandlerType = typeof(ObjectManipulatorMigrationHandler); GameObject gameObject = SetUpGameObjectWithComponentOfType(oldType); migrationTool.TryAddObjectForMigration(gameObject); migrationTool.MigrateSelection(migrationHandlerType, false); Assert.IsNull(gameObject.GetComponent(oldType), $"Migrated Component of type {oldType.Name} could not be removed"); Assert.IsNotNull(gameObject.GetComponent(newType), $"Migrated Component of type {newType.Name} could not be added"); GameObject.DestroyImmediate(gameObject); }
private void DrawDeprecated() { List <Type> requiringTypes; if ((target as ManipulationHandler).gameObject.IsComponentRequired <ManipulationHandler>(out requiringTypes)) { string requiringComponentNames = null; for (int i = 0; i < requiringTypes.Count; i++) { requiringComponentNames += "- " + requiringTypes[i].FullName; if (i < requiringTypes.Count - 1) { requiringComponentNames += '\n'; } } EditorGUILayout.HelpBox($"This component is deprecated. Please migrate object to up to date version. Remove the RequiredComponentAttribute from:\n{requiringComponentNames}", MessageType.Error); return; } EditorGUILayout.HelpBox("This component is deprecated. Please migrate object to up to date version", MessageType.Warning); if (GUILayout.Button("Migrate Object")) { MigrationTool migrationTool = new MigrationTool(); var component = (ManipulationHandler)target; migrationTool.TryAddObjectForMigration(typeof(ObjectManipulatorMigrationHandler), (GameObject)component.gameObject); migrationTool.MigrateSelection(typeof(ObjectManipulatorMigrationHandler), true); } }
public void GameObjectCanBeMigrated() { foreach (var entry in migrationList) { Type oldType = entry.oldType; Type newType = entry.newType; Type migrationHandlerType = entry.handler; GameObject gameObject = SetUpGameObjectWithComponentOfType(oldType); migrationTool.TryAddObjectForMigration(migrationHandlerType, gameObject); migrationTool.MigrateSelection(migrationHandlerType, false); Assert.IsNull(gameObject.GetComponent(oldType), $"Migrated Component of type {oldType.Name} could not be removed"); Assert.IsNotNull(gameObject.GetComponent(newType), $"Migrated Component of type {newType.Name} could not be added"); Object.DestroyImmediate(gameObject); } }
private void DrawDeprecated() { EditorGUILayout.HelpBox("This component is deprecated. Please migrate object to up to date version", UnityEditor.MessageType.Warning); if (GUILayout.Button("Migrate Object")) { #if UNITY_EDITOR MigrationTool migrationTool = new MigrationTool(); var component = (ManipulationHandler)target; migrationTool.TryAddObjectForMigration((GameObject)component.gameObject); migrationTool.MigrateSelection(typeof(ObjectManipulatorMigrationHandler), true); #endif } }