// ---------------------------------------------------------------------------- // fix missing component // ---------------------------------------------------------------------------- private static void FixMissingComponents(GameObjectIssueRecord issue, GameObject go) { CSObjectTools.SelectGameObject(go, issue.location); ActiveEditorTracker tracker = CSEditorTools.GetActiveEditorTrackerForSelectedObject(); tracker.RebuildIfNecessary(); bool touched = false; Editor[] activeEditors = tracker.activeEditors; for (int i = activeEditors.Length - 1; i >= 0; i--) { Editor editor = activeEditors[i]; if (CSObjectTools.GetLocalIdentifierInFileForObject(editor.serializedObject.targetObject) == issue.componentId) { Object.DestroyImmediate(editor.target, true); touched = true; } } if (touched) { #if UNITY_5_0_PLUS if (issue.location == RecordLocation.Scene) { CSSceneTools.MarkSceneDirty(); } else { EditorUtility.SetDirty(go); } #else EditorUtility.SetDirty(go); #endif } //CSObjectTools.SelectGameObject(null, issue.location); }
public void Show() { GameObject go = null; if (OpenNeededSceneIfNecessary(true)) { go = GetGameObjectWithThisIssue(); } if (go != null) { CSObjectTools.SelectGameObject(go, location); if (location == RecordLocation.Scene) { EditorApplication.delayCall += () => { EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(path, typeof(Object))); }; } else { if (gameObjectPath.Split('/').Length > 2) { EditorApplication.delayCall += () => { EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath(path, typeof(Object))); }; } } ActiveEditorTracker tracker = CSEditorTools.GetActiveEditorTrackerForSelectedObject(); tracker.RebuildIfNecessary(); Editor[] editors = tracker.activeEditors; long[] ids = new long[editors.Length]; bool targetFound = false; for (int i = 0; i < editors.Length; i++) { Editor editor = editors[i]; long id = CSObjectTools.GetLocalIdentifierInFileForObject(editor.serializedObject.targetObject); ids[i] = id; if (id == componentId) { targetFound = true; /* known corner cases when editor can't be set to visible via tracker */ if (editor.serializedObject.targetObject is ParticleSystemRenderer) { ParticleSystemRenderer renderer = (ParticleSystemRenderer)editor.serializedObject.targetObject; ParticleSystem ps = renderer.GetComponent <ParticleSystem>(); componentId = CSObjectTools.GetLocalIdentifierInFileForObject(ps); } } } if (targetFound) { for (int i = 0; i < editors.Length; i++) { tracker.SetVisible(i, ids[i] != componentId ? 0 : 1); } } } else { MaintainerWindow.ShowNotification("Couldn't find object " + gameObjectPath); } }