public override void Find(AssetMatches assetMatches, Object asset, AssetFinder finder, SearchResult result) { SerializedObject so = new SerializedObject(asset); SerializedProperty property = so.FindProperty("m_DefaultReferences.Array"); if (property != null) { string lastString = string.Empty; SerializedProperty end = property.GetEndProperty(); SerializedPropertyType type = property.propertyType; while (property.Next(type == SerializedPropertyType.Generic) == true && SerializedProperty.EqualContents(property, end) == false) { type = property.propertyType; if (type == SerializedPropertyType.String) { lastString = property.stringValue; } else if (type == SerializedPropertyType.ObjectReference) { ++result.potentialMatchesCount; if (property.objectReferenceValue == this.window.TargetAsset) { assetMatches.matches.Add(new Match(asset, property.propertyPath) { nicifiedPath = Utility.NicifyVariableName(lastString) }); ++result.effectiveMatchesCount; } } } } }
public void Export(StringBuilder buffer, int indentLevel = 0) { if (this.type == AssetMatches.Type.Reference && this.matches.Count == 0 && this.children.Count == 0) { return; } if (this.origin == null) { buffer.Append(SearchResult.ExportIndent, indentLevel); if (this.matches.Count > 0 || this.children.Count > 0) { buffer.Append(this.content.text, 3, this.content.text.Length - 3); buffer.AppendLine(" (NULL)"); } else { buffer.Append(this.content.text, 3, this.content.text.Length - 3); buffer.AppendLine(); } } else { buffer.Append(SearchResult.ExportIndent, indentLevel); string path = indentLevel == 0 ? AssetDatabase.GetAssetPath(origin) : null; if (string.IsNullOrEmpty(path) == false) { buffer.Append(path); } else { buffer.Append(this.content.text, 3, this.content.text.Length - 3); } buffer.AppendLine(); } if (this.Open == true) { AssetMatches.workingAssetMatches = this; for (int j = 0; j < this.matches.Count; j++) { this.matches[j].Export(buffer, indentLevel + 1); } for (int i = 0; i < this.children.Count; i++) { this.children[i].Export(buffer, indentLevel + 1); } } }
private void ReplaceAssetMatches(AssetMatches assetMatches) { this.workingAssetMatches = assetMatches; Undo.RecordObject(assetMatches.origin, "Replace Asset"); for (int j = 0; j < assetMatches.matches.Count; j++) { this.ReplaceMatch(assetMatches.matches[j]); } for (int j = 0; j < assetMatches.children.Count; j++) { this.ReplaceAssetMatches(assetMatches.children[j]); } EditorUtility.SetDirty(assetMatches.origin); }
private void OutputAssetMatches(int indent, AssetMatches assetMatches) { if (assetMatches.type == AssetMatches.Type.Reference && assetMatches.matches.Count == 0 && assetMatches.children.Count == 0) { return; } InternalNGDebug.Log(new string(' ', indent << 1) + assetMatches.origin); for (int i = 0; i < assetMatches.matches.Count; i++) { this.OutputMatch(indent + 1, assetMatches.matches[i]); } for (int i = 0; i < assetMatches.children.Count; i++) { this.OutputAssetMatches(indent + 1, assetMatches.children[i]); } }
public override void Find(AssetMatches assetMatches, Object asset, AssetFinder finder, SearchResult result) { GameObject go = asset as GameObject; finder.BrowseGameObject(result, assetMatches, go.transform); }
public void Draw(NGAssetFinderWindow window, Rect r) { if (this.type == AssetMatches.Type.Reference && this.matches.Count == 0 && this.children.Count == 0) { return; } float w = r.width; r.height = Constants.SingleLineHeight; bool isNull = this.origin == null; if (Event.current.type == EventType.Repaint) { if (r.Contains(Event.current.mousePosition) == true) { EditorGUI.DrawRect(r, NGAssetFinderWindow.HighlightBackground); } else if (isNull == false && Selection.activeObject == this.origin) { EditorGUI.DrawRect(r, NGAssetFinderWindow.SelectedAssetBackground); } } if (isNull == false && (this.origin is Component) == false) { r.width -= AssetMatches.PingButtonWidth; } EditorGUI.BeginDisabledGroup(isNull); { if (this.matches.Count > 0 || this.children.Count > 0) { EditorGUI.BeginChangeCheck(); bool open = EditorGUI.Foldout(r, this.Open, this.content, true); if (EditorGUI.EndChangeCheck() == true) { this.Open = open; } if (string.IsNullOrEmpty(this.content.tooltip) == false) { if (r.Contains(Event.current.mousePosition) == true) { Rect r2 = r; r2.y -= r2.height; EditorGUI.DrawRect(r2, NGAssetFinderWindow.HighlightBackground); GUI.Label(r2, this.content.tooltip); } } r.xMin += ((EditorGUI.indentLevel + 1) * 15F) - 4F; } else { r.xMin += (EditorGUI.indentLevel * 15F) - 4F; } if (this.image != null) { Rect r2 = r; r2.width = r2.height; GUI.DrawTexture(r2, this.image); r.xMin += r2.width; } if (this.matches.Count == 0 && this.children.Count == 0) { r.xMin -= 16F; GUI.Label(r, this.content); r.xMin += 16F; } if (isNull == false && (this.origin is Component) == false) { r.x += r.width; r.width = AssetMatches.PingButtonWidth; if (GUI.Button(r, LC.G("Ping")) == true) { if (Event.current.button != 0 || AssetMatches.lastClick + Constants.DoubleClickTime > EditorApplication.timeSinceStartup) { Selection.activeObject = this.origin; } else { EditorGUIUtility.PingObject(this.origin.GetInstanceID()); } AssetMatches.lastClick = EditorApplication.timeSinceStartup; } } if (this.Open == true) { r.x = 0F; r.y += r.height; r.width = w; EditorGUI.BeginChangeCheck(); ++EditorGUI.indentLevel; AssetMatches.workingAssetMatches = this; for (int i = 0; i < this.matches.Count; i++) { r.height = this.matches[i].GetHeight(); this.matches[i].Draw(window, r); r.y += r.height; } for (int i = 0; i < this.children.Count; i++) { r.height = this.children[i].GetHeight(); this.children[i].Draw(window, r); r.y += r.height; } --EditorGUI.indentLevel; if (EditorGUI.EndChangeCheck() == true && this.origin != null) { EditorUtility.SetDirty(this.origin); } } } EditorGUI.EndDisabledGroup(); }
public abstract void Find(AssetMatches assetMatches, Object asset, AssetFinder finder, SearchResult result);