コード例 #1
0
        void OnGUI()
        {
            if (Application.isEditor)
            {
                UpdateSettings();
            }
            Matrix4x4 matrixBackup = GUI.matrix;

            GUIUtility.RotateAroundPivot(angle, pivot);
            GUI.DrawTexture(rect, texture);
            GUI.matrix = matrixBackup;
        }
コード例 #2
0
    public void drawSwipe(float x1, float y1, float x2, float y2)
    {
        Matrix4x4 matrixBackup = GUI.matrix;
        float     dir          = -Mathf.Atan2(y2 - y1, x2 - x1) * Mathf.Rad2Deg;
        float     dist         = Mathf.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));

        GUIUtility.RotateAroundPivot(dir, new Vector2(x1, Screen.height - y1));
        float height = Mathf.Min(dist * 1.1f * (((float)swipeIndicator.height)) / swipeIndicator.width, Screen.height * drawScale);

        GUI.DrawTexture(new Rect(x1, Screen.height - y1 - height / 2, dist * 1.1f, height), swipeIndicator);
        GUI.matrix = matrixBackup;
    }
コード例 #3
0
    void OnGUI()
    {
        Matrix4x4 oldMatrix = GUI.matrix;
        float     thisAngle = Time.frameCount * 4;

        Rect thisRect = new Rect(Screen.width / 2.0f - Spinner.width / 2f, Screen.height / 2.0f - Spinner.height / 2f,
                                 Spinner.width, Spinner.height);

        GUIUtility.RotateAroundPivot(thisAngle, thisRect.center);
        GUI.DrawTexture(thisRect, Spinner);
        GUI.matrix = oldMatrix;
    }
コード例 #4
0
        //Draws the needle for intake air
        private void drawAirNeedle(Vessel v)
        {
            //double prov = airMass(v);
            //double req = getRequiredAir(v);
            double prov, req;

            getRequiredAir(v, out req, out prov);
            double percent = 6;

            if (req > 0)
            {
                percent = prov / req;
            }
            //if (SteamGauges.debug) Log.Info("Air Percent: " + Math.Round(prov, 2) + "/" + Math.Round(req, 2) + " = " + Math.Round(percent, 2));
            //Log.Info("Air Percent: " + Math.Round(percent, 2));
            double angle = 0;

            //right 180 deg is 1 to 5
            if (percent > 6)
            {
                percent = 6d;
            }
            if (percent > 2)
            {
                percent -= 2d;             //Now 0-4
                percent /= 4d;             //now 0-1
                angle    = percent * 180d; //convert to angle
                angle    = 180d - angle;   //rotate the other way
            }
            else if (percent > 1)
            {
                //left 180 is 0-1
                percent -= 1d;
                angle    = percent * 90d;
                angle    = 90d - angle;
                angle   += 180d;
            }
            else
            {
                //0-1 for last 85 degrees
                angle  = percent * 85d;
                angle  = 85d - angle;
                angle += 270;
            }
            //Log.Info("Final Percent: " + Math.Round(percent,2));
            //Log.Info("Air angle: " + Math.Round(angle, 1));
            //Now rotate the GUI and draw the needle
            Vector2 pivotPoint = new Vector2(200 * Scale, 261 * Scale);    //Center of air gauge

            GUIUtility.RotateAroundPivot((float)angle, pivotPoint);
            GUI.DrawTextureWithTexCoords(new Rect(195f * Scale, 205f * Scale, 11f * Scale, 66f * Scale), texture, new Rect(0.8925f, 0.4066f, 0.01375f, 0.0811f));
            GUI.matrix = Matrix4x4.identity;    //Reset rotation matrix
        }
コード例 #5
0
ファイル: tankGUI.cs プロジェクト: rfazmn/Tank-3D
    void OnGUI()
    {
        Matrix4x4 svMat = GUI.matrix;
        Vector2   pivot = drawArrow.center;

        //float angle = transform.eulerAngles.y;

        GUIUtility.RotateAroundPivot(0f, pivot);
        GUI.DrawTexture(drawArrow, arrow);

        GUI.matrix = svMat;
    }
コード例 #6
0
ファイル: Enemy.cs プロジェクト: TimPeeters1/MathGame
    public void Render()
    {
        GUIUtility.RotateAroundPivot(Rotation, Position.ToUnity());

        GUI.color = Color.red;

        GUI.DrawTexture(new Rect(Position.x - Circle.Radius, Position.y - Circle.Radius, visual.width, visual.height), visual);

        GUI.color = Color.white;

        GUI.matrix = Matrix4x4.identity;
    }
