예제 #1
0
 void OnDrawGizmos()
 {
     if (texture != null)
     {
         Gizmos.DrawGUITexture(rect, texture);
     }
 }
예제 #2
0
 private void DrawWebCam()
 {
     if (useWebCamFeed)
     {
         Gizmos.DrawGUITexture(new Rect(0, 0, webcamTexture.width, -webcamTexture.height), webcamTexture);
     }
 }
예제 #3
0
    // Update is called once per frame
    private void OnDrawGizmos()
    {
        if (dodecadragon != null)
        {
            for (int i = 0; i < dodecadragon.vertices.Length; i++)
            {
                if (dodecadragon.vertices[i] == Vector3.zero)
                {
                    Debug.LogAssertionFormat(this, "Bad vertex at index {0}", i);
                }

                Handles.Label(dodecadragon.vertices[i], i.ToString());
                Gizmos.DrawGUITexture(new Rect(new Vector2(0, 0), new Vector2(100, 100)), uvTexture);
                Gizmos.DrawRay(dodecadragon.vertices[i], dodecadragon.normals[i]);
            }
            if (points != null)
            {
                for (int i = 0; i < dodecadragon.triangles.Length / 3; i++)
                {
                    if (points[i] != null)
                    {
                        //print(points[dodecadragon.triangles[i * 3]].position);
                        Gizmos.DrawLine(points[dodecadragon.triangles[i * 3]].position, points[dodecadragon.triangles[i * 3 + 1]].position);
                        Gizmos.DrawLine(points[dodecadragon.triangles[i * 3 + 2]].position, points[dodecadragon.triangles[i * 3 + 1]].position);
                        Gizmos.DrawLine(points[dodecadragon.triangles[i * 3]].position, points[dodecadragon.triangles[i * 3 + 2]].position);
                    }
                    else
                    {
                        points[i] = new GameObject().transform;
                    }
                }
            }
        }
    }
예제 #4
0
    //only for debug purposes
    private void OnDrawGizmos()
    {
        camDeadzone.center = new Vector3(relativeValues.x, relativeValues.y, 0f);
        Rect rect = new Rect(camDeadzone.center, camDeadzone.size);

        Gizmos.DrawGUITexture(rect, GizmosTexture);
    }
예제 #5
0
    public void OnDrawGizmos()
    {
        if (grid != null && grid.GetNodes() != null)
        {
            foreach (Node node in grid.GetNodes())
            {
                if (node != null)
                {
                    Texture2D texture = node.isWall ? wallTexture : groundTexture;
                    Gizmos.DrawGUITexture(new Rect(node.worldPos - Vector2.one * grid.CellSize / 2, Vector2.one * grid.CellSize), texture);
                }
            }
        }

        if (pathFindingManager != null && pathFindingManager.getCurrentPath() != null)
        {
            foreach (Node node in pathFindingManager.getCurrentPath())
            {
                if (node != null)
                {
                    Gizmos.DrawGUITexture(new Rect(node.worldPos - Vector2.one * grid.CellSize / 2, Vector2.one * grid.CellSize), pathTexture);
                }
            }
        }
    }
