Search Unity

[STILL UNSOLVED]Help Updating UI Polygons

Discussion in 'Scripting' started by Collin__Patrick, Feb 13, 2016.

  1. Collin__Patrick

    Collin__Patrick

    Joined:
    May 20, 2015
    Posts:
    188
    I am creating a "Stat Polygon" which if you are not familiar with it, it's a polygon that stretches in different directions based on a certain stat. Example attached.

    I am having problems updating the polygon when the mouse hovers over a button. I should also note that if I edit the script and save it while in play mode the polygon updates and gets stuck again.

    This is my code:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI.Extensions;
    4. public class CharacterStatPolyTest : MonoBehaviour {
    5.  
    6.     public GameObject innerPoly;
    7.  
    8.     private float speedPoly;
    9.     private float strengthPoly;
    10.     private float magicPoly;
    11.     private float agilityPoly;
    12.     private float defensePoly;
    13.     private float luckPoly;
    14.    
    15.     // Update is called once per frame
    16.     void Update () {
    17.         innerPoly.GetComponent <StatPolygon> ().VerticesDistances [0] = speedPoly/10;
    18.         innerPoly.GetComponent <StatPolygon> ().VerticesDistances [1] = strengthPoly/10;
    19.         innerPoly.GetComponent <StatPolygon> ().VerticesDistances [2] = magicPoly/10;
    20.         innerPoly.GetComponent <StatPolygon> ().VerticesDistances [3] = agilityPoly/10;
    21.         innerPoly.GetComponent <StatPolygon> ().VerticesDistances [4] = defensePoly/10;
    22.         innerPoly.GetComponent <StatPolygon> ().VerticesDistances [5] = luckPoly/10;
    23.     }
    24.     public void HoverUnnamed1Poly(){
    25.         speedPoly = GameInformation.Unnamed2Speed;
    26.         strengthPoly = GameInformation.Unnamed2Strength;
    27.         magicPoly = GameInformation.Unnamed2Magic;
    28.         agilityPoly = GameInformation.Unnamed2Agility;
    29.         defensePoly = GameInformation.Unnamed2Defense;
    30.         luckPoly = GameInformation.Unnamed2Luck;
    31.     }
    32.  
    33. }
     

    Attached Files:

  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    Don't worry about this, the players aren't going to be editing scripts whilst they're being used... o_O

    how are you trying to call "HoverUnnamed1Poly"?
     
  3. Collin__Patrick

    Collin__Patrick

    Joined:
    May 20, 2015
    Posts:
    188
    I have a pointer enter event on a UI button triggering it. I know its being triggered because I have other things that also happen and work when the pointer enters.
     
  4. Collin__Patrick

    Collin__Patrick

    Joined:
    May 20, 2015
    Posts:
    188