示例#1
0
        protected GameObjectIssueRecord(IssueKind kind, RecordLocation location, string path, GameObject gameObject) : base(kind, location, path)
        {
            var transform = gameObject.transform;

            transformPath = CSEditorTools.GetFullTransformPath(transform);

            if (kind != IssueKind.MissingPrefab)
            {
                objectId = CSObjectTools.GetUniqueObjectId(gameObject);
            }
        }
示例#2
0
        public static ReferencingEntryData CreateNewReferenceEntry(Location currentLocation, Object lookAt, GameObject lookAtGameObject, EntryAddSettings settings)
        {
            var lookAtInstanceId = lookAt.GetInstanceID();
            CachedObjectData cachedObject;

            if (CachedObjects.ContainsKey(lookAtInstanceId))
            {
                cachedObject = CachedObjects[lookAtInstanceId];
            }
            else
            {
                cachedObject = new CachedObjectData
                {
                    objectId         = CSObjectTools.GetUniqueObjectId(lookAt),
                    objectInstanceId = lookAt.GetInstanceID(),
                };

                if (currentLocation == Location.SceneGameObject || currentLocation == Location.PrefabAssetGameObject)
                {
                    if (lookAtGameObject != null)
                    {
                        var transform = lookAtGameObject.transform;
                        cachedObject.transformPath = CSEditorTools.GetFullTransformPath(transform);
                    }
                    else
                    {
                        cachedObject.transformPath = lookAt.name;
                    }
                }
                else if (currentLocation == Location.PrefabAssetObject)
                {
                    cachedObject.transformPath = lookAt.name;
                }
                else
                {
                    cachedObject.transformPath = string.Empty;
                }

                CachedObjects.Add(lookAtInstanceId, cachedObject);
            }

            var newEntry = new ReferencingEntryData
            {
                location         = currentLocation,
                objectId         = cachedObject.objectId,
                objectInstanceId = cachedObject.objectInstanceId,
                transformPath    = cachedObject.transformPath
            };

            if (settings != null)
            {
                newEntry.componentName       = settings.componentName;
                newEntry.componentId         = settings.componentIndex;
                newEntry.componentInstanceId = settings.componentInstanceId;
                newEntry.prefixLabel         = settings.prefix;
                newEntry.suffixLabel         = settings.suffix;
                newEntry.propertyPath        = settings.propertyPath;
            }

            return(newEntry);
        }
        internal static void TryAddEntryToMatchedConjunctions(Object lookAt, int lookForInstanceId, EntryAddSettings settings)
        {
            var lookAtGameObject = lookAt as GameObject;

            for (var i = 0; i < assetConjunctions.conjunctions.Count; i++)
            {
                var conjunction            = assetConjunctions.conjunctions[i];
                var referencedAssetObjects = conjunction.referencedAsset.GetAllAssetObjects();

                var match = false;
                for (var j = 0; j < referencedAssetObjects.Length; j++)
                {
                    if (referencedAssetObjects[j] != lookForInstanceId)
                    {
                        continue;
                    }

                    match = true;
                    break;
                }

                if (!match)
                {
                    continue;
                }

                if (currentObjectCache == null)
                {
                    currentObjectCache          = new CachedObjectData();
                    currentObjectCache.objectId = CSObjectTools.GetUniqueObjectId(lookAt);

                    if (currentLocation == Location.SceneGameObject || currentLocation == Location.PrefabAssetGameObject)
                    {
                        if (lookAtGameObject != null)
                        {
                            var transform = lookAtGameObject.transform;
                            currentObjectCache.transformPath = CSEditorTools.GetFullTransformPath(transform);
                        }
                        else
                        {
                            currentObjectCache.transformPath = lookAt.name;
                        }
                    }
                    else if (currentLocation == Location.PrefabAssetObject)
                    {
                        currentObjectCache.transformPath = lookAt.name;
                    }
                    else
                    {
                        currentObjectCache.transformPath = string.Empty;
                    }
                }

                var newEntry = new ReferencingEntryData
                {
                    location      = currentLocation,
                    objectId      = currentObjectCache.objectId,
                    transformPath = currentObjectCache.transformPath
                };

                if (settings != null)
                {
                    newEntry.componentName = settings.componentName;
                    newEntry.componentId   = settings.componentIndex;
                    newEntry.prefixLabel   = settings.prefix;
                    newEntry.suffixLabel   = settings.suffix;
                    newEntry.propertyPath  = settings.propertyPath;
                }

                conjunction.referencedAtInfo.AddNewEntry(newEntry);
            }
        }