예제 #6
0
    void OnDrawGizmos()
    {
        //Handy debug draw calls to visualize camera and deadzone in Scene view. Toggle on off with the Debug Draw On

        if (debugDrawOn == true)
        {
            //Deadzone
            if (deadzone != null && deadzoneDebugTexture != null)
            {
                Gizmos.DrawGUITexture(deadzone, deadzoneDebugTexture);
            }
            else
            {
                Color colorGreen = Color.green;
                colorGreen.a         = 0.5f;
                deadzoneDebugTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
                deadzoneDebugTexture.SetPixel(0, 0, colorGreen);
                deadzoneDebugTexture.Apply();
                if (focusGameObject != null)
                {
                    deadzone.position = new Vector3(focusGameObject.transform.position.x, focusGameObject.transform.position.y, 0);
                }
            }
            //Camera
            if (cameraDebugRect != null && cameraDebugTexture != null)
            {
                cameraDebugRect.position = new Vector3(mainCamera.transform.position.x - cameraDebugRect.width * .5f, mainCamera.transform.position.y - cameraDebugRect.height * .5f, 0);
                Gizmos.DrawGUITexture(cameraDebugRect, cameraDebugTexture);
            }
            else
            {
                Color colorBlue = Color.blue;
                colorBlue.a        = 0.25f;
                cameraDebugTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
                cameraDebugTexture.SetPixel(0, 0, colorBlue);
                cameraDebugTexture.Apply();
            }
            Debug.DrawRay(new Vector2(focusDestinationX, focusDestinationY), Vector3.left, Color.red, 1 / 60);
            Debug.DrawRay(new Vector2(focusDestinationX, focusDestinationY), Vector3.right, Color.red, 1 / 60);
            Debug.DrawRay(new Vector2(focusDestinationX, focusDestinationY), Vector3.down, Color.red, 1 / 60);
            Debug.DrawRay(new Vector2(focusDestinationX, focusDestinationY), Vector3.up, Color.red, 1 / 60);
        }
        //Worldbounds -- not ideal to have on, but handy to make sure you've set the right world dimensions
        if (debugDrawWorld == true)
        {
            if (worldDebugRect != null && worldBoundsDebugTexture != null)
            {
                worldDebugRect.position = new Vector3(mapX, mapY - mapHeight, 0);
                Gizmos.DrawGUITexture(worldDebugRect, worldBoundsDebugTexture);
            }
            else
            {
                Color colorRed = Color.red;
                colorRed.a = 0.25f;
                worldBoundsDebugTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
                worldBoundsDebugTexture.SetPixel(0, 0, colorRed);
                worldBoundsDebugTexture.Apply();
            }
        }
    }
예제 #7
0
    private void OnDrawGizmos()
    {
        if (map != null && enableDebug)
        {
            int realWidth  = map.GetLength(0);
            int realHeight = map.GetLength(1);
            for (int i = 0; i < realWidth; i++)
            {
                for (int j = 0; j < realHeight; j++)
                {
                    Texture2D texture = null;
                    switch (map[i, j])
                    {
                    case Types.GROUND:
                        texture = groundTexture;
                        break;

                    case Types.WALL:
                        texture = wallTexture;
                        break;
                    }
                    Vector2 position = new Vector2(-realWidth / 2 + i, -realHeight / 2 + j);
                    Gizmos.DrawGUITexture(new Rect(position, Vector2.one), texture);
                }
            }
        }
    }
예제 #8
0
 private void OnDrawGizmosSelected()
 {
     Gizmos.color = new Color(1f, 0f, 0f, 1f);
     Gizmos.DrawWireSphere(transform.position, length);
     Gizmos.DrawSphere(transform.position, length);
     Gizmos.DrawGUITexture(new Rect(transform.position.x, transform.position.y + 3, 2, 2), tex);
 }
예제 #9
0
파일: Board.cs 프로젝트: tdvance/Maze-Chase
 private void OnDrawGizmos()
 {
     if (editorShowBoardInScene)
     {
         Gizmos.DrawGUITexture(Rect.MinMaxRect(minX, maxY + 1, maxX + 1, minY),
                               firstBoard);
     }
 }
        private void OnDrawGizmos()
        {
            if (EditorApplication.isPlaying)
            {
                return;
            }

            //外框
            Gizmos.color = Color.green;
            var bounds = GetComponent <RectTransform>().GetBounds();

            Gizmos.DrawWireCube(bounds.center, bounds.size);
            //分割线
            Vector3 miniPoint     = bounds.center - bounds.size * 0.5f;
            float   hightInterval = bounds.size.y / (float)Config.Row;

            for (int i = 0; i < Config.Row; i++)
            {
                Vector3 startPos = miniPoint + new Vector3(0, i * hightInterval, 0);
                Vector3 endPos   = miniPoint + new Vector3(bounds.size.x, i * hightInterval, 0);
                Gizmos.DrawLine(startPos, endPos);
            }
            float widthInterval = bounds.size.x / (float)Config.Column;

            for (int i = 0; i < Config.Column; i++)
            {
                Vector3 startPos = miniPoint + new Vector3(i * widthInterval, 0, 0);
                Vector3 endPos   = miniPoint + new Vector3(i * widthInterval, bounds.size.y, 0);
                Gizmos.DrawLine(startPos, endPos);
            }
            //绘制组件
            Vector2 cellInterval = new Vector2(widthInterval, hightInterval);

            if (SelectLevel >= 0 && SelectLevel < Config.Levels.Count)
            {
                Gizmos.color = Color.red;
                var levelConfig = Config.Levels[SelectLevel];
                foreach (var item in levelConfig.Items)
                {
                    Vector3 center = miniPoint + (Vector3)((item.Point + Vector2.one * 0.5f) * cellInterval);
                    Vector3 size   = item.Size * cellInterval;
                    Gizmos.DrawWireCube(center, size);
                    //prefab
                    string     prefabPath = GetPrafabPath(item.Sprite);
                    GameObject prefab     = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath);
                    //prefab
                    if (prefab != null)
                    {
                        Vector2 texturePoint = new Vector2(center.x - size.x * 0.5f, center.y - size.y * 0.5f);
                        Rect    textureRect  = new Rect(texturePoint, size);
                        Sprite  sprite       = prefab.transform.Find("Image").GetComponent <Image>().sprite;
                        Gizmos.DrawGUITexture(textureRect, sprite.texture);
                    }
                }
            }
        }
