コード例 #1
0
    /// <summary> Adds a new selector-like (like a constructor) </summary>
    /// <param name="options"> The options in chronological order, as text </param>
    /// <param name="position"> The position of the selector </param>
    /// <param name="anchorposition"> The position, where the selector is anchored </param>
    /// <param name="line_color"> The color of the line conn </param>
    /// <returns> The selector </returns>
    private SelectorLike AddNewSelectorLike(string[] options, Vector2 position)
    {
        GameObject selectorobj = Instantiate(GameObject.Find("map_selector_simple"));

        selectorobj.transform.SetParent(SceneGlobals.map_canvas.transform);
        selectorobj.transform.position = position;

        SelectorLike selector = Loader.EnsureComponent <SelectorLike>(selectorobj);

        selector.options_str = options;

        selector.Init();
        return(selector);
    }
コード例 #2
0
    public void Init(SelectorLike p_parent, byte p_num, Sprite icon, int pflags, int pfunction)
    {
        parent          = p_parent;
        num             = p_num;
        audio_          = Globals.audio;
        img             = GetComponent <Image>();
        icon_img        = transform.GetChild(1).GetComponent <Image>();
        icon_img.sprite = icon;

        label_text = GetComponentInChildren <Text>();
        label      = label_text.text;
        img.color  = idle;
        flags      = pflags;
        function   = pfunction;
    }
コード例 #3
0
ファイル: SelectorLike.cs プロジェクト: bionick7/4040Machines
    /// <summary> Spawns a child to the Selector </summary>
    /// <param name="button"> Where the child comes from </param>
    /// <param name="child_options"> The new options for the child </param>
    /// <returns> The Selectorlike of the child, or null if the button is not valid </returns>
    public SelectorLike SpawnChild(string button, string[] child_options, object[] obj_arr = null, Sprite[] icons = null, int[] flags = null, int[] functions = null)
    {
        if (child != null)
        {
            try {
                Destroy(child.gameObject);
            } catch { }
        }
        sbyte pos = -1;

        for (int i = 0; i < options_str.Length; i++)
        {
            if (options_str [i] == button)
            {
                pos = (sbyte)i;
            }
        }
        if (pos == -1)
        {
            return(null);                   // "What are you even doing?"
        }
        GameObject selectorobj = Instantiate(GameObject.Find("map_selector_simple"));

        selectorobj.transform.SetParent(SceneGlobals.map_canvas.transform);

        // Setting foelds of new_child
        SelectorLike new_child = Loader.EnsureComponent <SelectorLike>(selectorobj);

        new_child.options_str      = child_options;
        new_child.options_icons    = icons;
        new_child.options_flags    = flags;
        new_child.option_functions = functions;
        new_child.targets          = targets;
        new_child.Init();

        new_child.Position  = UpperLeft + new Vector2(width + new_child.width / 2, -new_child.head_height);
        new_child.draggable = false;
        new_child.transform.SetParent(transform, true);
        child = new_child;

        return(new_child);
    }