Beispiel #1
0
        public static void DrawDirectionalLight(Vector3 position, Quaternion rotation, Vector3 scale, Color color)
        {
            float sScale = RuntimeGraphics.GetScreenScale(position, Camera.current);

            Matrix4x4 zTranform  = Matrix4x4.TRS(Vector3.zero, rotation, Vector3.one);
            Matrix4x4 objToWorld = Matrix4x4.TRS(position, Quaternion.identity, scale * sScale);

            LinesMaterial.SetPass(0);
            GL.PushMatrix();
            GL.MultMatrix(objToWorld);

            GL.Begin(GL.LINES);
            GL.Color(color);

            float radius = 0.25f;
            float length = 1.25f;



            RuntimeGraphics.DrawCircleGL(zTranform, radius);
            RuntimeGraphics.DrawWireConeGL(zTranform, Vector3.zero, radius, length, 8);

            Vector3 point  = zTranform.MultiplyPoint(Vector3.zero);
            Vector3 point2 = zTranform.MultiplyPoint(Vector3.forward * length);

            GL.Vertex(point);
            GL.Vertex(point2);

            GL.End();
            GL.PopMatrix();
        }
Beispiel #2
0
        public static void DrawWireConeGL(float height, float radius, Vector3 position, Quaternion rotation, Vector3 scale, Color color)
        {
            Matrix4x4 circleTransform = Matrix4x4.TRS(height * Vector3.forward, Quaternion.identity, Vector3.one);

            Matrix4x4 objToWorld = Matrix4x4.TRS(position, rotation, scale);

            LinesMaterial.SetPass(0);
            GL.PushMatrix();
            GL.MultMatrix(objToWorld);

            GL.Begin(GL.LINES);
            GL.Color(color);
            RuntimeGraphics.DrawCircleGL(circleTransform, radius);

            GL.Vertex(Vector3.zero);
            GL.Vertex(Vector3.forward * height + new Vector3(1, 1, 0).normalized *radius);

            GL.Vertex(Vector3.zero);
            GL.Vertex(Vector3.forward * height + new Vector3(-1, 1, 0).normalized *radius);

            GL.Vertex(Vector3.zero);
            GL.Vertex(Vector3.forward * height + new Vector3(-1, -1, 0).normalized *radius);

            GL.Vertex(Vector3.zero);
            GL.Vertex(Vector3.forward * height + new Vector3(1, -1, 0).normalized *radius);

            GL.End();
            GL.PopMatrix();
        }