예제 #11
0
 public static Drawing DrawGUITexture(Rect screenRect,
                                      Texture texture,
                                      int leftBorder,
                                      int rightBorder,
                                      int topBorder,
                                      int bottomBorder,
                                      Material mat)
 {
     return(Draw(new Drawing(() => Gizmos.DrawGUITexture(screenRect, texture, leftBorder, rightBorder, topBorder, bottomBorder, mat))));
 }
예제 #12
0
 public void OnDrawGizmosSelected()
 {
     if (visualize && forceVariationMap != null)
     {
         Material mat = (Material)AssetDatabase.LoadAssetAtPath("Assets/Force2D/Gizmos/Gizmos.mat", typeof(Material));
         Gizmos.DrawGUITexture(
             new Rect(boxCollider.bounds.min.x, boxCollider.bounds.max.y, boxCollider.size.x, -boxCollider.size.y),
             forceVariationMap, mat);
     }
 }
예제 #13
0
    private void OnDrawGizmos()
    {
        Texture2D texture2D = new Texture2D(heightmapResolution, heightmapResolution);

        texture2D.SetPixels(_pixels);
        texture2D.Apply();


        Gizmos.DrawGUITexture(new Rect(0, 0, 500, 500), texture2D);
    }
 private void OnDrawGizmos()
 {
     if (textureGuizmo)
     {
         Gizmos.DrawGUITexture(new Rect(transform.position.x, transform.position.y, textureGuizmo.width, textureGuizmo.height), textureGuizmo);
     }
     else
     {
         Gizmos.DrawWireSphere(transform.position, 0.3f);
     }
 }
예제 #15
0
 /// <summary>
 /// Draws the texture.
 /// </summary>
 /// <param name="rect">The rect.</param>
 /// <param name="useGizmos">if set to <c>true</c> [use gizmos].</param>
 private void DrawTexture(Rect rect, bool useGizmos)
 {
     if (useGizmos)
     {
         Gizmos.DrawGUITexture(rect, m_GutterTexture);
     }
     else
     {
         Graphics.DrawTexture(rect, m_GutterTexture);
     }
 }
예제 #16
0
    /// <summary>
    /// Callback to draw gizmos that are pickable and always drawn.
    /// </summary>
    void OnDrawGizmos()
    {
        if (mTexture == null)
        {
            return;
        }
        Gizmos.DrawGUITexture(new Rect(20, 20, 20f, 20f), mTexture);
        Gizmos.color = Color.yellow;
        Gizmos.DrawCube(this.transform.position, new Vector3(2f, 2f, 2f));

        Gizmos.DrawIcon(this.transform.position + new Vector3(2, 2, 0), "node3", true);
    }