コード例 #7
0
        override public void Render(RenderSupport support, float parentAlpha)
        {
            int deg = 0;

            if (this.rotation != 0.0)
            {
                //deg = (int)(this.rotation * 180 / Math.PI);
                deg = (int)this.rotation;
                if (deg != 0)
                {
                    sHelperPoint = support.mvpMatrix.transformCoords(pivotX, pivotY);
                    sPoint.x     = sHelperPoint.x;
                    sPoint.y     = sHelperPoint.y;
                    GUIUtility.RotateAroundPivot(deg, sPoint);
                }
            }

            float alpha = parentAlpha * this.alpha;

            _isRendering = true;
            foreach (DisplayObject child in _children)
            {
                if (child.hasVisibleArea)
                {
                    support.PushMatrix();
                    support.TransformMatrix(child);
                    child.Render(support, alpha);
                    support.PopMatrix();
                }
            }
            _isRendering = false;
            for (int i = 0; i < _cacheAddList.Count; i++)
            {
                int idx = _cacheAddListIdx[i];
                if (idx == _children.Count)
                {
                    _children.Add(_cacheAddList[i]);
                }
                else
                {
                    _children.Insert(idx, _cacheAddList[i]);
                }
            }
            foreach (var obj in _cahcheRemoveList)
            {
                _children.Remove(obj);
            }
            CacheClear();
            if (deg != 0)
            {
                GUIUtility.RotateAroundPivot(-deg, sPoint);
            }
        }
コード例 #8
0
    public static bool DrawSquareButtonAtWorldPoint(Vector3 position, float width, Texture texture, float angle)
    {
        Vector3 screenPosition = Camera.main.WorldToScreenPoint(position);
        Vector2 pivotPoint     = new Vector2(screenPosition.x, Screen.height - screenPosition.y);

        GUIUtility.RotateAroundPivot(angle, pivotPoint);
        bool buttonClick = DrawSquareButtonAtWorldPoint(position, width, texture);

        GUIUtility.RotateAroundPivot(-angle, pivotPoint);

        return(buttonClick);
    }
コード例 #9
0
        public static void DrawFlowIndicatorForFlowEvent(RawFrameDataView.FlowEvent flowEvent, Rect sampleRect, IndicatorAppearanceMode indicatorAppearanceMode)
        {
            float indicatorAngularRotationDegrees;
            var   flowIndicatorRect = IndicatorRectForFlowEventType(flowEvent.FlowEventType, sampleRect, out indicatorAngularRotationDegrees);
            var   color             = IndicatorColorForMode(indicatorAppearanceMode);

            var matrix = GUI.matrix;

            GUIUtility.RotateAroundPivot(indicatorAngularRotationDegrees, flowIndicatorRect.center);
            GUI.DrawTexture(flowIndicatorRect, Styles.texture, ScaleMode.StretchToFill, true, 0f, color, 0f, 0f);
            GUI.matrix = matrix;
        }
コード例 #10
0
ファイル: Draw.cs プロジェクト: uhhhci/VRStrider
 void DrawLine(Vector2 pointA, Vector2 pointB)
 {
     pointA.y     = Screen.height - pointA.y;
     pointB.y     = Screen.height - pointB.y;
     angle        = Mathf.Atan2(pointB.y - pointA.y, pointB.x - pointA.x) * 180f / Mathf.PI;
     length       = (pointA - pointB).magnitude;
     GUI.color    = Color.green;
     matrixBackup = GUI.matrix;
     GUIUtility.RotateAroundPivot(angle, pointA);
     GUI.DrawTexture(new Rect(pointA.x, pointA.y, length, width), lineTex);
     GUI.matrix = matrixBackup;
 }
