public static FixResult FixObjectIssue(GameObjectIssueRecord issue, Object obj, Component component, IssueKind type) { FixResult result; if (type == IssueKind.MissingComponent) { var go = (GameObject)obj; var hasIssue = GameObjectHasMissingComponent(go); if (hasIssue) { if (PrefabUtility.IsPartOfPrefabAsset(go)) { var allTransforms = go.transform.root.GetComponentsInChildren <Transform>(true); foreach (var child in allTransforms) { FixMissingComponents(issue, child.gameObject, false); } } else { FixMissingComponents(issue, go, false); } if (!GameObjectHasMissingComponent(go)) { result = new FixResult(true); } else { result = FixResult.CreateError("Fix attempt failed!"); } } else { result = new FixResult(true); } } else if (type == IssueKind.MissingReference) { result = FixMissingReference(component != null ? component : obj, issue.propertyPath, issue.Location); } else { result = FixResult.CreateError("IssueKind is not supported!"); } return(result); }
public static FixResult FixObjectIssue(GameObjectIssueRecord issue, Object obj, Component component, IssueKind type) { FixResult result; if (type == IssueKind.MissingComponent) { var hasIssue = GameObjectHasMissingComponent(obj as GameObject); if (hasIssue) { FixMissingComponents(issue, obj as GameObject, false); if (!GameObjectHasMissingComponent(obj as GameObject)) { result = new FixResult(true); } else { result = FixResult.CreateError("Fix attempt failed!"); } } else { result = new FixResult(true); } } else if (type == IssueKind.MissingReference) { if (component != null) { result = FixMissingReference(component, issue.propertyPath, issue.Location); } else { result = FixMissingReference(obj, issue.propertyPath, issue.Location); } } else { result = FixResult.CreateError("IssueKind is not supported!"); } return(result); }
protected override FixResult PerformFix(bool batchMode) { CSSceneTools.OpenSceneResult openSceneResult = null; if (!batchMode) { openSceneResult = CSSceneTools.OpenScene(Path); if (!openSceneResult.success) { return(FixResult.CreateError("Couldn't open scene")); } } FixResult result; var settingsObject = GetSettingsObjectWithThisIssue(); if (settingsObject == null) { result = new FixResult(false); if (batchMode) { Debug.LogWarning(Maintainer.LogPrefix + "Couldn't find " + SettingsKind + " object for issue:\n" + this); } else { result.SetErrorText("Couldn't find " + SettingsKind + " object at\n" + Path); } return(result); } result = IssuesFixer.FixMissingReference(settingsObject, PropertyPath, RecordLocation.Scene); if (!batchMode) { CSSceneTools.SaveScene(openSceneResult.scene); CSSceneTools.CloseOpenedSceneIfNeeded(openSceneResult); } return(result); }
protected override FixResult PerformFix(bool batchMode) { Object obj = null; Component component = null; FixResult result; CSSceneTools.OpenSceneResult openSceneResult = null; if (!batchMode && Location == RecordLocation.Scene) { openSceneResult = CSSceneTools.OpenScene(Path); if (!openSceneResult.success) { return(FixResult.CreateError("Couldn't open scene")); } } obj = GetObjectWithThisIssue(); if (obj == null) { result = new FixResult(false); if (batchMode) { Debug.LogWarning(Maintainer.LogPrefix + "Can't find Object for issue:\n" + this); } else { result.SetErrorText("Couldn't find Object\n" + transformPath); } return(result); } if (!string.IsNullOrEmpty(componentName) && obj is GameObject) { component = GetComponentWithThisIssue(obj as GameObject); if (component == null) { result = new FixResult(false); if (batchMode) { Debug.LogWarning(Maintainer.LogPrefix + "Can't find component for issue:\n" + this); } else { result.SetErrorText("Can't find component\n" + componentName); } return(result); } } result = IssuesFixer.FixObjectIssue(this, obj, component, Kind); if (!batchMode && Location == RecordLocation.Scene && openSceneResult != null) { CSSceneTools.SaveScene(openSceneResult.scene); CSSceneTools.CloseOpenedSceneIfNeeded(openSceneResult); } return(result); }