예제 #17
0
    public void OnDrawGizmos()
    {
        Gizmos.color = Color.green;

        int i = 0;

        while (i < pipsPerDay && PipTemplate != null)
        {
//            Gizmos.DrawCube( transform.TransformPoint(new Vector3(i * pipSpacing, 0)), Vector3.one * 20);
            Gizmos.DrawGUITexture(new Rect(transform.TransformPoint(new Vector3(i * pipSpacing, 0)), 20 * PipTemplate.transform.localScale), PipTemplate.GetComponent <Image>().sprite.texture);
            i++;
        }
    }
예제 #18
0
    private void OnDrawGizmos()
    {
        if (backgroundTexture == null)
        {
            return;
        }

        transform.position = new Vector3(transform.position.x.RoundToNearest(1), transform.position.y.RoundToNearest(1), 0);

        var gizmoSize  = new Vector2(areaSize.x.RoundToNearest(2), areaSize.y.RoundToNearest(2));
        var texturePos = new Vector2(transform.position.x - gizmoSize.x / 2, transform.position.y - gizmoSize.y / 2);

        Gizmos.DrawGUITexture(new Rect(texturePos, gizmoSize), backgroundTexture);
    }
예제 #19
0
    private void OnDrawGizmos()
    {
        Gizmos.color = _color;

        switch (drawtype)
        {
        case GizmoList.Cube:
            Gizmos.DrawCube(transform.position, Vector3.one);
            break;

        case GizmoList.WireCube:
            Gizmos.DrawWireCube(transform.position, Vector3.one);
            break;

        case GizmoList.Sphere:
            Gizmos.DrawSphere(transform.position, 1);
            break;

        case GizmoList.WireSphere:
            Gizmos.DrawWireSphere(transform.position, 1);
            break;

        case GizmoList.Ray:
            Gizmos.DrawRay(transform.position, Vector3.up);
            break;

        case GizmoList.Line:
            Gizmos.DrawLine(transform.position, transform.position + new Vector3(1, 0, 1));
            break;

        case GizmoList.Icon:
            //ファイルは、Assets/Gizmosフォルダ内に格納しておく必要があります。
            Gizmos.DrawIcon(transform.position, "circle.png");
            break;

        case GizmoList.GUITexture:
            Gizmos.DrawGUITexture(new Rect(transform.position.x, transform.position.y, 2, 2), tex);
            break;

        case GizmoList.Frustrum:
            Gizmos.matrix = transform.localToWorldMatrix;
            Gizmos.DrawFrustum(Vector3.zero, 60, 0, 3, 1.3f);

            break;
        }
        #if UNITY_EDITOR
        UnityEditor.Handles.Label(transform.position + new Vector3(0, 3, 0), $"{drawtype.ToString()}");
        #endif
    }
예제 #20
0
 protected void OnDrawGizmos()
 {
     if (this.b != null)
     {
         Gizmos.DrawGUITexture(new Rect(0, 0, gridDimension.x, gridDimension.y), this.b);
     }
     if (this.x != null)
     {
         Gizmos.DrawGUITexture(new Rect(0, gridDimension.y, gridDimension.x, gridDimension.y), this.x);
     }
     if (this.difference != null)
     {
         Gizmos.DrawGUITexture(new Rect(0, gridDimension.y * 2, gridDimension.x, gridDimension.y), this.difference);
     }
 }
        void OnDrawGizmosSelected()
        {
            MeshFilter thisFilter = GetComponent <MeshFilter>();

            if (thisFilter && thisFilter.sharedMesh)
            {
                // Draw vertices.
                Gizmos.matrix = Matrix4x4.TRS(Vector3.zero, transform.rotation, transform.localScale);
                Vector3[] vertices = thisFilter.sharedMesh.vertices;
                for (int i = 0; i < vertices.Length; i++)
                {
                    Gizmos.color = Color.red;
                    Gizmos.DrawSphere(vertices[i] + transform.position, 0.01f);
                }

                // Draw UV lines.
                if (Show_Texture)
                {
                    Texture tex  = GetComponent <MeshRenderer>().sharedMaterial.mainTexture;
                    float   size = 2.0f;
                    Gizmos.DrawGUITexture(new Rect(size / 2.0f, size / 2.0f, -size, -size), tex);
                    float[] heightArray =
                    {
                        Line_A,
                        Line_B,
                        Line_C,
                        Line_D,
                        Line_E,
                        Line_F,
                        Line_G,
                        Line_H,
                        Guide_Line_Top,
                        Guide_Line_Bottom
                    };
                    Gizmos.color = Color.yellow;
                    for (int i = 0; i < heightArray.Length; i++)
                    {
                        Vector3 tempPos = new Vector3(size / 2.0f, -size / 2.0f + (heightArray[i] * size), 0.0f);
                        for (int j = 0; j < 6; j++)
                        { // Make the lines strong.
                            Gizmos.DrawLine(tempPos, tempPos + Vector3.left * size);
                        }
                    }
                }
            }
        }
