Пример #1
0
        internal override FixResult PerformFix(bool batchMode)
        {
            FixResult result;
            var       assetObject = AssetDatabase.LoadMainAssetAtPath(Path);

            // workaround for Unity 5.6 issue: LoadMainAssetAtPath returns null for settings assets
            if (assetObject == null)
            {
                var allObjects = AssetDatabase.LoadAllAssetsAtPath(Path);
                if (allObjects != null && allObjects.Length > 0)
                {
                    assetObject = allObjects[0];
                }
            }

            if (assetObject == null)
            {
                result = new FixResult(false);
                if (batchMode)
                {
                    Debug.LogWarning(Maintainer.LogPrefix + "Couldn't find settings asset for issue:\n" + this);
                }
                else
                {
                    result.SetErrorText("Couldn't find settings asset at\n" + Path);
                }
                return(result);
            }

            result = IssuesFixer.FixMissingReference(assetObject, PropertyPath, RecordLocation.Asset);
            return(result);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
        internal override FixResult PerformFix(bool batchMode)
        {
            FixResult result;
            var       scriptableObjectAsset = AssetDatabase.LoadMainAssetAtPath(Path);

            if (scriptableObjectAsset == null)
            {
                result = new FixResult(false);
                if (batchMode)
                {
                    Debug.LogWarning(Maintainer.LogPrefix + "Can't find Scriptable Object for issue:\n" + this);
                }
                else
                {
                    result.SetErrorText("Couldn't find Scriptable Object\n" + Path);
                }
                return(result);
            }

            result = IssuesFixer.FixMissingReference(scriptableObjectAsset, propertyPath, RecordLocation.Asset);
            return(result);
        }
Пример #6
0
        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);
        }
Пример #7
0
 /// <summary>
 /// Perform fix attempt. Call only if #IsFixable returns true.
 /// </summary>
 /// <param name="batchMode">Pass true when fixing more than 1 issue at a time to improve fixing performance using batch approach.</param>
 /// <returns>Fixing attempt result.</returns>
 public FixResult Fix(bool batchMode)
 {
     fixResult = PerformFix(batchMode);
     return(fixResult);
 }
Пример #8
0
 internal FixResult Fix(bool batchMode)
 {
     fixResult = PerformFix(batchMode);
     return(fixResult);
 }