コード例 #1
0
ファイル: PixelScene.cs プロジェクト: Wiladams/NewTOAPIA
        void CreateGrayscaleImage()
        {
            GLDraw drawer = new GLDraw(GI);

            byte[] lumdata = new byte[fPixmap.Width * fPixmap.Height];
            fModifiedPixels = new GLPixelData(fPixmap.Width, fPixmap.Height, TextureInternalFormat.Luminance8, GLPixelFormat.Luminance, PixelType.UnsignedByte, lumdata);

            // Make sure we get full color first
            gl.glPixelTransferf(gl.GL_RED_SCALE, 1.0f);
            gl.glPixelTransferf(gl.GL_GREEN_SCALE, 1.0f);
            gl.glPixelTransferf(gl.GL_BLUE_SCALE, 1.0f);

            //    // First draw image into color buffer
            GI.DrawPixels(0, 0, fPixmap);

            //    // Scale colors according to NSTC standard
            gl.glPixelTransferf(gl.GL_RED_SCALE, 0.3f);
            gl.glPixelTransferf(gl.GL_GREEN_SCALE, 0.59f);
            gl.glPixelTransferf(gl.GL_BLUE_SCALE, 0.11f);

            //    // Read pixles into buffer (scale above will be applied)
            GI.ReadPixels(0, 0, fModifiedPixels);

            //    // Return color scaling to normal
            gl.glPixelTransferf(gl.GL_RED_SCALE, 1.0f);
            gl.glPixelTransferf(gl.GL_GREEN_SCALE, 1.0f);
            gl.glPixelTransferf(gl.GL_BLUE_SCALE, 1.0f);
        }
コード例 #2
0
        private void OnRender(object sender, double delta)
        {
            GLDraw.Fill(ref backgroundColor);
            var root = (PBTTaskTreeControl <DataType>)TreeContainer.Controls.First().Controls.FirstOrDefault(c => c is PBTTaskTreeControl <DataType>);

            if (root != null)
            {
                lines.Clear();
                float scale = Math.Min(InnerWidth / (float)root.Width, InnerHeight / (float)root.Height);
                RenderSubtree(root, 0, 0, scale);

                GLDraw.PrepareCustomDrawing();
                var sr = GLDraw.CurrentScreenRect;
                GL.Color3(Color.White);
                GL.LineWidth(scale);
                GL.Enable(EnableCap.LineSmooth);
                GL.Begin(PrimitiveType.Lines);
                for (int i = 0; i < lines.Count; i++)
                {
                    GL.Vertex2(sr.X + lines[i].Item1.X, sr.Y + lines[i].Item1.Y);
                    GL.Vertex2(sr.X + lines[i].Item2.X, sr.Y + lines[i].Item2.Y);
                }
                GL.End();

                GL.LineWidth(2.0f);
                GL.Begin(PrimitiveType.LineLoop);
                GL.Vertex2(sr.X + TreeContainer.ScrollPosition.X * scale, sr.Y + TreeContainer.ScrollPosition.Y * scale);
                GL.Vertex2(sr.X + (TreeContainer.ScrollPosition.X + TreeContainer.InnerWidth) * scale, sr.Y + TreeContainer.ScrollPosition.Y * scale);
                GL.Vertex2(sr.X + (TreeContainer.ScrollPosition.X + TreeContainer.InnerWidth) * scale, sr.Y + (TreeContainer.ScrollPosition.Y + TreeContainer.InnerHeight) * scale);
                GL.Vertex2(sr.X + TreeContainer.ScrollPosition.X * scale, sr.Y + (TreeContainer.ScrollPosition.Y + TreeContainer.InnerHeight) * scale);
                GL.End();
            }
        }
コード例 #3
0
 private void FixedUpdate()
 {
     if (!room.IsActive)
     {
         return;
     }
     curAngle = GetLookRotAngle(this.transform.position, targetMovePos);
     this.transform.localRotation = Quaternion.Euler(Vector3.forward * (curAngle));
     if (room.IsAlert)
     {
         if (targetMovePos == (Vector2)PlayerManager.player.position && PlayerIsWithinRange(noticeRange))
         {
             TryFire();
             GLDraw.DrawLine(this.transform.position, targetMovePos, GameManager.roomGenerationFields.dangerColor);
         }
         else
         {
             rb.MovePosition(Vector3.MoveTowards(this.transform.position, targetMovePos, moveSpeed * Time.deltaTime * GameManager.timeScale));
             GLDraw.DrawLine(this.transform.position, targetMovePos, GameManager.roomGenerationFields.warningColor);
         }
     }
     else
     {
         rb.MovePosition(Vector3.MoveTowards(this.transform.position, targetMovePos, moveSpeed * Time.deltaTime * GameManager.timeScale));
         GLDraw.DrawLine(this.transform.position, targetMovePos, GameManager.roomGenerationFields.moveColor);
         if (PlayerIsWithinRange(noticeRange) && PlayerIsWithinFOV())
         {
             GLDraw.DrawLine(this.transform.position, PlayerManager.player.position, GameManager.roomGenerationFields.warningColor);
             if (HasDirectLineOFSight(this.transform.position, PlayerManager.player.position, 0))
             {
                 AlertRoom(true);
             }
         }
     }
 }