コード例 #11
0
ファイル: ScreenScript.cs プロジェクト: jkwendorf/ICS163-AR
    void OnGUI()
    {
        GUIUtility.RotateAroundPivot(rotation, pivotPoint);

        GUIStyle myStyle = new GUIStyle(GUI.skin.button);

        myStyle.font = myFont;

        if (GUI.Button(new Rect(left, top, box_X, box_Y), "1", myStyle))
        {
            GameManager.instance.SetGameToken(1);
        }
        if (GUI.Button(new Rect(widthMiddle, top, box_X, box_Y), "2", myStyle))
        {
            GameManager.instance.SetGameToken(2);
        }
        if (GUI.Button(new Rect(right, top, box_X, box_Y), "3", myStyle))
        {
            GameManager.instance.SetGameToken(3);
        }
        if (GUI.Button(new Rect(left, heightMiddle, box_X, box_Y), "4", myStyle))
        {
            GameManager.instance.SetGameToken(4);
        }
        if (GUI.Button(new Rect(widthMiddle, heightMiddle, box_X, box_Y), "5", myStyle))
        {
            GameManager.instance.SetGameToken(5);
        }
        if (GUI.Button(new Rect(right, heightMiddle, box_X, box_Y), "6", myStyle))
        {
            GameManager.instance.SetGameToken(6);
        }
        if (GUI.Button(new Rect(left, bottom, box_X, box_Y), "7", myStyle))
        {
            GameManager.instance.SetGameToken(7);
        }
        if (GUI.Button(new Rect(widthMiddle, bottom, box_X, box_Y), "8", myStyle))
        {
            GameManager.instance.SetGameToken(8);
        }
        if (GUI.Button(new Rect(right, bottom, box_X, box_Y), "9", myStyle))
        {
            GameManager.instance.SetGameToken(9);
        }
        if (GUI.Button(new Rect(farRight, top, quit_X, box_Y), "Reset", myStyle))
        {
            GameManager.instance.ResetGame();
        }
        if (GUI.Button(new Rect(farRight, heightMiddle, quit_X, box_Y), "Quit", myStyle))
        {
            Application.Quit();
        }
    }
コード例 #12
0
    void  OnGUI()
    {
        GUI.DrawTexture(new Rect(dialPos.x, dialPos.y, dialTex.width, dialTex.height), dialTex);
        Vector2   centre        = new Vector2((dialPos.x + dialTex.width) / 2, (dialPos.y + dialTex.height) / 2);
        Matrix4x4 savedMatrix   = GUI.matrix;
        float     speedFraction = speed / topSpeed;
        float     needleAngle   = Mathf.Lerp(stopAngle, topSpeedAngle, speedFraction);

        GUIUtility.RotateAroundPivot(needleAngle, centre);
        GUI.DrawTexture(new Rect(centre.x, centre.y - needleTex.height / 2, needleTex.width, needleTex.height), needleTex);
        GUI.matrix = savedMatrix;
    }
コード例 #13
0
        private void ApplyOrientation()
        {
            GUI.EndGroup();

            this.guiMatrix = GUI.matrix;

            var pivot = this.screenRect.center;

            GUIUtility.RotateAroundPivot((this.orientation == ScreenOrientation.Landscape ? this.GetLandscapeOrientationAngle() : this.GetPortraitOrientationAngle()), pivot);

            //GUILayout.BeginArea(this.screenRect);
        }
コード例 #14
0
    /// <summary>
    /// draws a direction arrow for every current inflictor of damage
    /// </summary>
    void UpdateInflictorArrows()
    {
        if (ArrowTexture == null)
        {
            return;
        }

        for (int v = m_Inflictors.Count - 1; v > -1; v--)
        {
            // remove inflictors that have been destroyed or made inactive
            if ((m_Inflictors[v] == null) ||
                (m_Inflictors[v].Transform == null) ||
                (!vp_Utility.IsActive(m_Inflictors[v].Transform.gameObject)))
            {
                m_Inflictors.Remove(m_Inflictors[v]);
                continue;
            }

            // fade out arrow
            m_ArrowColor.a = (ArrowVisibleDuration - (Time.time - m_Inflictors[v].DamageTime)) / ArrowVisibleDuration;

            // skip any invisible arrows
            if (m_ArrowColor.a < 0.0f)
            {
                continue;
            }

            // get horizontal direction of damage inflictor
            Vector2 pos = new Vector2(Screen.width * 0.5f, Screen.height * 0.5f);
            float   rot = vp_3DUtility.LookAtAngleHorizontal(
                transform.position,
                transform.forward,
                m_Inflictors[v].Transform.position)
                          + ArrowAngleOffset
                          + ((m_Inflictors[v].Transform != transform) ? 0 : 90);        // if damaging self, point straight down
            float scale = (Screen.width * ArrowScale);

            // shake arrows on each instance of incoming damage
            // NOTE: to make the arrows shake individually, you can instead use
            // '(Time.time - m_Inflictors[v].DamageTime)', but it won't look
            // quite as slick ;)
            float push = (ArrowShakeDuration - (Time.time - m_LastInflictorTime)) / ArrowShakeDuration;
            push   = Mathf.Lerp(0, 1, push);
            scale += ((Screen.width / 100) * push);

            // rotate and draw arrow
            Matrix4x4 matrixBackup = GUI.matrix;
            GUIUtility.RotateAroundPivot(rot, pos);
            GUI.color = m_ArrowColor;
            GUI.DrawTexture(new Rect(pos.x, pos.y, scale, scale), ArrowTexture);
            GUI.matrix = matrixBackup;
        }
    }
