public void Redraw()
        {
            if (waveElementPrefab == null)
            {
                Debug.LogError("SignalFragmentRackHandler.Redraw(): NULL waveElementPrefab"); return;
            }
            if (content == null)
            {
                Debug.LogError("SignalFragmentRackHandler.Redraw(): NULL content"); return;
            }

            content.AutoRebaseOffsets();
            ClearContents();

            ISignalHandler signalHandler = content as ISignalHandler;

            for (int i = 0; i < fragmentMaxLength; i++)
            {
                if (signalHandler.HasValuesAt(i, loopLength: fragmentMaxLength))
                {
                    AdjustSizeToElementCount(i + 1);
                    RectTransform newElementTransform = Instantiate(waveElementPrefab, transform).transform as RectTransform;

                    newElementTransform.position = new Vector3(GetElementWidth(i), 0, 0);
                    //newElementTransform.rect.
                }
            }
        }
Ejemplo n.º 2
0
        //ENDOF Implementación ISignalHandler

        //Implementación ISignalContainer
        //Adjust offset and Re-organize contents so that the earliest element sits at position 0 and every element keeps its absolute position. Acts recursively
        //Returns this element’s new offset
        void ISignalContainer.AutoRebaseOffsets()
        {
            //loop once through the list of children trying to determine target offset
            int lowestOffset = int.MaxValue;

            foreach (ISignalContent child in contents)
            {
                ISignalContainer childAsContainer = child as ISignalContainer;
                //propagate the AutoRebaseOffsets call to container elements, so they also have a 0-index offset
                if (childAsContainer != null)
                {
                    childAsContainer.AutoRebaseOffsets();
                }

                //keep the lowest offset out of every contained element to determine zero-index offset
                if (child.Offset < lowestOffset)
                {
                    lowestOffset = child.Offset;
                }
            }

            //skip restructuring offsets if they area already 0-aligned
            if (lowestOffset == 0)
            {
                return;
            }

            //now that we know the position of the earliest element, adjust this container's and every content's offset
            //so lowest element sits a position 0
            _offset += lowestOffset;

            foreach (ISignalContent child in contents)
            {
                child.Offset -= lowestOffset;
            }
        }