Пример #1
0
        protected override bool PerformFix(bool batchMode)
        {
            Object    obj       = null;
            Component component = null;

            CSSceneTools.OpenSceneResult openSceneResult = null;

            if (!batchMode && Location == RecordLocation.Scene)
            {
                openSceneResult = CSSceneTools.OpenScene(Path);
                if (!openSceneResult.success)
                {
                    return(false);
                }
            }

            obj = GetObjectWithThisIssue();

            if (obj == null)
            {
                if (batchMode)
                {
                    Debug.LogWarning(Maintainer.LogPrefix + "Can't find Object for issue:\n" + this);
                }
                else
                {
                    MaintainerWindow.ShowNotification("Couldn't find Object " + transformPath);
                }
                return(false);
            }

            if (!string.IsNullOrEmpty(componentName) && obj is GameObject)
            {
                component = GetComponentWithThisIssue(obj as GameObject);

                if (component == null)
                {
                    if (batchMode)
                    {
                        Debug.LogWarning(Maintainer.LogPrefix + "Can't find component for issue:\n" + this);
                    }
                    else
                    {
                        MaintainerWindow.ShowNotification("Can't find component " + componentName);
                    }

                    return(false);
                }
            }

            var fixResult = IssuesFixer.FixObjectIssue(this, obj, component, Kind);

            if (!batchMode && Location == RecordLocation.Scene && openSceneResult != null)
            {
                CSSceneTools.SaveScene(openSceneResult.scene);
                CSSceneTools.CloseOpenedSceneIfNeeded(openSceneResult);
            }

            return(fixResult);
        }
Пример #2
0
        internal override FixResult PerformFix(bool batchMode)
        {
            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"));
                }
            }

            var 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);
        }