예제 #22
0
        protected virtual void OnDrawGizmos()
        {
            Gizmos.color = Color.blue;
            foreach (var doorSpot in Data?.Doors)
            {
                var position = (Vector3)doorSpot.Position;
                Gizmos.DrawCube(position + transform.position, gizmosDoorSize);
            }

            Gizmos.color = Color.red;
            foreach (var enemySpot in Data?.Enemies)
            {
                var position = (Vector3)enemySpot.Position;
                var rect     = new Rect(position + transform.position - size / 2, size);
                Gizmos.DrawGUITexture(rect, enemySpot.Enemy.Icon);
                Gizmos.DrawWireSphere(position + transform.position, 0.2f);
            }
        }
예제 #23
0
    void OnDrawGizmos()
    {
                #if UNITY_EDITOR
        UnityEditor.Handles.Label(Vector3.zero, "generations: " + generations.ToString());
        UnityEditor.Handles.Label(new Vector3(0f, -1f, 0f), "populations: " + count);
                #endif

        /*
         * var l = resolution - 1;
         * for(int y = 0; y < resolution; y++)
         * {
         * for(int x = 0; x < resolution; x++)
         * {
         * if(x < l)
         * {
         *  Gizmos.DrawLine(new Vector3(x, y, 0f), new Vector3(x + 1f, y, 0f));
         * }
         * if(y < l)
         * {
         *  Gizmos.DrawLine(new Vector3(x, y, 0f), new Vector3(x, y + 1f, 0f));
         * }
         * }
         * }
         */

        /*
         * if (nematodes == null) return;
         * for(int i = 0, n = painters.Count; i < n; i++) {
         *      var painter = painters[i];
         *      var t = 1f * i / n;
         *      var color = grad.Evaluate(t);
         *      color.a *= Mathf.Lerp(0.5f, 1f, t);
         *      Gizmos.color = color;
         * DrawPainterGizmos(painter);
         * }
         */

        if (showTexture)
        {
            Gizmos.DrawGUITexture(new Rect(-0.5f, -0.5f, 1, 1), source);
        }
    }
예제 #24
0
 private void OnDrawGizmos()
 {
     if (drawGizmosForDebugging && MaskEnabled())
     {
         Gizmos.color = Color.yellow;
         rectTransform.GetWorldCorners(fourCorners);
         Rect r = new Rect
         {
             x      = fourCorners[0].x,
             y      = fourCorners[1].y,
             width  = fourCorners[2].x - fourCorners[1].x,
             height = fourCorners[0].y - fourCorners[1].y
         };
         Gizmos.DrawGUITexture(r, alphaTexture);
         for (int i = 0; i < 4; i++)
         {
             Gizmos.DrawLine(fourCorners[i], fourCorners[(i + 1) % 4]);
         }
     }
 }
예제 #25
0
        static void DrawGizmoForMyScript(PlaceManager baseManager, GizmoType gizmoType)
        {
            if (!baseManager.drawGizmoPlace)
            {
                return;
            }

            Dictionary <PlaceType, List <Place> > basePerType = baseManager.GetPlacesPerType();

            if (basePerType == null)
            {
                return;
            }

            Texture      texture;
            List <Place> bases;

            Rect rect = new Rect();

            rect.width  = 10;
            rect.height = 10;
            Vector2 offset = rect.size / 2;

            foreach (PlaceType baseType in basePerType.Keys)
            {
                bases = basePerType[baseType];

                foreach (Place currentPlace in bases)
                {
                    texture = baseManager.GetTextureIcon(baseType);

                    Vector2 position = currentPlace.transform.position;
                    position -= offset;

                    rect.position = position;

                    Gizmos.DrawGUITexture(rect, texture);
                }
            }
        }
