Beispiel #1
0
 public void Render()
 {
     if (GameMessage != null)
     {
         GameMessage.Text = String.Format("FPS: {0}", _currentFrameCnt);
     }
     // Backbuffer rendering
     lock (_gfxLock)
     {
         _gm.BeginDraw();
         _gm.Clear();
         SceneManager.Render(_gm);
         _gm.EndDraw();
         _gm.Render();
     }
     //Invalidate();
 }
Beispiel #2
0
        /// <summary>
        /// Draws a frame with a provided clear color.
        /// </summary>
        /// <param name="_">Time passed since last <see cref="Draw(GameTime)"/>.</param>
        /// <param name="clearColor"><see cref="Microsoft.Xna.Framework.Color"/> to clear the screen with.</param>
        public void Draw(GameTime _, Color clearColor)
        {
            GraphicsManager.Clear(clearColor);

            var render2DSystems = Render2DSystems.ToArray();
            var render3DSystems = Render3DSystems.ToArray();

            // 3D must render before 2D or else the 2D sprites will fail to render in the Z dimension properly
            foreach (var system in render3DSystems)
            {
                system.DrawComponents();
            }
            var spriteBatch = GraphicsManager.SpriteBatch;

            foreach (var system in render2DSystems)
            {
                system.DrawComponents(spriteBatch);
            }
        }
    /// <summary>
    /// Called when the inspector needs to draw
    /// </summary>
    public override void OnInspectorGUI()
    {
        // Pulls variables from runtime so we have the latest values.
        mTargetSO.Update();

        GUILayout.Space(5);

        EditorHelper.DrawInspectorTitle("ootii Graphics Manager");

        EditorHelper.DrawInspectorDescription("By adding this component to the camera, we can draw graphics to the scene and game views.", MessageType.None);

        GUILayout.Space(5);

        bool lNewDrawToSceneView = EditorGUILayout.Toggle(new GUIContent("Draw to Scene", "Determines if we render graphics to the scene view."), mTarget.DrawToSceneView);

        if (lNewDrawToSceneView != mTarget.DrawToSceneView)
        {
            mIsDirty = true;
            mTarget.DrawToSceneView = lNewDrawToSceneView;
        }

        bool lNewDrawToGameView = EditorGUILayout.Toggle(new GUIContent("Draw to Game", "Determines if we render graphics to the game view."), mTarget.DrawToGameView);

        if (lNewDrawToGameView != mTarget.DrawToGameView)
        {
            mIsDirty = true;
            mTarget.DrawToGameView = lNewDrawToGameView;
        }

        string lNewShader = EditorGUILayout.TextField("Shader", mTarget.DefaultShader);

        if (lNewShader != mTarget.DefaultShader)
        {
            mIsDirty = true;
            mTarget.DefaultShader = lNewShader;
        }

        Font lNewFont = EditorGUILayout.ObjectField("Font", mTarget.DefaultFont, typeof(Font), false) as Font;

        if (lNewFont != mTarget.DefaultFont)
        {
            mIsDirty            = true;
            mTarget.DefaultFont = lNewFont;
        }

        GUILayout.Space(5);

        EditorGUILayout.BeginVertical(EditorHelper.Box);

        EditorGUILayout.LabelField(string.Format("Lines:{0}  Triangles:{1}", mTarget.LineCount, mTarget.TriangleCount));

        if (GUILayout.Button("Clear Render Lists", EditorStyles.miniButton))
        {
            GraphicsManager.Clear();
        }

        EditorGUILayout.EndVertical();

        GUILayout.Space(5);

        // If there is a change... update.
        if (mIsDirty)
        {
            // Flag the object as needing to be saved
            EditorUtility.SetDirty(mTarget);

#if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
            EditorApplication.MarkSceneDirty();
#else
            if (!EditorApplication.isPlaying)
            {
                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
            }
#endif

            // Pushes the values back to the runtime so it has the changes
            mTargetSO.ApplyModifiedProperties();

            // Clear out the dirty flag
            mIsDirty = false;
        }
    }