Beispiel #3
0
        public static void DrawWireCapsuleGL(int axis, float height, float radius, Vector3 position, Quaternion rotation, Vector3 scale, Color color)
        {
            Matrix4x4 topCircleTransform;
            Matrix4x4 bottomCircleTransform;
            Matrix4x4 capsule2DTransform;
            Matrix4x4 capsule2DTransform2;

            radius = Mathf.Abs(radius);

            if (Mathf.Abs(height) < 2 * radius)
            {
                height = 0;
            }
            else
            {
                height = Mathf.Abs(height) - 2 * radius;
            }

            if (axis == 1)
            {
                topCircleTransform    = Matrix4x4.TRS(Vector3.up * height / 2, Quaternion.AngleAxis(-90, Vector3.right), Vector3.one);
                bottomCircleTransform = Matrix4x4.TRS(Vector3.down * height / 2, Quaternion.AngleAxis(-90, Vector3.right), Vector3.one);
                capsule2DTransform    = Matrix4x4.identity;
                capsule2DTransform2   = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(-90, Vector3.up), Vector3.one);
            }
            else if (axis == 0)
            {
                topCircleTransform    = Matrix4x4.TRS(Vector3.right * height / 2, Quaternion.AngleAxis(-90, Vector3.up), Vector3.one);
                bottomCircleTransform = Matrix4x4.TRS(Vector3.left * height / 2, Quaternion.AngleAxis(-90, Vector3.up), Vector3.one);
                capsule2DTransform    = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(-90, Vector3.forward), Vector3.one);
                capsule2DTransform2   = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(-90, Vector3.forward) * Quaternion.AngleAxis(-90, Vector3.up), Vector3.one);
            }
            else
            {
                topCircleTransform    = Matrix4x4.TRS(Vector3.forward * height / 2, Quaternion.identity, Vector3.one);
                bottomCircleTransform = Matrix4x4.TRS(Vector3.back * height / 2, Quaternion.identity, Vector3.one);
                capsule2DTransform    = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(-90, Vector3.right), Vector3.one);
                capsule2DTransform2   = Matrix4x4.TRS(Vector3.zero, Quaternion.AngleAxis(-90, Vector3.right) * Quaternion.AngleAxis(-90, Vector3.up), Vector3.one);
            }


            Matrix4x4 objToWorld = Matrix4x4.TRS(position, rotation, scale);

            LinesMaterial.SetPass(0);
            GL.PushMatrix();
            GL.MultMatrix(objToWorld);

            GL.Begin(GL.LINES);
            GL.Color(color);
            RuntimeGraphics.DrawCircleGL(topCircleTransform, radius);
            RuntimeGraphics.DrawCircleGL(bottomCircleTransform, radius);

            RuntimeGraphics.DrawCapsule2DGL(capsule2DTransform, radius, height);
            RuntimeGraphics.DrawCapsule2DGL(capsule2DTransform2, radius, height);

            GL.End();
            GL.PopMatrix();
        }
        private void UpdateFontSize()
        {
            if (m_txtSize1 != null)
            {
                m_txtSize1.fontSize = RuntimeGraphics.GetScreenScale(m_txtSize1.transform.position, Window.Camera) * 1.7f;
            }

            if (m_txtSize2 != null)
            {
                m_txtSize2.fontSize = RuntimeGraphics.GetScreenScale(m_txtSize2.transform.position, Window.Camera) * 1.7f;
            }
        }
Beispiel #5
0
        public static void DrawWireDisc(Vector3 position, Quaternion rotation, Vector3 scale, Color color)
        {
            Matrix4x4 zTranform  = Matrix4x4.TRS(Vector3.zero, rotation, Vector3.one);
            Matrix4x4 objToWorld = Matrix4x4.TRS(position, Quaternion.identity, scale);

            LinesMaterial.SetPass(0);
            GL.PushMatrix();
            GL.MultMatrix(objToWorld);

            GL.Begin(GL.LINES);
            GL.Color(color);
            RuntimeGraphics.DrawCircleGL(zTranform, 1);
            GL.End();
            GL.PopMatrix();
        }
