Пример #1
0
        private FindUsageResultElement CreateRequest([NotNull] IUnityYamlReference currentReference, [CanBeNull] IUnityYamlReference selectedReference)
        {
            var monoScriptDocument = currentReference.ComponentDocument;

            var sourceFile = monoScriptDocument?.GetSourceFile();

            if (sourceFile == null)
            {
                return(null);
            }

            var pathElements = UnityObjectPsiUtil.GetGameObjectPathFromComponent(mySceneProcessor, currentReference.ComponentDocument).RemoveEnd("\\").Split("\\");

            // Constructing path of child indices
            var consumer = new UnityChildPathSceneConsumer();

            mySceneProcessor.ProcessSceneHierarchyFromComponentToRoot(monoScriptDocument, consumer);


            if (!GetPathFromAssetFolder(sourceFile, out var pathFromAsset, out var fileName, out var extension))
            {
                return(null);
            }
            bool needExpand = currentReference == selectedReference;
            bool isPrefab   = extension.Equals(UnityYamlConstants.Prefab, StringComparison.OrdinalIgnoreCase);

            return(new FindUsageResultElement(isPrefab, needExpand, pathFromAsset, fileName, pathElements, consumer.RootIndices.ToArray().Reverse().ToArray()));
        }
Пример #2
0
        public override RdUsageGroup CreateModel(IOccurrence occurrence, IOccurrenceBrowserDescriptor descriptor)
        {
            using (CompilationContextCookie.GetExplicitUniversalContextIfNotSet())
            {
                if (occurrence is ReferenceOccurrence referenceOccurrence &&
                    referenceOccurrence.PrimaryReference is IUnityYamlReference reference)
                {
                    var document   = reference.ComponentDocument;
                    var sourceFile = document.GetSourceFile();
                    if (sourceFile == null || !sourceFile.IsValid())
                    {
                        return(EmptyModel());
                    }

                    var anchor = UnitySceneDataUtil.GetAnchorFromBuffer(document.GetTextAsBuffer());
                    if (anchor == null)
                    {
                        return(EmptyModel());
                    }

                    return(CreateModel(UnityObjectPsiUtil.GetGameObjectPathFromComponent(myUnitySceneDataLocalCache, sourceFile, anchor)));
                }
            }

            return(EmptyModel());
        }
 public override RdUsageGroup CreateModel(IOccurrence occurrence, IOccurrenceBrowserDescriptor descriptor)
 {
     if (occurrence is ReferenceOccurrence referenceOccurrence &&
         referenceOccurrence.PrimaryReference is IUnityYamlReference reference)
     {
         return(CreateModel(UnityObjectPsiUtil.GetGameObjectPathFromComponent(mySceneProcessor, reference.ComponentDocument)));
     }
     return(EmptyModel());
 }
        public override RdUsageGroup CreateModel(IOccurrence occurrence, IOccurrenceBrowserDescriptor descriptor)
        {
            using (CompilationContextCookie.GetExplicitUniversalContextIfNotSet())
            {
                if (occurrence is ReferenceOccurrence referenceOccurrence &&
                    referenceOccurrence.PrimaryReference is IUnityYamlReference reference)
                {
                    return(CreateModel(
                               UnityObjectPsiUtil.GetGameObjectPathFromComponent(mySceneProcessor,
                                                                                 reference.ComponentDocument)));
                }
            }

            return(EmptyModel());
        }