private void UpdateDotConnection()
 {
     if (dotConnectionGameObject != null)
     {
         RectTransform dotConnectionRectTransform = dotConnectionGameObject.GetComponent <RectTransform>();
         Vector2       dir      = (lastVisualObject.GetGraphPosition() - GetGraphPosition()).normalized;
         float         distance = Vector2.Distance(GetGraphPosition(), lastVisualObject.GetGraphPosition());
         dotConnectionRectTransform.sizeDelta        = new Vector2(distance, 3f);
         dotConnectionRectTransform.anchoredPosition = GetGraphPosition() + dir * distance * .5f;
         dotConnectionRectTransform.localEulerAngles = new Vector3(0, 0, UtilsClass.GetAngleFromVectorFloat(dir));
     }
 }
Пример #2
0
 // Update each data connection.
 public void UpdateDotConnection()
 {
     if (dotConnectionGameObject != null)
     {
         // A reference to RectTransform object: "It's used to store and manipulate the position, size, and anchoring of a rectangle".
         RectTransform dotConnectionRectTransform = dotConnectionGameObject.GetComponent <RectTransform>();
         Vector2       direction = (lastVisualObject.GetGraphPosition() - GetGraphPosition()).normalized;                // Line Orientation (connection between the two points).
         float         distance  = Vector2.Distance(GetGraphPosition(), lastVisualObject.GetGraphPosition());            // Euclidean distance between the two connection points.
         dotConnectionRectTransform.anchoredPosition = GetGraphPosition() + direction * distance * 0.5f;                 // Definition of the position (it will be the one specified on our input coordinates.
         dotConnectionRectTransform.sizeDelta        = new Vector2(distance, 3f);                                        // Size of our lines.
         dotConnectionRectTransform.localEulerAngles = new Vector3(0, 0, UtilsClass.GetAngleFromVectorFloat(direction)); // Rotate connection line.
     }
 }
Пример #3
0
            private void UpdateDotConnection()
            {
                if (dotConnectionGameObject != null)
                {
                    RectTransform dotConnectionRectTransform = dotConnectionGameObject.GetComponent <RectTransform>();
                    Vector2       dir      = (lastVisualObject.GetGraphPosition() - GetGraphPosition()).normalized;           //stores the direction for the line to face from dot a to b. And then normalizes it?
                    float         distance = Vector2.Distance(GetGraphPosition(), lastVisualObject.GetGraphPosition());       //determines distance between points a and b, to be used for calculating the length of the connecting line

                    dotConnectionRectTransform.sizeDelta        = new Vector2(distance, 3f);                                  //set length of line equal to distance between dots
                    dotConnectionRectTransform.anchoredPosition = GetGraphPosition() + dir * distance * .5f;                  //anchor line's position to halfway between dots a and b
                    dotConnectionRectTransform.localEulerAngles = new Vector3(0, 0, UtilsClass.GetAngleFromVectorFloat(dir)); //not too sure, but seems to calulate an angle from 0 to 360 degrees based on a vector2
                }
            }
 private void UpdateDotConnection()
 {
     if (dotConnectionGameObject != null)
     {
         RectTransform dotConnectionRectTransform = dotConnectionGameObject.GetComponent <RectTransform>();
         Vector2       dir      = (lastVisualObject.GetGraphPosition() - GetGraphPosition()).normalized;
         float         distance = Vector2.Distance(GetGraphPosition(), lastVisualObject.GetGraphPosition());
         dotConnectionRectTransform.sizeDelta        = new Vector2(distance, 3f);
         dotConnectionRectTransform.anchoredPosition = GetGraphPosition() + dir * distance * .5f;
         float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
         dotConnectionRectTransform.localEulerAngles = new Vector3(0, 0, angle);
     }
 }
Пример #5
0
        public IGraphVisualObject CreateGraphVisualObject(Vector2 graphPosition, float graphPositionWidth, string toolTipText)
        {
            GameObject dotGameObject = CreateDot(graphPosition);

            GameObject dotConnectionGameObject = null;

            if (lastLineGraphVisualObject != null)
            {
                dotConnectionGameObject = CreateDotConnection(lastLineGraphVisualObject.GetGraphPosition(), dotGameObject.GetComponent <RectTransform>().anchoredPosition);
            }

            LineGraphVisualObject lineGraphVisualObject = new LineGraphVisualObject(dotGameObject, dotConnectionGameObject, lastLineGraphVisualObject);

            lineGraphVisualObject.SetGraphVisualObjectInfo(graphPosition, graphPositionWidth, toolTipText);
            lastLineGraphVisualObject = lineGraphVisualObject;

            return(lineGraphVisualObject);
        }