コード例 #15
0
 void Rotation()
 {
     RoationEnable = true;
     //GUI.Label (new Rect (Pos.width, Pos.height, 300, 30), "Logging In");
     //GUI.Label (new Rect (Pos.width, Pos.height, 300, 30), "%" + percentage.ToString("F0"));
     for (int i = 0; i < 25; i++)
     {
         GUIUtility.RotateAroundPivot(RotationAngle, new Vector2(Pos.width, Pos.height));
         GUI.Label(new Rect(Pos.width * 1f, Pos.height * 1f, 22, 22), RoationPic);
     }
     //GUI.DrawTexture (new Rect (Pos.width, Pos.height, 256, 256), os.Icon[os.SelectedIcon]);
 }
コード例 #16
0
    void OnGUI()
    {
        int sh = Screen.height;
        int sw = Screen.width;

        switch (state)
        {
        case GameState.Ready:
            inputFileName = GUI.TextField(new Rect(sw * 3 / 8, sh / 20, sw / 16, sh / 20), inputFileName);
            if (GUI.Button(new Rect(sw * 3 / 8, sh / 9, sw / 24, sh / 18), "Input"))
            {
                SetOption();
            }
            if (GUI.Button(new Rect(sw * 20 / 48, sh / 2, sw / 24, sh / 8), "Start"))
            {
                FirstLog();
                state = GameState.Game;
            }
            break;

        case GameState.Game:
            int   x   = sw * 11 / 24;
            int   y   = sh * 4 / 5;
            int   w   = sw / 24;
            int   h   = sw / 24;
            float rot = playerCar.GetComponent <Rigidbody>().velocity.magnitude * 5f + 17;

            Vector2 pivotPoint = new Vector2(x + w / 2, y + h / 2);
            GUI.DrawTexture(new Rect(x, y, w, h), meterBackTexture);
            GUIUtility.RotateAroundPivot(rot, pivotPoint);
            GUI.DrawTexture(new Rect(x, y, w, h), meterArrowTexture);
            GUIUtility.RotateAroundPivot(-rot, pivotPoint);
            break;

        case GameState.Pause:
            if (GUI.Button(new Rect(sw * 20 / 48, sh / 2, sw / 24, sh / 8), "Resume"))
            {
                Pause();
            }
            break;

        case GameState.Result:
            if (GUI.Button(new Rect(sw * 20 / 48, sh / 2, sw / 24, sh / 8), "Finish"))
            {
                Application.LoadLevel(0);
            }
            break;

        default:
            break;
        }
    }