コード例 #4
0
        private Point RenderSubtree(PBTTaskTreeControl <DataType> ttc, int x, int y, float scale)
        {
            // add offset
            if (ttc.Parent is GLGroupLayout)
            {
                x += ttc.Parent.X; y += ttc.Parent.Y;
            }
            x += ttc.X; y += ttc.Y;

            // draw box
            var       tc     = ttc.TaskControl;
            Rectangle border = new Rectangle(
                (int)((x + tc.X) * scale),
                (int)((y + tc.Y) * scale),
                (int)(tc.Width * scale),
                (int)(tc.Height * scale));
            Rectangle content      = new Rectangle(border.X + 1, border.Y + 1, border.Width - 2, border.Height - 2);
            var       borderColor  = tc.Skin.BorderColor;
            var       contentColor = tc.Skin.BackgroundColor;

            GLDraw.FillRect(ref border, ref borderColor);
            GLDraw.FillRect(ref content, ref contentColor);
            //GLDraw.Text((GLFontText)typeof(GLLabel).GetField("textProcessed", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(tc.title), ref content, ref textColor);
            Point bottom = new Point(border.X, border.Y + border.Height);
            float dx     = border.Width / (float)(ttc.Subtrees.Count + 1);

            // draw subtrees
            for (int i = 0; i < ttc.Subtrees.Count; i++)
            {
                bottom.X = border.X + (int)(dx + i * dx);
                lines.Add(new Tuple <Point, Point>(bottom, RenderSubtree(ttc.Subtrees[i], x, y, scale)));
            }
            return(new Point((int)(border.X + border.Width / 2.0), border.Y));
        }
コード例 #5
0
 void LinksGUI()
 {
     if (currentGraph != null && currentGraph.links != null)
     {
         foreach (AG_NodeLink link in currentGraph.links)
         {
             GLDraw.DrawConnectingCurve(link.beginningPoint.imageRect.center, link.endingPoint.imageRect.center, Color.blue, 1.3f);
         }
     }
 }
コード例 #6
0
 void Awake()
 {
     if (instance)
     {
         DestroyImmediate(this);
         return;
     }
     instance = this;
     SetMaterial();
     linesZOff = new List <Line>();
 }
コード例 #7
0
    private void OnPostRender()
    {
        pos = transform.position + transform.forward * 10 + transform.up * 5 + transform.right * 7;
        shapesMaterial.SetPass(0);
        Graphics.DrawMeshNow(GLDraw.CreateArrow(Color.red, 1), pos, Quaternion.Euler(90, 0, 0));
        GL.Begin(GL.LINES);
        GL.Color(Color.red);
        GL.Vertex(pos);
        GL.Vertex(pos - Vector3.forward * 1);

        GL.End();
    }
コード例 #8
0
ファイル: PointSet.cs プロジェクト: coolzoom/WPFOpenTK_Modify
 /// <summary> Draw the points </summary>
 /// <remarks> Not very efficient. Use a <c>DisplayList</c> to render quickly </remarks>
 public override void Draw()
 {
     GL.PushAttrib(AttribMask.PointBit);
     GL.PointSize(PointSize);
     using (GLDraw.Begin(BeginMode.Points))
     {
         foreach (var point in points)
         {
             GL.Vertex3(point);
         }
     }
     GL.PopAttrib();
 }
コード例 #9
0
 /// <summary>
 /// 绘制连线
 /// </summary>
 void DrawNodeConnectLine()
 {
     if (NodeParent.m_SelectNodeLineBegin != null)
     {
         //Debug.Log("rttttttttttttt");
         GLDraw.DrawBezier(NodeParent.m_SelectNodeLineBegin.m_Pos, Event.current.mousePosition, 100, Color.red, 2);
     }
     //  Debug.Log("DrawNodeConnectLine " + m_AllConnectedLinePoints.Count);
     foreach (var item in m_AllConnectedLinePoints)
     {
         GLDraw.DrawBezier(item.m_BeginNodeLintPoint.m_Pos, item.m_EndNodeLintPoint.m_Pos, 100, Color.green, 2);
     }//绘制所有的连线
 }