예제 #26
0
        protected void OnDrawGizmos()
        {
            if (this.grid == null)
            {
                return;
            }
            var gridDimension = new Vector2Int(this.grid.pressure.nx, this.grid.pressure.ny);

            if (this.grid.b != null)
            {
                Gizmos.DrawGUITexture(new Rect(0, 0, gridDimension.x, gridDimension.y), this.grid.b);
            }
            if (this.grid.x != null)
            {
                Gizmos.DrawGUITexture(new Rect(0, gridDimension.y, gridDimension.x, gridDimension.y), this.grid.x);
            }
            if (this.grid.markerTex != null)
            {
                Gizmos.DrawGUITexture(new Rect(0, gridDimension.y * 2, gridDimension.x, gridDimension.y), this.grid.markerTex);
            }
            //if (this.difference != null) Gizmos.DrawGUITexture(new Rect(0, gridDimension.y * 2, gridDimension.x, gridDimension.y), this.difference);
        }
예제 #27
0
        protected override void OnDrawGizmosSelected()
        {
            //base.OnDrawGizmosSelected();

            if (!drawGUITexture)
            {
                return;
            }
            if (gridData == null || gridData.Count == 0)
            {
                return;
            }

            foreach (LevelGridData block in gridData)
            {
                Rect    rect    = block.GetRectPoints();
                Texture texture = block.GetTextureToDraw();
                if (texture == null)
                {
                    continue;
                }
                Gizmos.DrawGUITexture(rect, texture);
            }
        }
