Esempio n. 1
0
        /// <summary>
        /// Calculate and set UI Object's positions.
        /// This must be called for any ui centering to occur, and the Instructions queue should have been filled first with AddAnchoredObject
        /// </summary>
        public static void OrganizeObjects()
        {
            while (Instructions.Count > 0)
            {
                UIInstruction instr = Instructions.Dequeue();

                SetPosition(instr.uiObject, instr.anchor);
                AdjustPositionBySortingMode(instr.uiObject, (int)instr.anchor, instr.sortingMode);
                //Add offset
                instr.uiObject.Location.X += instr.offset.X;
                instr.uiObject.Location.Y += instr.offset.Y;
                //Add to list to keep track of anchored objects
                if (instr.sortingMode != SortingMode.None)
                {
                    AnchoredObjects[(int)instr.anchor].Add(instr.uiObject);
                }

                //Final adjustment for Buttons now that everything is updated
                //since buttons aren't directly manipulated in this class
                if (instr.uiObject is UIText)
                {
                    UIText t = (UIText)instr.uiObject;
                    if (t.Parent != null)
                    {
                        t.Parent.AdjustLocation();
                    }
                }
            }
        }
Esempio n. 2
0
    public GameObject MakeGameObject(States state, Transform parent)
    {
        GameObject go = null;

        if (state.GetType() == typeof(StatesForward))
        {
            go = Instantiate(Resources.Load <GameObject>("UI/Instruction"), parent);
            UIInstruction ui = go.GetComponent <UIInstruction>();
            ui.states = state;
            ui.textInstruction.text = "Avancer";
        }
        else if (state.GetType() == typeof(StatesBackward))
        {
            go = Instantiate(Resources.Load <GameObject>("UI/Instruction"), parent);
            UIInstruction ui = go.GetComponent <UIInstruction>();
            ui.states = state;
            ui.textInstruction.text = "Reculer";
        }
        else if (state.GetType() == typeof(StatesRotate))
        {
            go = Instantiate(Resources.Load <GameObject>("UI/InstructionRotate"), parent);
            UIInstructionRotate ui = go.GetComponent <UIInstructionRotate>();
            ui.states = state as StatesRotate;
        }
        else if (state.GetType() == typeof(StatesIf))
        {
            go = Instantiate(Resources.Load <GameObject>("UI/InstructionIf"), parent);
            UIInstructionIfThen ui = go.GetComponent <UIInstructionIfThen>();
            ui.states = state as StatesIf;
            ui.GenerateContent();
        }
        else if (state.GetType() == typeof(StatesIfElse))
        {
            go = Instantiate(Resources.Load <GameObject>("UI/InstructionIfElse"), parent);
            UIInstructionIfThen ui = go.GetComponent <UIInstructionIfThen>();
            ui.states = state as StatesIfElse;
            ui.GenerateContent();
        }
        else if (state.GetType() == typeof(StatesRepeat))
        {
            go = Instantiate(Resources.Load <GameObject>("UI/InstructionRepeat"), parent);
            UIInstructionRepeat ui = go.GetComponent <UIInstructionRepeat>();
            ui.states = state as StatesRepeat;
            ui.GenerateContent();
        }
        else if (state.GetType() == typeof(StatesColor))
        {
            go = Instantiate(Resources.Load <GameObject>("UI/InstructionColor"), parent);
            UIInstructionColor ui = go.GetComponent <UIInstructionColor>();
            ui.states = state as StatesColor;
        }
        return(go);
    }