コード例 #10
0
ファイル: AITreeEditor.cs プロジェクト: wdb4tiancai/version
    private Vector2 DrawRoot(TreeNode node, Vector2 offset, bool isRuning, RunStatus?state, out Vector2 current)
    {
        var             tempOffset = new Vector2(offset.x + offsetx + width, offset.y);
        float           offex      = tempOffset.x;
        var             expand     = this [node.guid];
        List <LineData> points     = new List <LineData> ();

        if (expand.Expanded)
        {
            for (var i = 0; i < node.childs.Count; i++)
            {
                if (node.childs [i] == currentDrag)
                {
                    continue;
                }
                RunStatus?cRunstate;
                var       runing = CheckRunning(node.childs [i].guid, out cRunstate);
                var       mine   = tempOffset;
                var       or     = DrawRoot(node.childs [i], tempOffset, runing, cRunstate, out mine);
                var       h      = Mathf.Max(height + offsety, or.y);
                offex = Mathf.Max(offex, or.x);

                points.Add(new LineData {
                    point = new Vector2(mine.x, mine.y + 5), IsRunning = runing
                });
                tempOffset.y += h;
            }
        }
        var t             = Mathf.Max(0, (tempOffset.y - offset.y - height));
        int currentHeight = height;

        if (this [node.guid].OnEdited)
        {
            currentHeight = editHeight;
            runstate      = GetComposite(node.guid);
            //runNodeName = node.ToString();
        }
        var rect = new Rect(offset.x, offset.y + (t / 2), width, currentHeight);

        this[node.guid] = DrawNode(rect, node, expand, node.childs.Count > 0, isRuning, state);

        foreach (var p in points)
        {
            GLDraw.DrawConnectingCurve(new Vector2(rect.xMax + 10, rect.center.y), p.point,
                                       p.IsRunning? Color.yellow: Color.black, p.IsRunning?2:1);
        }

        current = rect.position;

        return(new Vector2(offex, Mathf.Max(height + offsety, t + offsety + currentHeight)));
    }
コード例 #11
0
    /// <summary>
    /// 绘制坐标系箭头
    /// </summary>
    private void DrawCoordinateArrow(Transform target)
    {
        Vector3 position = target.position;
        Vector3 euler    = target.eulerAngles;
        // 画坐标轴的箭头 (箭头的锥顶不是它自身坐标的forword)
        Mesh meshX = GLDraw.CreateArrow(m_SelectedAxis == RuntimeHandleAxis.X ? m_SelectedColor : Color.red, m_ArrowScale * m_ScreenScale);

        Graphics.DrawMeshNow(meshX, position + target.right * m_HandleScale * m_ScreenScale, target.rotation * Quaternion.Euler(0, 0, -90));
        Mesh meshY = GLDraw.CreateArrow(m_SelectedAxis == RuntimeHandleAxis.Y ? m_SelectedColor : Color.green, m_ArrowScale * m_ScreenScale);

        Graphics.DrawMeshNow(meshY, position + target.up * m_HandleScale * m_ScreenScale, target.rotation);
        Mesh meshZ = GLDraw.CreateArrow(m_SelectedAxis == RuntimeHandleAxis.Z ? m_SelectedColor : Color.blue, m_ArrowScale * m_ScreenScale);

        Graphics.DrawMeshNow(meshZ, position + target.forward * m_HandleScale * m_ScreenScale, target.rotation * Quaternion.Euler(90, 0, 0));
    }
コード例 #12
0
ファイル: EditorGLTools.cs プロジェクト: useada/ARPG-Game
    public static void DrawTitleRect(Rect rect, string title, string content, Color color, Color bg, float width)
    {
        GLDraw.DrawFillBox(rect, color, bg, width);
        int top   = 20;
        var lRect = new Rect(rect.x, rect.y + 2, rect.width, top);

        GLDraw.DrawLine(
            new Vector2(rect.x, lRect.yMax),
            new Vector2(rect.x + rect.width, lRect.yMax),
            color, 1);
        GUI.Label(lRect, title);
        var bRect = new Rect(rect.x, rect.y + top + 2, rect.width, rect.height - top);

        GUI.Label(bRect, content);
    }
コード例 #13
0
 private void AlertRoom(bool _status)
 {
     if (room.IsAlert && _status)
     {
         return;
     }
     room.IsAlert = _status;
     if (_status)
     {
         Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Enemy"), LayerMask.NameToLayer("Enemy"), false);
         for (int i = 0; i < room.enemyTransforms.Count; i++)
         {
             GLDraw.DrawLine(this.transform.position, room.enemyTransforms[i].position, GameManager.roomGenerationFields.infoColor, 0.15f);
         }
     }
     else
     {
         //Physics2D.IgnoreLayerCollision(LayerMask.NameToLayer("Enemy"), LayerMask.NameToLayer("Enemy"), true);
     }
 }
