Exemple #1
0
        void Start()
        {
            gameObject.SetActive(false);
            cam       = Camera.main;
            segmenter = GetComponentInChildren <Segmenter>();

            uiElement = GetComponent <RectTransform>();
            w2c       = new WorldToCanvas(GetComponentInParent <Canvas>());
        }
Exemple #2
0
    void Start()
    {
        cam         = Camera.main;
        pointerRect = GetComponent <RectTransform>();
        pointerRect.gameObject.SetActive(false);

        w2c          = new WorldToCanvas(GetComponentInParent <Canvas>());
        canvasBorder = 0.05f * new Vector2(w2c.canvasRect.rect.width, w2c.canvasRect.rect.height);
    }
Exemple #3
0
    private ProgressBarBehaviour makeMPbar()
    {
        GameObject           canvas = GameObject.FindGameObjectWithTag("Canvas");
        Vector2              pos    = WorldToCanvas.toCanvas(canvas, transform.position + new Vector3(0, 3.0f));
        ProgressBarBehaviour pb     = Instantiate(MP, pos, Quaternion.identity);

        pb.ProgressSpeed = 500;
        pb.SetFillerSizeAsPercentage(100.0f);
        pb.transform.SetParent(canvas.transform, false);
        pb.transform.localScale = new Vector3(0.2f, 0.3f);

        return(pb);
    }
Exemple #4
0
    // Use this for initialization
    void Awake()
    {
        // Caches the damage text's useful components
        damageText        = textObject.GetComponent <Text>();
        textRectTransform = textObject.GetComponent <RectTransform>();
        Shadow[] effects = damageText.GetComponents <Shadow>();         // Get the Outline/Shadow components in the text
        // Cycle through each effect on the text
        for (int i = 0; i < effects.Length; i++)
        {
            // If the effect is of type 'Outline', save the component in the "outline" variable
            if (effects[i] is Outline)
            {
                textOutline = (Outline)effects[i];
            }
            // Else, the effect is a shadow. Thus, save the component in the "shadow" variable
            else
            {
                textShadow = effects[i];
            }
        }

        // Caches the background image's useful components
        backgroundImage         = backgroundObject.GetComponent <Image>();
        backgroundRectTransform = backgroundObject.GetComponent <RectTransform>();

        // Stores the original scale for the text and background.
        originalTextScale       = textRectTransform.localScale;
        originalBackgroundScale = backgroundRectTransform.localScale;

        // Stores the background image's original color. This is the color the background will preserve when fading in
        originalBackgroundColor = backgroundImage.color;

        // Cache this gameObject's Transform component
        transform = GetComponent <Transform>();

        // Create a 'WorldToCanvas' component, allowing the damage label to be placed over a character's head in the world.
        worldToCanvas = gameObject.AddComponent <WorldToCanvas>();
        // Add a rigidobdy to the "worldToCanvas" component. Allows the damage label to fall down using gravity.
        worldToCanvas.CreateRigidbody();

        //StartCoroutine (Test());
    }
Exemple #5
0
    // Update is called once per frame
    void Update()
    {
        if (displayHPMP == true)
        {
            makedHPbar.gameObject.SetActive(true);
            makedMPbar.gameObject.SetActive(true);

            GameObject canvas = GameObject.FindGameObjectWithTag("Canvas");
            Vector3    pos    = WorldToCanvas.toCanvas(canvas, transform.position + new Vector3(0, 3.2f));
            makedHPbar.transform.position = pos;

            Vector3 pos2 = WorldToCanvas.toCanvas(canvas, transform.position + new Vector3(0, 3.0f));
            makedMPbar.transform.position = pos2;
        }

        if (displayHPMP == false)
        {
            makedHPbar.gameObject.SetActive(false);
            makedMPbar.gameObject.SetActive(false);
        }
    }