Beispiel #6
0
        public static void DrawWireSphereGL(Vector3 position, Quaternion rotation, Vector3 scale, Color color)
        {
            Matrix4x4 xTranform  = Matrix4x4.TRS(Vector3.zero, rotation * Quaternion.AngleAxis(-90, Vector3.up), Vector3.one);
            Matrix4x4 yTranform  = Matrix4x4.TRS(Vector3.zero, rotation * Quaternion.AngleAxis(-90, Vector3.right), Vector3.one);
            Matrix4x4 zTranform  = Matrix4x4.TRS(Vector3.zero, rotation, Vector3.one);
            Matrix4x4 objToWorld = Matrix4x4.TRS(position, Quaternion.identity, scale);

            LinesMaterial.SetPass(0);
            GL.PushMatrix();
            GL.MultMatrix(objToWorld);

            GL.Begin(GL.LINES);
            GL.Color(color);
            RuntimeGraphics.DrawCircleGL(xTranform, 1);
            RuntimeGraphics.DrawCircleGL(yTranform, 1);
            RuntimeGraphics.DrawCircleGL(zTranform, 1);
            if (Camera.current.orthographic)
            {
                Matrix4x4 outTransform = Matrix4x4.TRS(Vector3.zero, Camera.current.transform.rotation, Vector3.one);
                RuntimeGraphics.DrawCircleGL(outTransform, 1);
            }
            else
            {
                Vector3 toCam     = Camera.current.transform.position - position;
                Vector3 toCamNorm = toCam.normalized;
                if (Vector3.Dot(toCamNorm, Camera.current.transform.forward) < 0)
                {
                    float     m            = toCam.magnitude;
                    Matrix4x4 outTransform = Matrix4x4.TRS(toCamNorm * 0.56f * scale.x / m, Quaternion.LookRotation(toCamNorm, Camera.current.transform.up), Vector3.one);
                    RuntimeGraphics.DrawCircleGL(outTransform, 1);
                }
            }

            GL.End();
            GL.PopMatrix();
        }
        static RuntimeHandles()
        {
            LinesMaterial                  = new Material(Shader.Find("Battlehub/RTHandles/VertexColor"));
            LinesMaterial.color            = Color.white;
            LinesMaterial.enableInstancing = true;

            LinesMaterialZTest       = new Material(Shader.Find("Battlehub/RTHandles/VertexColor"));
            LinesMaterialZTest.color = Color.white;
            LinesMaterialZTest.SetFloat("_ZTest", (float)UnityEngine.Rendering.CompareFunction.LessEqual);
            LinesMaterialZTest.enableInstancing = true;

            LinesClipMaterial                  = new Material(Shader.Find("Battlehub/RTHandles/VertexColorClip"));
            LinesClipMaterial.color            = Color.white;
            LinesClipMaterial.enableInstancing = true;

            LinesBillboardMaterial                  = new Material(Shader.Find("Battlehub/RTHandles/VertexColorBillboard"));
            LinesBillboardMaterial.color            = Color.white;
            LinesBillboardMaterial.enableInstancing = true;

            ShapesMaterial                  = new Material(Shader.Find("Battlehub/RTHandles/Shape"));
            ShapesMaterial.color            = Color.white;
            ShapesMaterial.enableInstancing = true;


            ShapesMaterialZTest       = new Material(Shader.Find("Battlehub/RTHandles/Shape"));
            ShapesMaterialZTest.color = new Color(1, 1, 1, 0);
            ShapesMaterialZTest.SetFloat("_ZTest", (float)UnityEngine.Rendering.CompareFunction.LessEqual);
            ShapesMaterialZTest.SetFloat("_ZWrite", 1.0f);
            ShapesMaterialZTest.enableInstancing = true;

            ShapesMaterialZTestOffset       = new Material(Shader.Find("Battlehub/RTHandles/Shape"));
            ShapesMaterialZTestOffset.color = new Color(1, 1, 1, 1);
            ShapesMaterialZTestOffset.SetFloat("_ZTest", (float)UnityEngine.Rendering.CompareFunction.LessEqual);
            ShapesMaterialZTestOffset.SetFloat("_ZWrite", 1.0f);
            ShapesMaterialZTestOffset.SetFloat("_OFactors", -1.0f);
            ShapesMaterialZTestOffset.SetFloat("_OUnits", -1.0f);
            ShapesMaterialZTestOffset.enableInstancing = true;

            ShapesMaterialZTest2       = new Material(Shader.Find("Battlehub/RTHandles/Shape"));
            ShapesMaterialZTest2.color = new Color(1, 1, 1, 0);
            ShapesMaterialZTest2.SetFloat("_ZTest", (float)UnityEngine.Rendering.CompareFunction.LessEqual);
            ShapesMaterialZTest2.SetFloat("_ZWrite", 1.0f);
            ShapesMaterialZTest2.enableInstancing = true;

            ShapesMaterialZTest3       = new Material(Shader.Find("Battlehub/RTHandles/Shape"));
            ShapesMaterialZTest3.color = new Color(1, 1, 1, 0);
            ShapesMaterialZTest3.SetFloat("_ZTest", (float)UnityEngine.Rendering.CompareFunction.LessEqual);
            ShapesMaterialZTest3.SetFloat("_ZWrite", 1.0f);
            ShapesMaterialZTest3.enableInstancing = true;

            ShapesMaterialZTest4       = new Material(Shader.Find("Battlehub/RTHandles/Shape"));
            ShapesMaterialZTest4.color = new Color(1, 1, 1, 0);
            ShapesMaterialZTest4.SetFloat("_ZTest", (float)UnityEngine.Rendering.CompareFunction.LessEqual);
            ShapesMaterialZTest4.SetFloat("_ZWrite", 1.0f);
            ShapesMaterialZTest4.enableInstancing = true;

            XMaterial                  = new Material(Shader.Find("Battlehub/RTCommon/Billboard"));
            XMaterial.color            = Color.white;
            XMaterial.mainTexture      = Resources.Load <Texture>("Battlehub.RuntimeHandles.x");
            XMaterial.enableInstancing = true;
            YMaterial                  = new Material(Shader.Find("Battlehub/RTCommon/Billboard"));
            YMaterial.color            = Color.white;
            YMaterial.mainTexture      = Resources.Load <Texture>("Battlehub.RuntimeHandles.y");
            YMaterial.enableInstancing = true;
            ZMaterial                  = new Material(Shader.Find("Battlehub/RTCommon/Billboard"));
            ZMaterial.color            = Color.white;
            ZMaterial.mainTexture      = Resources.Load <Texture>("Battlehub.RuntimeHandles.z");
            ZMaterial.enableInstancing = true;

            GridMaterial       = new Material(Shader.Find("Battlehub/RTHandles/Grid"));
            GridMaterial.color = Color.white;
            GridMaterial.SetFloat("_ZTest", (float)UnityEngine.Rendering.CompareFunction.Never);
            GridMaterial.enableInstancing = true;

            Mesh selectionArrowMesh = CreateConeMesh(RTHColors.SelectionColor, HandleScale);
            Mesh disableArrowMesh   = CreateConeMesh(RTHColors.DisabledColor, HandleScale);

            CombineInstance yArrow = new CombineInstance();

            yArrow.mesh      = selectionArrowMesh;
            yArrow.transform = Matrix4x4.TRS(Vector3.up * HandleScale, Quaternion.identity, Vector3.one);
            SelectionArrowY  = new Mesh();
            SelectionArrowY.CombineMeshes(new[] { yArrow }, true);
            SelectionArrowY.RecalculateNormals();

            yArrow.mesh      = disableArrowMesh;
            yArrow.transform = Matrix4x4.TRS(Vector3.up * HandleScale, Quaternion.identity, Vector3.one);
            DisabledArrowY   = new Mesh();
            DisabledArrowY.CombineMeshes(new[] { yArrow }, true);
            DisabledArrowY.RecalculateNormals();

            yArrow.mesh      = CreateConeMesh(RTHColors.YColor, HandleScale);
            yArrow.transform = Matrix4x4.TRS(Vector3.up * HandleScale, Quaternion.identity, Vector3.one);
            ArrowY           = new Mesh();
            ArrowY.CombineMeshes(new[] { yArrow }, true);
            ArrowY.RecalculateNormals();

            CombineInstance xArrow = new CombineInstance();

            xArrow.mesh      = selectionArrowMesh;
            xArrow.transform = Matrix4x4.TRS(Vector3.right * HandleScale, Quaternion.AngleAxis(-90, Vector3.forward), Vector3.one);
            SelectionArrowX  = new Mesh();
            SelectionArrowX.CombineMeshes(new[] { xArrow }, true);
            SelectionArrowX.RecalculateNormals();

            xArrow.mesh      = disableArrowMesh;
            xArrow.transform = Matrix4x4.TRS(Vector3.right * HandleScale, Quaternion.AngleAxis(-90, Vector3.forward), Vector3.one);
            DisabledArrowX   = new Mesh();
            DisabledArrowX.CombineMeshes(new[] { xArrow }, true);
            DisabledArrowX.RecalculateNormals();

            xArrow.mesh      = CreateConeMesh(RTHColors.XColor, HandleScale);
            xArrow.transform = Matrix4x4.TRS(Vector3.right * HandleScale, Quaternion.AngleAxis(-90, Vector3.forward), Vector3.one);
            ArrowX           = new Mesh();
            ArrowX.CombineMeshes(new[] { xArrow }, true);
            ArrowX.RecalculateNormals();

            Vector3         zAxis     = Forward * HandleScale;
            Quaternion      zRotation = InvertZAxis ? Quaternion.AngleAxis(-90, Vector3.right) : Quaternion.AngleAxis(90, Vector3.right);
            CombineInstance zArrow    = new CombineInstance();

            zArrow.mesh      = selectionArrowMesh;
            zArrow.transform = Matrix4x4.TRS(zAxis, zRotation, Vector3.one);
            SelectionArrowZ  = new Mesh();
            SelectionArrowZ.CombineMeshes(new[] { zArrow }, true);
            SelectionArrowZ.RecalculateNormals();

            zArrow.mesh      = disableArrowMesh;
            zArrow.transform = Matrix4x4.TRS(zAxis, zRotation, Vector3.one);
            DisabledArrowZ   = new Mesh();
            DisabledArrowZ.CombineMeshes(new[] { zArrow }, true);
            DisabledArrowZ.RecalculateNormals();

            zArrow.mesh      = CreateConeMesh(RTHColors.ZColor, HandleScale);
            zArrow.transform = Matrix4x4.TRS(zAxis, zRotation, Vector3.one);
            ArrowZ           = new Mesh();
            ArrowZ.CombineMeshes(new[] { zArrow }, true);
            ArrowZ.RecalculateNormals();

            yArrow.mesh = CreateConeMesh(RTHColors.YColor, HandleScale);
            xArrow.mesh = CreateConeMesh(RTHColors.XColor, HandleScale);
            zArrow.mesh = CreateConeMesh(RTHColors.ZColor, HandleScale);
            Arrows      = new Mesh();
            Arrows.CombineMeshes(new[] { yArrow, xArrow, zArrow }, true);
            Arrows.RecalculateNormals();

            SelectionCube = RuntimeGraphics.CreateCubeMesh(RTHColors.SelectionColor, Vector3.zero, HandleScale, 0.1f, 0.1f, 0.1f);
            DisabledCube  = RuntimeGraphics.CreateCubeMesh(RTHColors.DisabledColor, Vector3.zero, HandleScale, 0.1f, 0.1f, 0.1f);
            CubeX         = RuntimeGraphics.CreateCubeMesh(RTHColors.XColor, Vector3.zero, HandleScale, 0.1f, 0.1f, 0.1f);
            CubeY         = RuntimeGraphics.CreateCubeMesh(RTHColors.YColor, Vector3.zero, HandleScale, 0.1f, 0.1f, 0.1f);
            CubeZ         = RuntimeGraphics.CreateCubeMesh(RTHColors.ZColor, Vector3.zero, HandleScale, 0.1f, 0.1f, 0.1f);
            CubeUniform   = RuntimeGraphics.CreateCubeMesh(RTHColors.AltColor, Vector3.zero, HandleScale, 0.1f, 0.1f, 0.1f);

            SceneGizmoSelectedAxis = CreateSceneGizmoHalfAxis(RTHColors.SelectionColor, Quaternion.AngleAxis(90, Vector3.right));
            SceneGizmoXAxis        = CreateSceneGizmoAxis(RTHColors.XColor, RTHColors.AltColor, Quaternion.AngleAxis(-90, Vector3.forward));
            SceneGizmoYAxis        = CreateSceneGizmoAxis(RTHColors.YColor, RTHColors.AltColor, Quaternion.identity);
            SceneGizmoZAxis        = CreateSceneGizmoAxis(RTHColors.ZColor, RTHColors.AltColor, zRotation);
            SceneGizmoCube         = RuntimeGraphics.CreateCubeMesh(RTHColors.AltColor, Vector3.zero, 1);
            SceneGizmoSelectedCube = RuntimeGraphics.CreateCubeMesh(RTHColors.SelectionColor, Vector3.zero, 1);
            SceneGizmoQuad         = RuntimeGraphics.CreateQuadMesh();
        }
        public static void DoRotationHandle(Quaternion rotation, Vector3 position, RuntimeHandleAxis selectedAxis = RuntimeHandleAxis.None, LockObject lockObject = null)
        {
            float     screenScale = GetScreenScale(position, Camera.current);
            float     radius      = HandleScale;
            Vector3   scale       = new Vector3(screenScale, screenScale, screenScale);
            Matrix4x4 xTranform   = Matrix4x4.TRS(Vector3.zero, rotation * Quaternion.AngleAxis(-90, Vector3.up), Vector3.one);
            Matrix4x4 yTranform   = Matrix4x4.TRS(Vector3.zero, rotation * Quaternion.AngleAxis(-90, Vector3.right), Vector3.one);
            Matrix4x4 zTranform   = Matrix4x4.TRS(Vector3.zero, rotation, Vector3.one);
            Matrix4x4 objToWorld  = Matrix4x4.TRS(position, Quaternion.identity, scale);

            bool xLocked      = lockObject != null && lockObject.RotationX;
            bool yLocked      = lockObject != null && lockObject.RotationY;
            bool zLocked      = lockObject != null && lockObject.RotationZ;
            bool screenLocked = lockObject != null && lockObject.RotationScreen;

            LinesClipMaterial.SetPass(0);
            GL.PushMatrix();
            GL.MultMatrix(objToWorld);

            GL.Begin(GL.LINES);
            if (xLocked)
            {
                GL.Color(RTHColors.DisabledColor);
            }
            else
            {
                GL.Color(selectedAxis != RuntimeHandleAxis.X ? RTHColors.XColor : RTHColors.SelectionColor);
            }
            RuntimeGraphics.DrawCircleGL(xTranform, radius);

            if (yLocked)
            {
                GL.Color(RTHColors.DisabledColor);
            }
            else
            {
                GL.Color(selectedAxis != RuntimeHandleAxis.Y ? RTHColors.YColor : RTHColors.SelectionColor);
            }
            RuntimeGraphics.DrawCircleGL(yTranform, radius);

            if (zLocked)
            {
                GL.Color(RTHColors.DisabledColor);
            }
            else
            {
                GL.Color(selectedAxis != RuntimeHandleAxis.Z ? RTHColors.ZColor : RTHColors.SelectionColor);
            }
            RuntimeGraphics.DrawCircleGL(zTranform, radius);
            GL.End();

            GL.PopMatrix();

            LinesBillboardMaterial.SetPass(0);
            GL.PushMatrix();
            GL.MultMatrix(objToWorld);

            GL.Begin(GL.LINES);
            if (xLocked && yLocked && zLocked)
            {
                GL.Color(RTHColors.DisabledColor);
            }
            else
            {
                GL.Color(selectedAxis != RuntimeHandleAxis.Free ? RTHColors.AltColor : RTHColors.SelectionColor);
            }
            RuntimeGraphics.DrawCircleGL(Matrix4x4.identity, radius);

            if (screenLocked)
            {
                GL.Color(RTHColors.DisabledColor);
            }
            else
            {
                GL.Color(selectedAxis != RuntimeHandleAxis.Screen ? RTHColors.AltColor : RTHColors.SelectionColor);
            }
            RuntimeGraphics.DrawCircleGL(Matrix4x4.identity, radius * 1.1f);
            GL.End();

            GL.PopMatrix();
        }