コード例 #14
0
    /// <summary>
    /// 绘制坐标系小正方体
    /// </summary>
    private void DrawCoordinateCube(Transform target)
    {
        Vector3 position = target.position;
        Vector3 euler    = target.eulerAngles;

        // 画坐标轴的小方块
        m_ShapesMaterial.SetPass(0);
        Mesh meshX = GLDraw.CreateCubeMesh(m_SelectedAxis == RuntimeHandleAxis.X ? m_SelectedColor : Color.red, Vector3.zero, m_CubeScale * m_ScreenScale);

        Graphics.DrawMeshNow(meshX, position + target.right * m_HandleScale * m_ScreenScale, target.rotation * Quaternion.Euler(0, 0, -90));
        Mesh meshY = GLDraw.CreateCubeMesh(m_SelectedAxis == RuntimeHandleAxis.Y ? m_SelectedColor : Color.green, Vector3.zero, m_CubeScale * m_ScreenScale);

        Graphics.DrawMeshNow(meshY, position + target.up * m_HandleScale * m_ScreenScale, target.rotation);
        Mesh meshZ = GLDraw.CreateCubeMesh(m_SelectedAxis == RuntimeHandleAxis.Z ? m_SelectedColor : Color.blue, Vector3.zero, m_CubeScale * m_ScreenScale);

        Graphics.DrawMeshNow(meshZ, position + target.forward * m_HandleScale * m_ScreenScale, target.rotation * Quaternion.Euler(90, 0, 0));

        Mesh meshO = GLDraw.CreateCubeMesh(m_SelectedAxis == RuntimeHandleAxis.XYZ ? m_SelectedColor : Color.white, Vector3.zero, m_CubeScale * m_ScreenScale);

        Graphics.DrawMeshNow(meshO, position, target.rotation);
    }
コード例 #15
0
        private void OnRender(object sender, double delta)
        {
            if (Subtrees.Count == 0)
            {
                return;
            }

            // draw connection lines
            GLDraw.PrepareCustomDrawing();
            var sr = GLDraw.CurrentScreenRect;

            GL.Color3(Color.White);
            GL.LineWidth(1.0f);
            GL.Enable(EnableCap.LineSmooth);
            GL.Begin(PrimitiveType.Lines);
            for (int i = 0; i < Subtrees.Count; i++)
            {
                var src = new OpenTK.Vector2(
                    sr.X + TaskControl.X + TaskControl.Width * (i + 1) / (Subtrees.Count + 1),
                    sr.Y + TaskControl.Outer.Bottom + 1);
                var dst = new OpenTK.Vector2(
                    sr.X + Subtrees[i].Parent.X + Subtrees[i].Parent.Inner.X + Subtrees[i].X + Subtrees[i].Inner.X + Subtrees[i].TaskControl.X + Subtrees[i].TaskControl.Width / 2,
                    sr.Y + Subtrees[i].Parent.Y + Subtrees[i].Parent.Inner.Y + Subtrees[i].Y + Subtrees[i].Inner.Y + Subtrees[i].TaskControl.Y + 1);

                float srcX2 = src.X + (dst.X - src.X) * 0.02f;
                float dstX2 = dst.X - (dst.X - src.X) * 0.02f;

                GL.Vertex2(src);
                GL.Vertex2(srcX2, src.Y + 2);

                GL.Vertex2(srcX2, src.Y + 2);
                GL.Vertex2(dstX2, dst.Y - 2);

                GL.Vertex2(dstX2, dst.Y - 2);
                GL.Vertex2(dst);
            }
            GL.End();
        }
