コード例 #1
0
        private static ExactReferenceData ObjectToReferencingEntry(Object target)
        {
            var referencedObjectAsComponent = target as Component;
            var referencedObjectGameObject  = target as GameObject;

            if (referencedObjectAsComponent != null)
            {
                referencedObjectGameObject = referencedObjectAsComponent.gameObject;
            }

            if (referencedObjectGameObject == null)
            {
                Debug.LogError(Maintainer.ConstructError("Couldn't find referenced Game Object from object " + target));
                return(new ExactReferenceData());
            }

            var referencedSettings = new EntryAddSettings
            {
                componentName = referencedObjectAsComponent != null?CSComponentTools.GetComponentName(referencedObjectAsComponent) : null,
                                    componentIndex = referencedObjectAsComponent != null?CSComponentTools.GetComponentIndex(referencedObjectAsComponent) : -1,
                                                         componentInstanceId = referencedObjectAsComponent != null?referencedObjectAsComponent.GetInstanceID() : -1,
            };

            var reference = EntryGenerator.CreateNewReferenceEntry(EntryFinder.currentLocation,
                                                                   referencedObjectGameObject,
                                                                   referencedObjectGameObject, referencedSettings);

            var assetPath = CSObjectTools.TryGetObjectAssetPath(target);

            var result = new ExactReferenceData
            {
                reference = reference,
                assetPath = assetPath
            };

            return(result);
        }
コード例 #2
0
        private static void TryAddEntryToMatchedConjunctions(Object lookAt, int lookForInstanceId, EntryAddSettings settings)
        {
            var lookAtGameObject = lookAt as GameObject;

            for (var i = 0; i < currentAssetConjunctions.conjunctions.Count; i++)
            {
                var conjunction            = currentAssetConjunctions.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;
                }

                var newEntry = EntryGenerator.CreateNewReferenceEntry(EntryFinder.currentLocation, lookAt, lookAtGameObject, settings);

                conjunction.referencedAtInfo.AddNewEntry(newEntry);
            }
        }