private static void ProcessScriptableObjectAsset() { var path = assetConjunctions.asset.Path; var mainAsset = AssetDatabase.LoadMainAssetAtPath(path); if (mainAsset == null) { return; } currentObjectCache = null; currentLocation = Location.ScriptableObjectAsset; var addSettings = new EntryAddSettings { componentIndex = -1, }; TraverseObjectProperties(mainAsset, mainAsset, addSettings); }
private static bool OnGameObjectTraverse(ObjectTraverseInfo traverseInfo) { var target = traverseInfo.current; currentObjectCache = null; //Debug.Log("OnGameObjectTraverse " + target); if (traverseInfo.inPrefabInstance) { //Debug.Log("traverseInfo.dirtyComponents " + traverseInfo.dirtyComponents); var prefabAssetSource = CSPrefabTools.GetAssetSource(target); if (prefabAssetSource != null) { var instanceId = prefabAssetSource.GetInstanceID(); TryAddEntryToMatchedConjunctions(target, instanceId, null); if (traverseInfo.dirtyComponents == null) { traverseInfo.skipCurrentTree = true; return(true); } } } var thumbnail = AssetPreview.GetMiniThumbnail(target); if (thumbnail != null && (thumbnail.hideFlags & HideFlags.HideAndDontSave) == 0) { var addSettings = new EntryAddSettings { prefix = "[Object Icon]", }; TryAddEntryToMatchedConjunctions(target, thumbnail.GetInstanceID(), addSettings); } CSTraverseTools.TraverseGameObjectComponents(traverseInfo, OnGameObjectComponentTraverse); return(true); }
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); } }
private static void ProcessPrefab() { var path = assetConjunctions.asset.Path; var assetObject = AssetDatabase.LoadMainAssetAtPath(path); if (assetObject == null) { return; } var prefabRootGameObject = assetObject as GameObject; if (prefabRootGameObject == null) { return; } currentLocation = Location.PrefabAssetGameObject; CSTraverseTools.TraversePrefabGameObjects(prefabRootGameObject, true, OnGameObjectTraverse); // specific cases handling for main asset ----------------------------------------------------- /*var importSettings = AssetImporter.GetAtPath(path) as ModelImporter; * if (importSettings == null) return; * * var settings = new EntryAddSettings { suffix = "| Model Importer: RIG > Source" }; * TryAddEntryToMatchedConjunctions(assetConjunctions.conjunctions, prefabRootGameObject, importSettings.sourceAvatar, settings); * * for (var i = 0; i < importSettings.clipAnimations.Length; i++) * { * var clipAnimation = importSettings.clipAnimations[i]; * settings.suffix = "| Model Importer: Animations [" + clipAnimation.name + "] > Mask"; * TryAddEntryToMatchedConjunctions(assetConjunctions.conjunctions, prefabRootGameObject, clipAnimation.maskSource, settings); * }*/ var allObjectsInPrefab = AssetDatabase.LoadAllAssetsAtPath(path); foreach (var objectOnPrefab in allObjectsInPrefab) { if (objectOnPrefab == null) { continue; } currentObjectCache = null; if (objectOnPrefab is GameObject || objectOnPrefab is Component) { continue; } currentObjectCache = null; currentLocation = Location.PrefabAssetObject; var addSettings = new EntryAddSettings { componentIndex = -1, }; TraverseObjectProperties(objectOnPrefab, objectOnPrefab, addSettings); /*if (AssetDatabase.IsMainAsset(objectOnPrefab)) * { * * } * else*/ { // specific cases handling ------------------------------------------------------------------------ /*if (objectOnPrefab is BillboardAsset) * { * var billboardAsset = objectOnPrefab as BillboardAsset; * var settings = new EntryAddSettings { suffix = "| BillboardAsset: Material" }; * TryAddEntryToMatchedConjunctions(assetConjunctions.conjunctions, billboardAsset, billboardAsset.material, settings); * } * else if (objectOnPrefab is TreeData) * { * CachedObjectData objectInAssetCachedData = null; * InspectComponent(assetConjunctions.conjunctions, objectOnPrefab, objectOnPrefab, -1, true, ref objectInAssetCachedData); * }*/ } } }