Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mdagreda · Jan 02, 2013 at 02:44 AM · texturepluginhtmlwiki

How do install a plugin?

So I got the htmlTexturePlugin from the unity wiki here http://wiki.unity3d.com/index.php?title=HtmlTexturePlugin

and I'm not sure how to get it to work. I dropped the bundle I downloaded into unity and I got it to install something called htmlTexture. Then I placed the sample code they have on the wiki into a script and placed that script on a plane. But I got back a bunch of errors. One error was" 'm_Texture' does not exist in the current context". Here is the code I used. using UnityEngine; using System.Collections; public class htmlTexture : MonoBehaviour { public int width =512; public int height = 512; void Start() { m_Texture = new Texture2D (width, height, TextureFormat.ARGB32, false); m_Texture.Apply(); htmlTexture_start(m_Texture.GetInstanceID(), width, height, "http://google.com"); // put the texture on something transform.renderer.sharedMaterial.mainTexture = m_Texture; } void Update() { htmlTexture_update( m_Texture.GetInstanceID() ); } void OnApplicationQuit() { htmlTexture_stop(); } }

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Wiggitamoo · Jan 17, 2013 at 07:28 PM 0
Share

am also having this same problem. I created a script and added the code provided on the website to the class. I dropped the c# code on the plane and received the following error:

'm_Texture' does not exist in the current context.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Loius · Jan 17, 2013 at 09:37 PM

You need to declare m_Texture's type.

I hate unofficial tutorials for exactly this reason. Why would someone provide that example code in such a flawed state? O_o

You need this line in your class to make m_Texture a class variable:

 Texture2D m_Texture;


Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Wiggitamoo · Jan 18, 2013 at 04:26 PM

I'm still having problems getting this code to work. Is this how you setup the code?

 using UnityEngine;
 using System.Collections;
 using System;
 using System.Runtime.InteropServices;
 using System.Text;
  
 public class DisplayWebpage : MonoBehaviour {
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_start( int textID, int width, int height, string url );
     //    creates the offscreen window and webview
     //    url: initial URL to display, use null for none
     //    width, height: currently must be a power of 2 (i.e. 128, 256, 512, 1024) due to my using GL_TEXTURE2D
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_stop();
     // releases all windows and webview; use on quit
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_update ( int texID );
     // makes bitmap of the webview and loads it into openGL with the given texture ID
  
     //
     // browser functions
     //
     // as you'd expect, handles any URL, HTML and CSS that webkit can
     //
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_setURL( int texID, string url);
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_getURL( int texID, StringBuilder url, int stringCapacity);
     // to get the current URL, you need to pass in a StringBuilder and its capacity (to
     // avoid buffer overflow errors)
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_goBack( int texID );
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_goForward( int texID );
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_sendJavascript( int texID, string js);
     // sends a string to the webview's javascript interpreter
     // will return a string result as soon as I get the Marshall class figured out
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_sendJavascript( int texID, string js, StringBuilder result, int stringCapacity);
     // sends a string to the webview's javascript interpreter
     // will return a string result 
  
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_sendKeypress( int texID, string s);
  
  
     //
     // these functions simulate a mouse event in the webview
     //
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_mousemoved( int texID, int _x, int _y );
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_mousedown( int texID,  int _x, int _y );
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_mouseup( int texID, int _x, int _y );
  
     [DllImport ("htmlTexture")]
     private static extern void htmlTexture_leftclick( int texID, int _x, int _y );
     // leftclick = a mousemoved, mousedown, and mouseup 
  
     // 
     public int width =512;
     public int height = 512;
     Texture2D m_Texture;
     void Start() {
         m_Texture = new Texture2D (width, height, TextureFormat.ARGB32, false);
         m_Texture.Apply();
         htmlTexture_start(m_Texture.GetInstanceID(), width, height, "http://google.com");
         // put the texture on something
         transform.renderer.sharedMaterial.mainTexture = m_Texture;
     }
      
     void Update() {
         htmlTexture_update( m_Texture.GetInstanceID() );
     }
      
     void OnApplicationQuit() {
         htmlTexture_stop();
     }
     void OnMouseUp()
     {
         RaycastHit hit;
         if (Physics.Raycast (Camera.main.ScreenPointToRay(Input.mousePosition), out hit)) {
             int x = width - (int) (hit.textureCoord.x * width); 
             int y = height - (int) (hit.textureCoord.y * height); 
             htmlTexture_mouseup(m_Texture.GetInstanceID(), x, y );
         }
     }
     // 
 }


Please let me know if you have any differences / suggestions

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can Unity utilize textures created by a plugin? 1 Answer

html texture plugin 1 Answer

Problem, Textures updated by plugin won't behave as expected in combination with HLSL shader 2 Answers

Are there any good plugins out there for putting a web page into a unity scene? 1 Answer

LIVETEXTURE FRONT CAMERA BACK, STOP VUFORIA PLUGIN 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges