public override string ToString() { bool hasParent = null != ParentGroupAdapter; return(string.Format(@"ComponentAdapter: {0} ParentContainerAdapter: {1} ParentIsStage: {2} ParentIsStage: {3} ParentHasAbsoluteLayout: {4} ParentUsesLayoutDescriptor: {5} ParentLayout: {6} ParentHasAbsoluteLayout: {7}", ComponentAdapter, hasParent ? ParentGroupAdapter.ToString() : "-", hasParent, hasParent ? ParentIsStage.ToString() : "-", hasParent ? ParentHasAbsoluteLayout.ToString() : "-", hasParent ? ParentUsesLayoutDescriptor.ToString() : "-", //hasParent ? ParentLayoutDescriptor.ToString() : "-", hasParent ? ParentLayout.ToString() : "-", ParentHasAbsoluteLayout)); }
internal static void Process(List <Node> nodes) { if (nodes.Count == 0) { return; } //Debug.Log(string.Format("Processing {0} moves in edit mode.", nodes.Count)); foreach (Node node in nodes) { /** * 1. Process transforms * */ Transform transform = node.Transform; if (null == node.Transform) { throw new Exception("Transform is null"); } /*if (null == transform) * continue; // ROOT*/ //Debug.Log("node.Transform: " + transform); ComponentAdapter adapter = GuiLookup.GetAdapter(transform); bool isStage = adapter is StageAdapter; Transform oldParentTransform = node.OldParentTransform; Transform newParentTransform = node.ParentTransform; /* This happens when a stage moved to root */ if (null == newParentTransform && !isStage) { continue; // not a stage, return (if stage, should process) - only stage could be added to root } /** * The adapter was moved * It is still placed on the same (moved) transform * We are accessing the old and the new parent adapter via transforms: * 1. old parent transform could be referenced using the node.OldParentTransform * 2. new parent transform could be referenced using the node.ParentTransform * */ GroupAdapter oldParentAdapter = null != oldParentTransform? GuiLookup.GetAdapter(oldParentTransform) as GroupAdapter: null; GroupAdapter newParentAdapter = null != newParentTransform? GuiLookup.GetAdapter(newParentTransform) as GroupAdapter: null; Debug.Log(string.Format("[{0}] -> moving from [{1}] to [{2}]", adapter, null == oldParentAdapter ? "-" : oldParentAdapter.ToString(), null == newParentAdapter ? "-" : newParentAdapter.ToString() )); /** * 2. Sanity check * */ if (null == newParentAdapter && !isStage) { throw new Exception("eDriven.Gui components could be added to containers only"); } /** * 3. Process adapters * */ if (null != oldParentAdapter) { oldParentAdapter.RemoveChild(adapter); ParentChildLinker.Instance.Update(oldParentAdapter); } if (null != newParentAdapter) { newParentAdapter.AddChild(adapter, true); ParentChildLinker.Instance.Update(newParentAdapter); } /** * 4. Set transform * */ node.Transform.parent = newParentTransform; } }