private void SetModifyValue(PrefabComponent component, TreeViewItem root) { foreach (var diff in component.Diffs) { var item = new TreeViewItem { id = GetId(), displayName = ObjectNames.NicifyVariableName(diff.Name), icon = Styles.InfoTexture, }; foreach (var value in diff.PrevValues) { item.AddChild(new TreeViewItem { id = GetId(), displayName = value, }); } item.AddChild(new TreeViewItem { id = GetId(), displayName = "↓", }); foreach (var value in diff.CurrentValues) { item.AddChild(new TreeViewItem { id = GetId(), displayName = value, }); } root.AddChild(item); } }
/// <summary> /// 差分確認 /// </summary> private static void AddRecursive(Transform transform, PrefabObject info) { info.Flag = TargetFlag.None; var components = transform.GetComponents <Component>(); foreach (var component in components) { if (!AssetDatabase.TryGetGUIDAndLocalFileIdentifier(component, out var guid, out long id)) { continue; } var index = info.Components.FindIndex(cc => cc.ID == id); if (index >= 0) { info.Components[index].Flag = TargetFlag.None; continue; } var c = new PrefabComponent(component.GetType(), id, TargetFlag.Sub); info.Components.Add(c); } var count = transform.childCount; for (var i = 0; i < count; i++) { var child = transform.GetChild(i); if (!AssetDatabase.TryGetGUIDAndLocalFileIdentifier(child.gameObject, out var guid, out long id)) { continue; } var index = info.Child.FindIndex(c => c.ID == id); if (index >= 0) { AddRecursive(child, info.Child[index]); } else { // 前にしかない info.Child.Add(Recursive(child, TargetFlag.Sub)); } } }
/// <summary> /// Create Prefab Data /// </summary> private static PrefabObject Recursive(Transform transform, TargetFlag flag) { var info = new PrefabObject(transform.name, flag); { if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(transform.gameObject, out string guid, out long id)) { info.ID = id; } } var nestedRoot = PrefabUtility.GetNearestPrefabInstanceRoot(transform); info.IsNestedPrefab = nestedRoot != null; var components = transform.GetComponents <Component>(); foreach (var component in components) { if (!AssetDatabase.TryGetGUIDAndLocalFileIdentifier(component, out string guid, out long id)) { continue; } var c = new PrefabComponent(component.GetType(), id, flag); info.Components.Add(c); } var count = transform.childCount; for (var i = 0; i < count; i++) { var child = transform.GetChild(i); info.Child.Add(Recursive(child, flag)); } return(info); }