Jump to content

PNG texture visualisation problem on GUI


Recommended Posts

I'm trying to create a camera plugin with target textures layer. The rendered camera image is displayed, but the texture overlaid is failed.

In Unity3D working, but in KSP doesn't. On left side of simple camera picture visible the failed and on the right side what i want it.

7vFL7fU.png

J2pjlYz.png
What could be the problem?
        private void OnWindow(int windowID)
        {
            GUILayout.BeginHorizontal();

            // Close window button
            if (GUI.Button(new Rect((renderSize.x + 2 * windowBorder.x) - 20f, 3, 17, 15), "x"))
            {
                clcWindowActive = false;
                // This will hide the TurnOffCLCEven event, and show the TurnOnCLCEvent event.
                Events["TurnOnCLCEvent"].active = true;
                Events["TurnOffCLCEvent"].active = false;
                clcWindowActive = false;
                OnSave(nodeInner);
            }

            GUI.DrawTexture(TexturePosition, _textureBackGroundCamera);

            //if (Event.current.type.Equals(EventType.Repaint))
            //    Graphics.DrawTexture(TexturePosition, Render(), null);

            GUI.DrawTexture(TexturePosition, texLEEHUD);

            //Yoffset = 0;
            //Rect inputRect = new Rect(20, 40, 40, 20);
            //AddOutputValue(inputRect, "eePosition", eeCamera.transform.position, 110f, 110f);
            //AddOutputValue(inputRect, "eeRotation", eeCamera.transform.rotation.eulerAngles, 110f, 110f);

            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }

 

Edited by Trufiadok
Link to comment
Share on other sites

Problem solved. Bug was in load function of PNG.

JaDSy6n.png

old code: tex = new Texture2D(2, 2);

new code: tex = new Texture2D(2, 2, TextureFormat.ARGB32, false);

I have another problem: On the rendered camera image "Camera 01" layer haven't got texture. I fill failed area with pink color.

UGYXvUh.png

I used camera renderer routine from @RasterPropMonitor plugin.

 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...