Beispiel #9
0
        private void Update()
        {
            if (InputController._GetKeyDown(AddAssetBundleKey2))
            {
                ProjectItem rootFolder = m_projectManager.Project;
                m_projectManager.AddBundledResources(rootFolder, "bundledemo",
                                                     (obj, assetName) =>
                {
                    return(true);
                },
                                                     addedItems =>
                {
                    for (int i = 0; i < addedItems.Length; ++i)
                    {
                        Debug.Log(addedItems[i].ToString() + " added");
                    }
                });
            }


            if (InputController._GetKeyDown(AddAssetBundleKey))
            {
                ProjectItem rootFolder = m_projectManager.Project;
                m_projectManager.AddBundledResource(rootFolder, "bundledemo", "monkey", addedItems =>
                {
                    for (int i = 0; i < addedItems.Length; ++i)
                    {
                        Debug.Log(addedItems[i].ToString() + " added");
                    }
                });
            }

            if (InputController._GetKeyDown(AddWithDependenciesKey))
            {
                ProjectItem        rootFolder = m_projectManager.Project;
                List <UnityObject> objects    = new List <UnityObject>();

                Material material = new Material(Shader.Find("Standard"));
                material.color = Color.yellow;

                Mesh mesh = RuntimeGraphics.CreateCubeMesh(Color.white, Vector3.zero, 1);
                mesh.name = "TestMesh";

                GameObject   go         = new GameObject();
                MeshRenderer renderer   = go.AddComponent <MeshRenderer>();
                MeshFilter   meshFilter = go.AddComponent <MeshFilter>();

                go.name = "TestGO";
                renderer.sharedMaterial = material;
                meshFilter.sharedMesh   = mesh;

                //objects.Add(material);
                //objects.Add(mesh);
                objects.Add(go);

                bool includingDependencies      = true;
                Func <UnityObject, bool> filter = o =>
                {
                    if (o is Shader)
                    {
                        return(false);
                    }
                    return(true);
                };

                m_projectManager.AddDynamicResources(rootFolder, objects.ToArray(), includingDependencies, filter, addedItems =>
                {
                    for (int i = 0; i < addedItems.Length; ++i)
                    {
                        Debug.Log(addedItems[i].ToString() + " added");
                    }

                    for (int i = 0; i < objects.Count; ++i)
                    {
                        Destroy(objects[i]);
                    }
                });
            }


            if (InputController._GetKeyDown(AddInstantiatedObjectKey))
            {
                ProjectItem        rootFolder = m_projectManager.Project;
                List <UnityObject> objects    = new List <UnityObject>();

                Material material = new Material(Shader.Find("Standard"));
                material.color = Color.yellow;

                Mesh mesh = RuntimeGraphics.CreateCubeMesh(Color.white, Vector3.zero, 1);
                mesh.name = "TestMesh";

                GameObject   go       = new GameObject();
                MeshRenderer renderer = go.AddComponent <MeshRenderer>();
                MeshFilter   filter   = go.AddComponent <MeshFilter>();

                go.name = "TestGO";
                renderer.sharedMaterial = material;
                filter.sharedMesh       = mesh;

                objects.Add(material);
                objects.Add(mesh);
                objects.Add(go);

                m_projectManager.AddDynamicResources(rootFolder, objects.ToArray(), addedItems =>
                {
                    for (int i = 0; i < addedItems.Length; ++i)
                    {
                        Debug.Log(addedItems[i].ToString() + " added");
                    }

                    for (int i = 0; i < objects.Count; ++i)
                    {
                        Destroy(objects[i]);
                    }
                });
            }

            if (InputController._GetKeyDown(KeyCode.Keypad7))
            {
                ProjectItem projectItem = m_projectManager.Project.FlattenHierarchy().Where(item => item.Name == "TestGO").FirstOrDefault();
                m_projectManager.GetOrCreateObjects(new[] { projectItem }, result =>
                {
                    Instantiate(result.First().Object);
                });
            }

            if (InputController._GetKeyDown(AddPrefabKey))
            {
                ProjectItem        rootFolder = m_projectManager.Project;
                List <UnityObject> objects    = new List <UnityObject>();

                if (Prefab != null)
                {
                    objects.Add(Prefab);
                }

                bool includingDependencies      = true;
                Func <UnityObject, bool> filter = o =>
                {
                    if (o is Shader)
                    {
                        return(false);
                    }
                    return(true);
                };

                m_projectManager.AddDynamicResources(rootFolder, objects.ToArray(), includingDependencies, filter, addedItems =>
                {
                    for (int i = 0; i < addedItems.Length; ++i)
                    {
                        Debug.Log(addedItems[i].ToString() + " added");
                    }
                });
            }

            if (InputController._GetKeyDown(AddTextureKey))
            {
                ProjectItem        rootFolder = m_projectManager.Project;
                List <UnityObject> objects    = new List <UnityObject>();

                string    path      = Application.streamingAssetsPath + "/" + ImagePath;
                Texture2D texture2D = LoadPNG(path);
                if (texture2D == null)
                {
                    Debug.LogErrorFormat("File {0} not found", path);
                    return;
                }

                texture2D.name = "TestTexture";
                objects.Add(texture2D);

                m_projectManager.AddDynamicResources(rootFolder, objects.ToArray(), addedItems =>
                {
                    for (int i = 0; i < addedItems.Length; ++i)
                    {
                        Debug.Log(addedItems[i].ToString() + " added");
                    }
                });
            }
        }