コード例 #17
0
    public static void DrawLine(Vector2 pointA, Vector2 pointB, Color color, float width)
    {
        // Save the current GUI matrix, since we're going to make changes to it.
        Matrix4x4 matrix = GUI.matrix;

        // Generate a single pixel texture if it doesn't exist
        if (!lineTex)
        {
            lineTex = new Texture2D(1, 1);
        }

        // Store current GUI color, so we can switch it back later,
        // and set the GUI color to the color parameter
        Color savedColor = GUI.color;

        GUI.color = color;

        // Determine the angle of the line.
        float angle = Vector3.Angle(pointB - pointA, Vector2.right);

        // Vector3.Angle always returns a positive number.
        // If pointB is above pointA, then angle needs to be negative.
        if (pointA.y < pointB.y)
        {
            angle = -angle;
        }

        Debug.Log(pointA);

        // Use ScaleAroundPivot to adjust the size of the line.
        // We could do this when we draw the texture, but by scaling it here we can use
        //  non-integer values for the width and length (such as sub 1 pixel widths).
        // Note that the pivot point is at +.5 from pointA.y, this is so that the width of the line
        //  is centered on the origin at pointA.
        GUIUtility.ScaleAroundPivot(new Vector2((pointB - pointA).magnitude, width), new Vector2(pointA.x, pointA.y));

        // Set the rotation for the line.
        //  The angle was calculated with pointA as the origin.
        GUIUtility.RotateAroundPivot(angle, pointA);

        // Finally, draw the actual line.
        // We're really only drawing a 1x1 texture from pointA.
        // The matrix operations done with ScaleAroundPivot and RotateAroundPivot will make this
        //  render with the proper width, length, and angle.
        Rect rect = new Rect(pointA.x, pointA.y, 1, 1);

        GUI.DrawTexture(rect, lineTex);

        // We're done.  Restore the GUI matrix and GUI color to whatever they were before.
        GUI.matrix = matrix;
        GUI.color  = savedColor;
    }
コード例 #18
0
    private void DrawIndicator(int i)
    {
        if (Time.time > Indicator.time[i])
        {
            return;
        }
        float     angle  = Indicator.AngleSigned(Camera.main.transform.forward, Indicator.pos[i] - this.goPlayer.transform.position, this.goPlayer.transform.up);
        Matrix4x4 matrix = GUI.matrix;

        GUIUtility.RotateAroundPivot(angle, this.v);
        GUI.DrawTexture(this.r, this.tIndicator);
        GUI.matrix = matrix;
    }
コード例 #19
0
 /// <summary>
 /// 将摄像机图像渲染到屏幕,请在OnGUI函数中调用
 /// </summary>
 public static void OnGUI()
 {
     if (camTex != null)
     {
         float half_x = Screen.width / 2f;
         float half_y = Screen.height / 2f;
         GUIUtility.RotateAroundPivot(CamAngle, new Vector2(half_x, half_y));
         GUIUtility.ScaleAroundPivot(new Vector2(Mathf.Sign(CamAngle), 1), new Vector2(half_x, half_y));
         GUI.DrawTexture(new Rect(half_x - half_y, half_y - half_x, Screen.height, Screen.width), camTex);
         GUIUtility.ScaleAroundPivot(new Vector2(Mathf.Sign(CamAngle), 1), new Vector2(half_x, half_y));
         GUIUtility.RotateAroundPivot(-CamAngle, new Vector2(half_x, half_y));
     }
 }
コード例 #20
0
 public override void Draw()
 {
     GUIUtility.RotateAroundPivot(mAngle, Center);
     if (mDelay <= 0f)
     {
         GUIUtil.DrawAnimatedTextureFrame(mRect, mTexture, mFrames + 1, (int)(Time.realtimeSinceStartup * 30f) % mFrames, MirrorX: false, MirrorY: false);
     }
     else
     {
         GUIUtil.DrawAnimatedTextureFrame(mRect, mTexture, mFrames + 1, mIdleFrame, MirrorX: false, MirrorY: false);
     }
     GUI.matrix = Matrix4x4.identity;
 }
コード例 #21
0
        public float FloatAngle(Rect rect, float value)
        {
            Rect knobRect = new Rect(rect.x, rect.y, graphicHeight, graphicHeight);

            Matrix4x4 matrix = GUI.matrix;

            GUIUtility.RotateAroundPivot(value, knobRect.center);

            GUI.DrawTexture(knobRect, circle);
            GUI.matrix = matrix;

            return(value);
        }
コード例 #22
0
    void OnGUI()
    {
        GUI.depth = 0;
        //GUILayout.BeginArea( new Rect(Screen.width/2 +270,Screen.height/2 +200,300,350));
        GUILayout.BeginArea(new Rect(Screen.width / 2 + 390, Screen.height / 2 + 250, 50, 90));

        GUIUtility.RotateAroundPivot(turn, new Vector2(0.0f, 10.0f));
        //GUI.Label( new Rect(Screen.width/2,Screen.height/2,50,100),needle);

        //GUI.Label( new Rect(Screen.width/2,Screen.height/2,50,50),"fryf");
        GUILayout.Label(needle);
        GUILayout.EndArea();
    }