コード例 #16
0
    private void OnGUI()
    {
        Repaint();
        //GetPlayingInfo ();
        Color color = Color.black;
        float lS    = 230;

        DrawOp();


        if (data == null)
        {
            return;
        }

        _scroll = GUI.BeginScrollView(new Rect(0, 0, position.width - lS, position.height), _scroll, view);

        var currentView = new Rect(_scroll.x, _scroll.y, position.width - lS, position.height);

        BeginWindows();
        var offsetX   = 50;
        var offsetY   = 10;
        var sizeX     = 200;
        var sizeY     = 60;
        var sizeYBase = 100;

        Vector2 cOffset = new Vector2(offsetX + sizeX + offsetX, offsetY);

        Vector2            eOffset   = new Vector2(cOffset.x + sizeX + offsetX, offsetY);
        float              maxY      = 0;
        int                indexC    = 100;
        List <TargetPoint> cEndPoint = new List <TargetPoint> ();

        foreach (var i in data.Containers)
        {
            int indexE       = indexC * 100;;
            var oldOffset    = eOffset;
            var listEndPoint = new List <Vector2> ();
            foreach (var e in i.effectGroup)
            {
                var eRect = new Rect(eOffset, new Vector2(sizeX, sizeY));
                if (Event.current.type == UnityEngine.EventType.ContextClick)
                {
                    if (eRect.Contains(Event.current.mousePosition))
                    {
                        GenericMenu m = new GenericMenu();
                        m.AddItem(new GUIContent("Delete"), false, DeleteEffectGroupDe,
                                  new DeleteEffectGroup {
                            egroup = e, Container = i
                        });
                        m.AddSeparator("");
                        m.AddItem(new GUIContent("Edit Effects"), false, ShowEffectGroup, e);
                        m.ShowAsContext();
                        Event.current.Use();
                    }
                }
                if (DrawWindow(indexE, eRect, EffectWindow, e.key))
                {
                    ShowObject(e);
                }

                listEndPoint.Add(new Vector2(eOffset.x, eOffset.y + 5));
                eOffset = new Vector2(eOffset.x, eOffset.y + offsetY + sizeY);
                indexE++;
            }

            var center = oldOffset.y + ((eOffset.y - oldOffset.y) / 2);
            if (maxY < center)
            {
                maxY = center;
            }
            var cRect = new Rect(new Vector2(cOffset.x, maxY), new Vector2(sizeX, sizeY));


            if (DrawWindow(indexC, cRect,
                           EventWindow, i.type.ToString()))
            {
                ShowObject(i);
            }

            if (IsRuning(i.type))
            {
                cEndPoint.Add(new TargetPoint(Color.yellow, new Vector2(cOffset.x, maxY + 5), 2));
                GLDraw.DrawBox(cRect, Color.yellow, 2);
            }
            else
            {
                cEndPoint.Add(new TargetPoint(color, new Vector2(cOffset.x, maxY + 5), 1));
            }


            if (Event.current.type == UnityEngine.EventType.ContextClick)
            {
                if (cRect.Contains(Event.current.mousePosition))
                {
                    GenericMenu m = new GenericMenu();
                    m.AddItem(new GUIContent("Delete"), false, DeleteEvent, i);
                    m.AddSeparator("");
                    m.AddItem(new GUIContent("Add Effect Group"), false, AddEffectGroup, i);
                    if (!string.IsNullOrEmpty(i.layoutPath))
                    {
                        m.AddItem(new GUIContent("Open Layout Editor"), false, OpenLayout, i);
                    }
                    m.ShowAsContext();
                    Event.current.Use();
                }
            }
            var start = new Vector2(cOffset.x + sizeX, maxY + sizeY / 2);
            foreach (var p in listEndPoint)
            {
                if (currentView.Contains(start) && currentView.Contains(p))
                {
                    GLDraw.DrawConnectingCurve(start, p, color, 1);
                }
            }
            maxY += offsetY + sizeY;
            indexC++;
        }


        var rectBase = new  Rect(new Vector2(offsetX, offsetY + maxY / 2), new Vector2(sizeX, sizeYBase));

        if (Event.current.type == UnityEngine.EventType.ContextClick)
        {
            if (rectBase.Contains(Event.current.mousePosition))
            {
                GenericMenu m = new GenericMenu();
                m.AddItem(new GUIContent("Add Event"), false, AddEvent, data);
                m.AddSeparator("");
                m.AddItem(new GUIContent("Save"), false, Save, data);
                m.AddItem(new GUIContent("Save As"), false, SaveAs, data);
                m.ShowAsContext();
                Event.current.Use();
            }
        }

        if (DrawWindow(0,
                       rectBase,
                       MagicWindow, data.name))
        {
            ShowObject(data);
        }
        // content



        var startBase = new Vector2(offsetX + sizeX, offsetY + maxY / 2 + sizeYBase / 2);

        foreach (var p in cEndPoint)
        {
            if (currentView.Contains(startBase) && currentView.Contains(p.point))
            {
                GLDraw.DrawConnectingCurve(startBase, p.point, p.color, p.withd);
            }
        }

        EndWindows();
        GUI.EndScrollView();



        view = new Rect(0, 0, eOffset.x + sizeX + offsetX, Mathf.Max(maxY, eOffset.y));

        var view2P = new Rect(position.width - lS, 0, lS, position.height);

        GUILayout.BeginArea(view2P);
        GUILayout.BeginVertical(GUILayout.Width(lS - 10));
        GUILayout.Label("Property");
        scrollProperty = GUILayout.BeginScrollView(scrollProperty);
        GUILayout.BeginVertical();
        if (currentObj != null)
        {
            PropertyDrawer.DrawObject(currentObj);
        }
        GUILayout.EndVertical();
        GUILayout.EndScrollView();
        GUILayout.EndVertical();
        GUILayout.EndArea();

        GLDraw.DrawLine(new Vector2(position.width - lS, 0),
                        new Vector2(position.width - lS, position.height), color, 1);
    }