예제 #28
0
        static void DrawGizmo(ImageTargetController scr, GizmoType gizmoType)
        {
            var signature = scr.SourceType.ToString();

            switch (scr.SourceType)
            {
            case ImageTargetController.DataSource.ImageFile:
                if (!EasyARController.Settings.GizmoConfig.ImageTarget.EnableImageFile)
                {
                    return;
                }
                signature += scr.ImageFileSource.PathType.ToString() + scr.ImageFileSource.Path;
                break;

            case ImageTargetController.DataSource.TargetDataFile:
                if (!EasyARController.Settings.GizmoConfig.ImageTarget.EnableTargetDataFile)
                {
                    return;
                }
                signature += scr.TargetDataFileSource.PathType.ToString() + scr.TargetDataFileSource.Path;
                break;

            case ImageTargetController.DataSource.Target:
                if (!EasyARController.Settings.GizmoConfig.ImageTarget.EnableTarget)
                {
                    return;
                }
                if (scr.Target != null)
                {
                    signature += scr.Target.runtimeID().ToString();
                }
                break;

            default:
                break;
            }

            if (scr.GizmoData.Material == null)
            {
                scr.GizmoData.Material = new Material(Shader.Find("EasyAR/ImageTargetGizmo"));
            }
            if (scr.GizmoData.Signature != signature)
            {
                if (scr.GizmoData.Texture != null)
                {
                    UnityEngine.Object.DestroyImmediate(scr.GizmoData.Texture);
                    scr.GizmoData.Texture = null;
                }

                string path;
                switch (scr.SourceType)
                {
                case ImageTargetController.DataSource.ImageFile:
                    path = scr.ImageFileSource.Path;
                    if (scr.ImageFileSource.PathType == PathType.StreamingAssets)
                    {
                        path = Application.streamingAssetsPath + "/" + scr.ImageFileSource.Path;
                    }
                    if (System.IO.File.Exists(path))
                    {
                        var sourceData = System.IO.File.ReadAllBytes(path);
                        scr.GizmoData.Texture = new Texture2D(2, 2);
                        scr.GizmoData.Texture.LoadImage(sourceData);
                        scr.GizmoData.Texture.Apply();
                        UpdateScale(scr, scr.ImageFileSource.Scale);
                        if (SceneView.lastActiveSceneView)
                        {
                            SceneView.lastActiveSceneView.Repaint();
                        }
                    }
                    break;

                case ImageTargetController.DataSource.TargetDataFile:
                    path = scr.TargetDataFileSource.Path;
                    if (scr.TargetDataFileSource.PathType == PathType.StreamingAssets)
                    {
                        path = Application.streamingAssetsPath + "/" + scr.TargetDataFileSource.Path;
                    }
                    if (System.IO.File.Exists(path))
                    {
                        if (!EasyARController.Initialized)
                        {
                            EasyARController.GlobalInitialization();
                            if (!EasyARController.Initialized)
                            {
                                Debug.LogWarning("EasyAR Sense target data gizmo enabled but license key validation failed, target data gizmo will not show");
                            }
                        }
                        var sourceData = System.IO.File.ReadAllBytes(path);

                        using (Buffer buffer = Buffer.wrapByteArray(sourceData))
                        {
                            var targetOptional = ImageTarget.createFromTargetData(buffer);
                            if (targetOptional.OnSome)
                            {
                                using (ImageTarget target = targetOptional.Value)
                                {
                                    var imageList = target.images();
                                    if (imageList.Count > 0)
                                    {
                                        var image = imageList[0];
                                        scr.GizmoData.Texture = new Texture2D(image.width(), image.height(), TextureFormat.R8, false);
                                        scr.GizmoData.Texture.LoadRawTextureData(image.buffer().data(), image.buffer().size());
                                        scr.GizmoData.Texture.Apply();
                                    }
                                    foreach (var image in imageList)
                                    {
                                        image.Dispose();
                                    }
                                    UpdateScale(scr, target.scale());
                                    if (SceneView.lastActiveSceneView)
                                    {
                                        SceneView.lastActiveSceneView.Repaint();
                                    }
                                }
                            }
                        }
                    }
                    break;

                case ImageTargetController.DataSource.Target:
                    if (scr.Target != null)
                    {
                        var imageList = (scr.Target as ImageTarget).images();
                        if (imageList.Count > 0)
                        {
                            var image = imageList[0];
                            scr.GizmoData.Texture = new Texture2D(image.width(), image.height(), TextureFormat.R8, false);
                            scr.GizmoData.Texture.LoadRawTextureData(image.buffer().data(), image.buffer().size());
                            scr.GizmoData.Texture.Apply();
                        }
                        foreach (var image in imageList)
                        {
                            image.Dispose();
                        }
                        UpdateScale(scr, (scr.Target as ImageTarget).scale());
                        if (SceneView.lastActiveSceneView)
                        {
                            SceneView.lastActiveSceneView.Repaint();
                        }
                    }
                    break;

                default:
                    break;
                }

                if (scr.GizmoData.Texture == null)
                {
                    scr.GizmoData.Texture = new Texture2D(2, 2);
                    scr.GizmoData.Texture.LoadImage(new byte[0]);
                    scr.GizmoData.Texture.Apply();
                }
                scr.GizmoData.Signature = signature;
            }

            if (scr.GizmoData.Material && scr.GizmoData.Texture)
            {
                scr.GizmoData.Material.SetMatrix("_Transform", scr.transform.localToWorldMatrix);
                if (scr.GizmoData.Texture.format == TextureFormat.R8)
                {
                    scr.GizmoData.Material.SetInt("_isRenderGrayTexture", 1);
                }
                else
                {
                    scr.GizmoData.Material.SetInt("_isRenderGrayTexture", 0);
                }
                scr.GizmoData.Material.SetFloat("_Ratio", (float)scr.GizmoData.Texture.height / scr.GizmoData.Texture.width);
                Gizmos.DrawGUITexture(new Rect(0, 0, 1, 1), scr.GizmoData.Texture, scr.GizmoData.Material);
            }
        }
예제 #29
0
 public static void DrawGUITexture(Rect screenRect, Texture texture, Material mat)
 {
     Gizmos.DrawGUITexture(screenRect, texture, mat);
 }
예제 #30
0
 public static void DrawGUITexture(Rect screenRect, Texture texture)
 {
     Gizmos.DrawGUITexture(screenRect, texture);
 }