コード例 #23
0
    void OnGUI()
    {
        //Draw Handle;
        Matrix4x4 matrixBackup = GUI.matrix;

        GUIUtility.RotateAroundPivot(steering_Angle, new Vector2(Screen.width / 4, Screen.height));
        GUI.DrawTexture(new Rect(0, Screen.height - Screen.width / 4, Screen.width / 2, Screen.width / 2), steering_Wheel);
        GUI.matrix = matrixBackup;
        //accel button
        GUI.Button(AccelButtonRect, AccelButton);
        //back or break button
        GUI.Button(BackButtonRect, BackButton);
    }
コード例 #24
0
ファイル: GUILine.cs プロジェクト: regstar/OpenSpace4x
    public void Draw()
    {
        // Save the current GUI matrix, since we're going to make changes to it.
        Matrix4x4 matrix     = GUI.matrix;
        Color     SavedColor = GUI.color;

        GUIUtility.RotateAroundPivot(Angle, PointA);
        GUI.color = color;
        GUI.DrawTexture(rect, lineTex, ScaleMode.StretchToFill);

        GUI.matrix = matrix;
        GUI.color  = SavedColor;
    }
コード例 #25
0
    public static void Rotate90Right()
    {
        GUI.matrix = Matrix4x4.identity;

        Vector2 center = new Vector2(Screen.width / 2, Screen.height / 2);

        GUIUtility.RotateAroundPivot(90, center);
        Vector3 offset = Vector3.zero;

        offset.x    = (Screen.width - Screen.height) / 2;
        offset.y    = -(Screen.width - Screen.height) / 2;
        GUI.matrix *= Matrix4x4.TRS(offset, Quaternion.identity, Vector3.one);
    }
コード例 #26
0
        private static void Line(Vector2 a, Vector2 b, float thickness = 4.0f)
        {
            var matrix = GUI.matrix;
            var vector = b - a;
            var angle  = Mathf.Atan2(vector.y, vector.x) * Mathf.Rad2Deg;

            GUIUtility.ScaleAroundPivot(new Vector2((b - a).magnitude, thickness), new Vector2(a.x, a.y + 0.5f));
            GUIUtility.RotateAroundPivot(angle, a);

            GUI.DrawTexture(new Rect(a.x, a.y, 1, 1), EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill, true, 0.0f, Color.black, 0.0f, 0.0f);

            GUI.matrix = matrix;
        }
コード例 #27
0
    void GUILoading()
    {
        if (loading)
        {
            guiRect.Set(-5, -5, Screen.width + 10, Screen.height + 10);
            GUI.Box(guiRect, "");
            GUI.Box(guiRect, "");

            GUIUtility.RotateAroundPivot(rotateAngle, pivotPoint);
            guiRect.Set((Screen.width - loader.width) * 0.5f, (Screen.height * 0.94f - loader.height) * 0.5f, loader.width, loader.height);
            GUI.DrawTexture(guiRect, loader);
        }
    }
コード例 #28
0
ファイル: Graph.cs プロジェクト: robpennock/WoB_Tutorial_BAK
    void DoWindow(int windowID)
    {
        GUI.DragWindow(new Rect(0, 0, 10000, 20));
        int count        = 0;
        int displayCount = 0;

        defaultColor    = GUI.color;
        colorDictionary = new Dictionary <string, Color>();

        GUI.Label(new Rect(GraphWindow.width - 180, 20, 50, 25), "Search");
        scrollBarSearchText = GUI.TextField(new Rect(GraphWindow.width - 130, 20, 60, 25), scrollBarSearchText);

        scrollWindowPos = GUI.BeginScrollView(scrollWindow, scrollWindowPos, new Rect(0, 0, 110, 35 * AnimalList.Count));

        foreach (string animal in AnimalList)
        {
            if (count < colors.Length)
            {
                colorDictionary.Add(animal, colors[count]);
                GUI.color = colors[count];
                if (animal.ToLower().Contains(scrollBarSearchText.ToLower()))
                {
                    if (GUI.Button(new Rect(2, 30 * (displayCount), 80, 30), animal))
                    {
                        if (SelectedAnimalsList.Contains(animal))
                        {
                            SelectedAnimalsList.Remove(animal);
                        }
                        else
                        {
                            SelectedAnimalsList.Add(animal);
                        }
                    }
                    displayCount++;
                }
            }

            count++;
            GUI.color = defaultColor;
        }

        GUI.EndScrollView();

        GUIUtility.RotateAroundPivot(-90, new Vector2(55, 115));
        GUI.Label(new Rect(5, 100, 100, 30), "Biomass");
        GUIUtility.RotateAroundPivot(90, new Vector2(55, 115));

        DrawGraphSkeleton();
        //DrawBarGraph();
        DrawLineGraph();
    }