コード例 #17
0
    void OnGUI()
    {
        Repaint();
        if (groupData == null)
        {
            return;
        }
        var leftWidth = 200;
        var height    = 50;
        var color     = Color.black;
        var topHeight = 25;

        var rectLeft = new Rect(0, topHeight, position.width - leftWidth, position.height - topHeight);

        //var rectRight = new Rect (rectLeft.width , 0, leftWidth , position.height);

        GUILayout.BeginArea(new Rect(0, 0, rectLeft.width, topHeight));
        GUILayout.BeginHorizontal(GUILayout.Height(topHeight), GUILayout.Width(rectLeft.width));

        index = EditorGUILayout.Popup(index, _effectNames);
        if (GUILayout.Button("Create", GUILayout.Width(70)))
        {
            if (index >= 0)
            {
                var t      = _effects [index];
                var effect = EffectBase.CreateInstance(t);
                groupData.Add(effect);
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        var re = new Rect(rectLeft);

        re.width = re.width + 20;
        _scroll  = GUI.BeginScrollView(re, _scroll, new Rect(0, 0, rectLeft.width, groupData.Count * 50));
        float h = 0;

        foreach (var i in groupData)
        {
            var attrs = i.GetType().GetCustomAttributes(typeof(EditorEffectAttribute), false) as EditorEffectAttribute[];
            var name  = i.GetType().Name;
            if (attrs.Length > 0)
            {
                name = attrs [0].Name;
            }

            var rect = new Rect(0, h, rectLeft.width, height);
            GUI.Label(new Rect(10, h + 5, 200, 16), name);
            GUI.Label(new Rect(10, h + 20, 200, 16), i.ToString());
            GLDraw.DrawBox(rect, color, 1);
            if (current == i)
            {
                GLDraw.DrawBox(new Rect(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4), Color.green, 2);
            }
            else
            {
                if (Event.current.type == UnityEngine.EventType.MouseDown)
                {
                    if (rect.Contains(Event.current.mousePosition))
                    {
                        current = i;
                        Event.current.Use();
                    }
                }
            }

            if (Event.current.type == UnityEngine.EventType.ContextClick)
            {
                if (rect.Contains(Event.current.mousePosition))
                {
                    GenericMenu m = new GenericMenu();
                    m.AddItem(new GUIContent("Delete"), false, DeleteThis, i);
                    m.ShowAsContext();
                    //Event.current.Use ();
                }
            }

            h += height;
        }

        GUI.EndScrollView();


        GUILayout.BeginArea(new Rect(position.width - leftWidth + 16, 0, leftWidth - 20, position.height));
        GUILayout.BeginVertical();
        GUILayout.Label("Property", GUILayout.Height(20));
        scrollProperty = GUILayout.BeginScrollView(scrollProperty);
        GUILayout.BeginVertical();
        if (current != null)
        {
            PropertyDrawer.DrawObject(current, "EFFECT");
        }
        GUILayout.EndVertical();
        GUILayout.EndScrollView();
        GUILayout.EndVertical();
        GUILayout.EndArea();

        GLDraw.DrawLine(new Vector2(rectLeft.width, 0), new Vector2(rectLeft.width, position.height), color, 1);
    }
コード例 #18
0
    void OnGUI()
    {
        GetPlayingInfo();
        int offset = 2;

        Repaint();
        var group = new Rect(5, position.height - 30, 250, 25);

        GUI.Box(new Rect(3, position.height - 55, 226, 50), "Operator");
        GUILayout.BeginArea(group);

        GUILayout.BeginHorizontal(GUILayout.Width(250));

        if (GUILayout.Button("Run", GUILayout.Width(50)))
        {
            //release
            PlayLayout();
        }

        if (GUILayout.Button("Open", GUILayout.Width(50)))
        {
            Open();
        }
        if (GUILayout.Button("Save", GUILayout.Width(50)))
        {
            Save();
        }

        if (GUILayout.Button("Save As", GUILayout.Width(50)))
        {
            SaveAs();
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        if (line == null)
        {
            return;
        }
        int   topHeight = 30;
        int   leftWidth = 240;
        Color color     = Color.black;
        var   rectTop   = new Rect(0, 0, position.width - leftWidth, topHeight);


        currentzTime = Mathf.Min(currentzTime, line.Time);
        if (currentObj == line)
        {
            if (Event.current.type == EventType.mouseDrag)
            {
                if (rectTop.Contains(Event.current.mousePosition))
                {
                    currentzTime = line.Time * (Event.current.mousePosition.x / rectTop.width);
                    if (EditorApplication.isPaused)
                    {
                        if (currentzTime < s && lastStep != 0)
                        {
                            PlayLayout();
                        }
                        s = Time.deltaTime;
                        var now = (lastStep - 1) * s;
                        if (now <= currentzTime)
                        {
                            if ((DateTime.Now - lastTime).TotalSeconds >= s)
                            {
                                lastTime = DateTime.Now;
                                lastStep++;
                                EditorApplication.Step();
                                //currentzTime = now;
                            }
                        }
                    }
                    Event.current.Use();
                }
            }
        }


        if (Event.current.type == EventType.ContextClick)
        {
            if (rectTop.Contains(Event.current.mousePosition))
            {
                GenericMenu m = new GenericMenu();
                //m.AddItem (new GUIContent ("查看属性"), false, ShowProperty, line);
                m.AddSeparator("");
                foreach (var i in _layouts)
                {
                    m.AddItem(new GUIContent(i.Value), false, CreateLayout, i.Key);
                }
                m.ShowAsContext();

                Event.current.Use();
            }
        }


        if (currentObj != line)
        {
            if (Event.current.type == EventType.mouseDown)
            {
                if (rectTop.Contains(Event.current.mousePosition))
                {
                    ShowProperty(line);
                    Event.current.Use();
                }
            }
        }

        int layoutHeight = 35;

        var viewLayout = new Rect(0, topHeight, rectTop.width + 18, position.height - topHeight);
        var vewSize    = new Rect(0, 0, rectTop.width, line.Layouts.Count * (layoutHeight + 1));


        _scroll = GUI.BeginScrollView(viewLayout, _scroll, vewSize);
        for (var i = 0; i < line.Layouts.Count; i++)
        {
            var l      = line.Layouts[i];
            var points = line.FindPointByGuid(l.GUID);

            var rect = new Rect(0, i * (layoutHeight + 1), rectTop.width, layoutHeight);
            //var name = string.Empty;
            var attrs = l.GetType().GetCustomAttributes(typeof(EditorLayoutAttribute), false) as  EditorLayoutAttribute[];
            if (attrs.Length > 0)
            {
                name = attrs[0].Name;
            }
            GLDraw.DrawBox(rect, currentObj == l? Color.green:color, 1);

            foreach (var point in points)
            {
                var   time     = point.Time;
                int   withd    = 1;
                float xt       = rect.width * (time / line.Time);
                var   rectTick = new Rect(xt - 5, rect.yMin, 10, rect.height);

                //GLDraw.DrawBox(rectTick, Color.yellow, 2);

                if (Event.current.type == EventType.ContextClick)
                {
                    if (rectTick.Contains(Event.current.mousePosition))
                    {
                        GenericMenu m = new GenericMenu();
                        m.AddItem(new GUIContent("DeletePoint"), false, DeletePoint, point);
                        m.ShowAsContext();
                        Event.current.Use();
                    }
                }

                if (currentPoint == point)
                {
                    withd = 2;
                }
                else
                {
                    if (Event.current.type == EventType.mouseDown)
                    {
                        if (rectTick.Contains(Event.current.mousePosition))
                        {
                            currentPoint = point;
                        }
                    }
                }


                GLDraw.DrawLine(new Vector2(xt, rect.y), new Vector2(xt, rect.y + rect.height), color, 1);
                GLDraw.DrawTick(new Vector2(xt, rect.y), color, withd, rect.height);
                GUI.Label(new Rect(xt, rect.y + 2, 200, 16), string.Format("{0:0.00}s", time));
            }

            if (Event.current.type == EventType.mouseDrag)
            {
                if (rect.Contains(Event.current.mousePosition))
                {
                    if (currentPoint != null && currentPoint.GUID == l.GUID)
                    {
                        var rT = line.Time * Event.current.mousePosition.x / rect.width;
                        currentPoint.Time = rT;
                        Event.current.Use();
                    }
                }
            }

            if (Event.current.type == EventType.ContextClick)
            {
                if (rect.Contains(Event.current.mousePosition))
                {
                    GenericMenu m = new GenericMenu();
                    m.AddItem(new GUIContent("AddPoint"), false, AddPoint, l);
                    m.AddSeparator("-");
                    m.AddItem(new GUIContent("DeleteLayout"), false, DeleteLayout, l);
                    //m.AddSeparator ("");
                    m.ShowAsContext();

                    Event.current.Use();
                }
            }

            if (currentObj != l)
            {
                if (Event.current.type == EventType.mouseDown)
                {
                    if (rect.Contains(Event.current.mousePosition))
                    {
                        if (currentObj != l)
                        {
                            ShowProperty(l);//	currentObj ;
                        }
                        Event.current.Use();
                    }
                }
            }


            GUI.Label(new Rect(2, rect.y + 16, 300, 20), l.ToString());
        }
        GUI.EndScrollView();



        GUILayout.BeginArea(new Rect(position.width - leftWidth, 0, leftWidth, position.height));
        scrollProperty = GUILayout.BeginScrollView(scrollProperty);
        GUILayout.BeginVertical(GUILayout.Width(leftWidth - 25), GUILayout.Height(position.height - 2));
        if (currentObj != null)
        {
            PropertyDrawer.DrawObject(currentObj);
        }
        GUILayout.EndVertical();
        GUILayout.EndScrollView();
        GUILayout.EndArea();



        //selected
        if (currentObj == line)
        {
            GLDraw.DrawBox(
                new Rect(rectTop.x + offset, rectTop.y + offset, rectTop.width - offset * 2, rectTop.height - offset * 2),
                Color.green, 2);
        }
        //show Lines
        GUI.Label(new Rect(0, 0, 200, 20), string.Format("Time: {1:0.0}s of {0:0.0}s ", line.Time, currentzTime));
        var   count = (int)((rectTop.width / 100) * 10);
        float x     = 0;

        for (var i = 0; i <= count; i++)
        {
            //pre100FixeTick
            float h = 0;
            if (i % 10 == 0)
            {
                h = rectTop.height;
            }
            else if (i % 5 == 0)
            {
                h = rectTop.height * 0.5f;
            }
            else
            {
                h = rectTop.height * 0.2f;
            }

            GLDraw.DrawLine(new Vector2(x, topHeight), new Vector2(x, topHeight - h), color, 1);
            if (h == rectTop.height)
            {
                GUI.Label(new Rect(x, 16, 20, 20), string.Format("{0:0.0}", line.Time * ((float)i / (float)count)));
            }
            x += (100 / pre100FixeTick);
        }
        {
            var w = rectTop.width * (currentzTime / line.Time);
            GLDraw.DrawLine(new Vector2(rectTop.width, 0), new Vector2(rectTop.width, position.height), color, 1);
            GLDraw.DrawLine(new Vector2(0, topHeight), new Vector2(rectTop.width, topHeight), color, 1);
            GLDraw.DrawLine(new Vector2(w, 0), new Vector2(w, position.height), Color.green, 1);
        }
        if (currentRunTime != null)
        {
            var w = rectTop.width * (currentRunTime.Value / line.Time);
            GUI.Label(new Rect(w, topHeight, 50, 20), string.Format("{0:0.0}s",
                                                                    (float)currentRunTime.Value));
            GLDraw.DrawLine(new Vector2(w, 0), new Vector2(w, position.height), Color.yellow, 2);
        }
    }
コード例 #19
0
ファイル: AITreeEditor.cs プロジェクト: wdb4tiancai/version
    private void OnDrawGUI()
    {
        if (root == null)
        {
            if (Event.current.type == EventType.ContextClick)
            {
                GenericMenu m = new GenericMenu();
                m.AddItem(new GUIContent("Open Tree"), false, OpenTree);
                m.AddSeparator("");
                ProcessMenu(m, null);
                m.ShowAsContext();
            }
            if (!string.IsNullOrEmpty(currenPath))
            {
                OpenTree(currenPath);
            }
        }
        else
        {
            runstate = null;
            //runNodeName = string.Empty;
            var rect = new Rect(0, 0, position.width, position.height);
            //scroll = GUI.BeginScrollView(rect, scroll, new Rect(0, 0, lastoffset.x, lastoffset.y));
            Vector2   mine;
            RunStatus?runState;
            var       runing = CheckRunning(root.guid, out runState);
            //GUI.BeginClip (rect);
            lastoffset = DrawRoot(root, new Vector2(offsetx, offsety), runing, runState, out mine);
            //GUI.EndClip ();
            //lastoffset.x;

            if (currentDrag != null)
            {
                var p     = Event.current.mousePosition;
                var prect = new Rect(p.x, p.y, width, height);
                DrawNode(prect, currentDrag, new StateOfEditor(), false, false, null);
            }



            if (Event.current.type == EventType.mouseUp)
            {
                if (currentDrag != null)
                {
                    currentDrag     = null;
                    currentShowDrag = null;
                }
            }

            if (Event.current.type == EventType.MouseDrag)
            {
                currentShowDrag = null;
            }

            if (currentShowDrag.HasValue)
            {
                GLDraw.DrawFillBox(currentShowDrag.Value, Color.black, Color.green, 1);
            }
            //GUI.EndScrollView();
        }
    }