protected override void Initialize() { /*if (depth != 0) * { * return; * }*/ if (data.reference == null || data.reference.objectInstanceId == 0) { icon = (Texture2D)CSEditorIcons.WarnSmallIcon; return; } var objectInstance = EditorUtility.InstanceIDToObject(data.reference.objectInstanceId); if (objectInstance == null) { icon = (Texture2D)CSEditorIcons.WarnSmallIcon; return; } if (data.reference.componentId >= 0) { icon = (Texture2D)CSEditorIcons.ScriptIcon; if (objectInstance is GameObject) { var component = CSComponentTools.GetComponentWithIndex(objectInstance as GameObject, data.reference.componentId); if (component != null) { var texture = CSAssetsLoader.GetCachedTypeImage(component.GetType()); if (texture != null && texture is Texture2D) { icon = (Texture2D)texture; } else { icon = (Texture2D)CSEditorIcons.ScriptIcon; } } } } else { icon = (Texture2D)CSEditorIcons.GameObjectIcon; } }
private static void OnGameObjectComponentTraverse(ObjectTraverseInfo traverseInfo, Component component, int orderIndex) { if (component == null) return; var target = traverseInfo.current; var componentName = CSComponentTools.GetComponentName(component); if (CSObjectTools.IsHiddenInInspector(component)) { orderIndex = -1; } var addSettings = new EntryAddSettings { componentName = componentName, componentIndex = orderIndex, componentInstanceId = component.GetInstanceID(), }; TraverseObjectProperties(target, component, addSettings); }
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); }