コード例 #29
0
    void OnGUI()
    {
        if (!play.Active)
        {
            return;
        }

        if (Show)
        {
            GUI.color = Color.green;
            switch (Mode)
            {
            case NavMode.Third:

                break;

            case NavMode.Cockpit:
                if (Crosshair_in)
                {
                    GUI.DrawTexture(new Rect((Screen.width / 2 - Crosshair_in.width / 2) + CrosshairOffset.x,
                                             (Screen.height / 2 - Crosshair_in.height / 2) + CrosshairOffset.y,
                                             Crosshair_in.width, Crosshair_in.height),
                                    Crosshair_in);
                }
                DrawNavEnemy();

                Matrix4x4 matrixBackup = GUI.matrix;
                GUIUtility.RotateAroundPivot(this.gameObject.transform.rotation.eulerAngles.z, new Vector2(Screen.width / 2, Screen.height / 2));

                if (HlineTexture)
                {
                    GUI.DrawTexture(new Rect((Screen.width / 2 - HlineTexture.width / 2), (Screen.height / 2 - HlineTexture.height / 2), HlineTexture.width, HlineTexture.height), HlineTexture);
                }

                if (HlineStepTexture)
                {
                    GUI.DrawTextureWithTexCoords(new Rect((Screen.width / 2 - HlineStepTexture.width / 2), (Screen.height / 2 - 200), HlineStepTexture.width, 400), HlineStepTexture, new Rect(1, this.gameObject.transform.position.y * 0.01f, 1, 5));
                }


                GUI.matrix = matrixBackup;
                GUI.skin.label.alignment = TextAnchor.UpperLeft;
                GUI.Label(new Rect(Screen.width / 2 - 170, Screen.height / 2 - 150, 400, 30), flight.gameObject.GetComponent <Rigidbody>().velocity.magnitude.ToString());
                break;

            case NavMode.None:

                break;
            }
        }
    }
コード例 #30
0
    // =====================================================================================================================
    static void DrawLineMac(Vector2 pointA, Vector2 pointB, Color color, float width, bool antiAlias)
    {
        if (pointA == pointB)
        {
            return;
        }

        Color     savedColor  = GUI.color;
        Matrix4x4 savedMatrix = GUI.matrix;

        float oldWidth = width;

        if (antiAlias)
        {
            width *= 3;
        }
        float angle = Vector3.Angle(pointB - pointA, Vector2.right) * (pointA.y <= pointB.y?1:-1);
        float m     = (pointB - pointA).magnitude;

        if (m > 0.01f)
        {
            Vector3 dz     = new Vector3(pointA.x, pointA.y, 0);
            Vector3 offset = new Vector3((pointB.x - pointA.x) * 0.5f,
                                         (pointB.y - pointA.y) * 0.5f,
                                         0f);

            Vector3 tmp = Vector3.zero;

            if (antiAlias)
            {
                tmp = new Vector3(-oldWidth * 1.5f * Mathf.Sin(angle * Mathf.Deg2Rad), oldWidth * 1.5f * Mathf.Cos(angle * Mathf.Deg2Rad));
            }
            else
            {
                tmp = new Vector3(-oldWidth * 0.5f * Mathf.Sin(angle * Mathf.Deg2Rad), oldWidth * 0.5f * Mathf.Cos(angle * Mathf.Deg2Rad));
            }

            GUI.color  = color;
            GUI.matrix = translationMatrix(dz) * GUI.matrix;
            GUIUtility.ScaleAroundPivot(new Vector2(m, width), new Vector2(-0.5f, 0));
            GUI.matrix = translationMatrix(-dz) * GUI.matrix;
            GUIUtility.RotateAroundPivot(angle, Vector2.zero);
            GUI.matrix = translationMatrix(dz - tmp - offset) * GUI.matrix;

            GUI.DrawTexture(new Rect(0, 0, 1, 1), antiAlias ? adLineTex :  lineTex);
        }

        GUI.matrix = savedMatrix;

        GUI.color = savedColor;
    }