//-------∽-★-∽------∽-★-∽--------∽-★-∽渲染排序∽-★-∽--------∽-★-∽------∽-★-∽--------// //窗口渲染排序 void SortAllPop() { List <IPop> popList = ListUtil.Clone(m_openList); ListUtil.SortOn(popList, new string[] { "layerIdx", "popTime" }, SortOption.DESCENDING); KUIPop pop; int dis; int len = popList.Count; for (int i = 0; i < len; ++i) { pop = popList[i] as KUIPop; dis = m_canvasDisStart + m_canvasDisPer * i; //镜头距离 pop.sortingLayer = pop.layerIdx; pop.sortingOrder = len - i; pop.planeDistance = dis; } m_sortPopCalled = false; }
public static void DescribeChildrenWithGroups(ref StringBuilder sb, Node node, bool richText) { var childNodes = node.ChildNodes; var unprocessedNodes = ListUtil <Node> .Clone(node.ChildNodes); var adapter = node.Adapter; //Debug.Log(@"adapter: " + adapter); var containerAdapter = adapter as GroupAdapter; // Note: the ROOT node has no adapter nor groups defined! if (null != containerAdapter) { ChildGroupPack pack = ChildGroupPack.Read(containerAdapter); // Debug.Log(@"pack: //" + pack); foreach (ChildGroup childGroup in pack.Groups) { sb.AppendLine(StringUtil.Indent(node.Depth + 1, string.Format("== {0} ==", childGroup.GroupName))); foreach (ComponentAdapter componentAdapter in childGroup.Adapters) { var childNode = GetNode(childNodes, componentAdapter); if (null == childNode) { var line = StringUtil.Indent(node.Depth + 1, string.Format("*** Not found ***")); if (richText) { line = (StringUtil.WrapColor(StringUtil.WrapTag(line, "b"), EditorSettings.UseDarkSkin ? "yellow" : "blue")); } sb.AppendLine(line); } else { unprocessedNodes.Remove(childNode); string name = null == childNode.Transform ? "New" : childNode.Transform.name; var isSelected = Selection.activeGameObject == componentAdapter.gameObject; string selected = isSelected ? "*" : string.Empty; string changed = ParentChildLinker.Instance.IsChanged(childNode.AdapterId) ? "[changed]" : string.Empty; var line = StringUtil.Indent(childNode.Depth /* + 1*/, string.Format("{2}{0} [A:{1}]{3}", name, childNode.AdapterId, selected, changed)); if (richText && isSelected) { line = StringUtil.WrapTag(line, "b"); } sb.AppendLine(line); DescribeChildrenWithGroups(ref sb, childNode, richText); } } } } if (unprocessedNodes.Count > 0 && null != node.ParentTransform) { sb.AppendLine(StringUtil.Indent(node.Depth + 1, string.Format("== Orphans =="))); } // orphans foreach (Node childNode in unprocessedNodes) { string name = null == childNode.Transform ? "New" : childNode.Transform.name; var isSelected = (Selection.activeGameObject == childNode.Adapter.gameObject); string selected = isSelected ? "*" : string.Empty; string changed = ParentChildLinker.Instance.IsChanged(childNode.AdapterId) ? "[changed]" : string.Empty; bool isOrphan = !(childNode.Adapter is StageAdapter); string orphan = isOrphan ? "[orphan] " : string.Empty; //string orphan = StringUtil.WrapColor((childNode.Adapter is StageAdapter) ? string.Empty : "[orphan] ", //EditorSettings.UseDarkSkin ? "yellow" : "blue"); var line = StringUtil.Indent(childNode.Depth /* + 1*/, string.Format("{4}{2}{0} [A:{1}]{3}", name, childNode.AdapterId, selected, changed, orphan)); if (isOrphan) { line = StringUtil.WrapColor(StringUtil.WrapTag(line, "b"), EditorSettings.UseDarkSkin ? "yellow" : "blue"); } if (richText && isSelected) { line = StringUtil.WrapTag(line, "b"); } sb.AppendLine(line); DescribeChildrenWithGroups(ref sb, childNode, richText); } }
/** * Return an Array that is populated in the same order as the IList * implementation. * * @throws ItemPendingError if the data is not yet completely loaded * from a remote location */ ///<summary> ///</summary> ///<returns></returns> // ReSharper disable MemberCanBePrivate.Global public virtual List <object> ToList() // ReSharper restore MemberCanBePrivate.Global { return(ListUtil <object> .Clone(Source)); }
/// <summary> /// Recursive! /// </summary> /// <param name="sb"></param> /// <param name="node"></param> private static void DoFix(ref StringBuilder sb, Node node) { bool isRoot = (null == node.Adapter); //if (!isRoot) // Debug.Log(StringUtil.Indent(node.Depth, "Fixing " + node.Adapter)); var childNodes = node.ChildNodes; var unprocessedNodes = ListUtil <Node> .Clone(node.ChildNodes); var adapter = node.Adapter; //Debug.Log(@"adapter: " + adapter); var containerAdapter = adapter as GroupAdapter; //Debug.Log(@"containerAdapter: " + containerAdapter); // Note: the ROOT node has no adapter no groups defined! if (null != containerAdapter) { ChildGroupPack pack = ChildGroupPack.Read(containerAdapter); // Debug.Log(@"pack: //" + pack); foreach (ChildGroup childGroup in pack.Groups) { //sb.AppendLine(StringUtil.Indent(node.Depth + 1, string.Format("== {0} ==", childGroup.GroupName))); //foreach (ComponentAdapter componentAdapter in childGroup.Adapters) for (int i = childGroup.Adapters.Count - 1; i >= 0; i--) { ComponentAdapter componentAdapter = childGroup.Adapters[i]; bool doRemove = false; /** * 1. Handle null * */ if (null == componentAdapter) { //sb.AppendLine(StringUtil.Indent(node.Depth + 1, "*** Not found ***")); // adapter is not child of this container, remove it from the list //toRemove.Add(componentAdapter); doRemove = true; } /** * 2. Not null. Handle the adapter * */ else { var childNode = GetNode(childNodes, componentAdapter); if (null == childNode) { //sb.AppendLine(StringUtil.Indent(node.Depth + 1, "*** Not found ***")); // adapter is not child of this container, remove it from the list //toRemove.Add(componentAdapter); doRemove = true; } else { unprocessedNodes.Remove(childNode); DoFix(ref sb, childNode); } } if (doRemove) { //Debug.Log("list 1: " + ComponentAdapterUtil.DescribeAdapterList(childGroup.Adapters)); childGroup.Adapters.RemoveAt(i); //childGroup.Adapters.Remove(adapterToRemove); if (null != componentAdapter) { sb.AppendLine(string.Format("{0}: {1} [A:{2}] removed", GuiLookup.PathToString(containerAdapter.transform, "->"), componentAdapter, componentAdapter.GetInstanceID())); } else { sb.AppendLine(string.Format("{0}: Adapter at position {1} removed", GuiLookup.PathToString(containerAdapter.transform, "->"), i)); } //Debug.Log("list 2: " + ComponentAdapterUtil.DescribeAdapterList(childGroup.Adapters)); } } } } // orphans foreach (Node childNode in unprocessedNodes) { if (!isRoot) { if (null != containerAdapter) { ChildGroupPack pack = ChildGroupPack.Read(containerAdapter); if (pack.Groups.Count > 0) { pack.Groups[0].Adapters.Add(childNode.Adapter); sb.AppendLine(string.Format("{0}: [{1}] added to the first group", GuiLookup.PathToString(containerAdapter.transform, "->"), childNode.Adapter)); } } } DoFix(ref sb, childNode); } }
/// <summary> /// Takes the snapshot of current values<br/> /// Saves the values to a supplied dictionary /// </summary> /// <param name="dictionary"></param> private void TakeSnapshot(IDictionary <MemberInfo, object> dictionary) { // clear dictionary dictionary.Clear(); // gets all members for this type var members = SaveableMembers.Get(_type); if (null == members) { Debug.LogWarning(string.Format("Cannot find saveable members for type [{0}]", _type)); return; } #if DEBUG if (DebugMode) { _sb = new StringBuilder(); } #endif int count = 1; /** * Loop through all members to get their values * */ foreach (MemberInfo memberInfo in members) { // read value var value = TypeUtil.GetValue(memberInfo, _target); #if DEBUG if (DebugMode) { _sb.AppendLine(string.Format("{0}) {1}: {2}", count, memberInfo.Name, value)); } #endif // ##################################################################### // # Handling the case of old eDriven.Gui collection type // # (converting on-the-fly) // ##################################################################### if (value is IList <string> && !(value is SaveableStringCollection)) { var pers = SaveableStringCollection.FromList((IList <string>)value); #if DEBUG if (DebugMode) { Debug.Log(string.Format(@"{0} Converted from IList<string> to SaveableStringCollection: --------------------------------------------------------- {1}", memberInfo, pers)); } #endif dictionary[memberInfo] = pers; } // ##################################################################### /** * 1. This is a list * Important: In order to save the current values, we have to break the connection to the adapter itself * (or else the collection will be changed with new values and no change between old and new will be detected) * */ // ReSharper disable once CanBeReplacedWithTryCastAndCheckForNull else if (value is List <ComponentAdapter> ) { //Debug.Log("Clonning list: " + memberInfo.Name); dictionary[memberInfo] = ListUtil <ComponentAdapter> .Clone((List <ComponentAdapter>) value); } /** * 2. Cloning cloneables (rather than comparing references) * */ else if (value is ICloneable) { // Debug.Log(@"##### This is ICloneable ##### //" + value); ICloneable cloneable = value as ICloneable; dictionary[memberInfo] = cloneable.Clone(); } /** * 3. Normal values * */ else { dictionary[memberInfo] = value; } count++; } #if DEBUG if (DebugMode) { Debug.Log(string.Format(@"Values read. Target: {0} [{1} saveable members] {2}", _target, members.Count, _sb), _target); } #endif }