protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
        {
            var sceneName = myWarning.SceneName;

            Assertion.Assert(sceneName != null, "sceneName != null");

            var unityModule = GetUnityModule(solution);

            Assertion.Assert(unityModule != null, "unityModule != null");

            var buildSettings = GetEditorBuildSettings(unityModule);

            var scenes = GetSceneCollection(buildSettings.GetDominantPsiFile <UnityYamlLanguage>() as IYamlFile) as IBlockSequenceNode;

            Assertion.Assert(scenes != null, "scene != null");
            foreach (var entry in scenes.Entries)
            {
                var scene       = entry.Value;
                var sceneRecord = scene as IBlockMappingNode;
                if (sceneRecord == null)
                {
                    continue;
                }

                var path = GetUnityScenePathRepresentation(
                    (sceneRecord.Entries[1].Content.Value as IPlainScalarNode).NotNull("PlainScalarNode:1").Text.GetText());
                var simple = path.Split('/').Last();
                var isEnabledPlaneScalarNode = (sceneRecord.Entries[0].Content.Value as IPlainScalarNode).NotNull("PlainScalarNode:0");
                var isEnabled = isEnabledPlaneScalarNode.Text.GetText().Equals("1");
                if (!isEnabled && (path.Equals(sceneName) || simple.Equals(sceneName)))
                {
                    using (WriteLockCookie.Create(myWarning.Argument.IsPhysical()))
                    {
                        var text = YamlTokenType.NS_PLAIN_ONE_LINE_IN.Create("1");
                        if (isEnabledPlaneScalarNode.Text != null)
                        {
                            LowLevelModificationUtil.ReplaceChildRange(isEnabledPlaneScalarNode.Text, isEnabledPlaneScalarNode.Text, text);
                        }
                        else
                        {
                            LowLevelModificationUtil.AddChild(isEnabledPlaneScalarNode.Text, text);
                        }
                    }
                }

                solution.GetComponent <IDaemon>().Invalidate();
                solution.GetComponent <UnityRefresher>().Refresh(RefreshType.Normal);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public override IReference BindTo(IDeclaredElement element)
        {
            using (WriteLockCookie.Create(myOwner.IsPhysical()))
            {
                var text = YamlTokenType.NS_PLAIN_ONE_LINE_IN.Create(element.ShortName);
                if (myOwner.Text != null)
                {
                    LowLevelModificationUtil.ReplaceChildRange(myOwner.Text, myOwner.Text, text);
                }
                else
                {
                    LowLevelModificationUtil.AddChild(myOwner.Text, text);
                }
            }

            return(this);
        }
Ejemplo n.º 3
0
            public override IReference BindTo(IDeclaredElement element)
            {
                using (WriteLockCookie.Create(myOwner.IsPhysical()))
                {
                    var shaderLabIdentifier = new ShaderLabIdentifier();
                    shaderLabIdentifier.AddChild(new Identifier(element.ShortName));
                    if (myOwner.Identifier != null)
                    {
                        LowLevelModificationUtil.ReplaceChildRange(myOwner.Identifier, myOwner.Identifier,
                                                                   shaderLabIdentifier);
                    }
                    else
                    {
                        LowLevelModificationUtil.AddChild(myOwner.Identifier, shaderLabIdentifier);
                    }
                }

                return(myOwner.Reference);
            }