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
-1
Question by netkingZ · Apr 13, 2013 at 06:56 PM · texturesaveinsert

Insert the texture means the URL

Hello i want insert the texture on plane means the URL. I use this script in C# but the system don't error returns:

 using UnityEngine;
 using System.Collections;
 using System.IO;
 
 public class OpenFilePanel : MonoBehaviour {
     
     
     
     bool modys = false;
     bool modus = false;
     private Rect windowRect = new Rect(Screen.width/2, 300,320,150);        
     string Text = "";
     string NameT = "";
     
     
     void OnMouseDown() {
 
         modys = !modys;
     }
     
     void OnGUI () {
     
         if(modys){
             // Register the window. Notice the 3rd parameter 
             windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window");
         
             }
     }
     
       // Make the contents of the window
    private void DoMyWindow (int id) {
     
              GUILayout.Label("URL:");
             
             Text = GUILayout.TextField(Text, GUILayout.Width(300) , GUILayout.Height(20));
         
             GUILayout.Label("NameTexture:");
             
             NameT = GUILayout.TextField(NameT, GUILayout.Width(300) , GUILayout.Height(20));    
             
             GUILayout.BeginHorizontal();
         
     
              if(GUILayout.Button ("Save")) {
                    
                    modus = !modus;
                     Save();
                     
                                     
                 }
         
                if(GUILayout.Button ("Close")) {
             
                    modys = false;
             
             
                }
         
         GUILayout.EndHorizontal();
        
             
             
     }
 
     
     // Update is called once per frame
     IEnumerator Save () {
         
         if(modus){
         
           string url = Text;
                     print(url);
                    // Create a texture in DXT1 format
                                 renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
                                 while (true) {
                                 // Start a download of the given URL
                                 var www = new WWW(url);
                                 
                                 yield return www;
                                 // assign the downloaded image to the main texture of the object
                                 www.LoadImageIntoTexture((Texture2D)renderer.material.mainTexture);
             }
         }
     
     }
     
     void Start()
 
     {
 
         StartCoroutine("WritePNG");
 
     }
 
     
         IEnumerator WritePNG()
 
     {
 
         // We should only read the screen buffer after rendering is complete
 
         yield return new WaitForEndOfFrame();
 
  
 
         // Create a texture the size of the screen, RGB24 format
 
         int width = Screen.width;
 
         int height = Screen.height;
 
         Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
 
  
 
         // Read screen contents into the texture
 
         tex.ReadPixels(new Rect(0, 0, width, height), 0, 0, false);
 
         //tex.Apply(); //Needed? setPixels not called and it works without Apply.
 
  
 
         // Encode texture into PNG
 
         byte[] bytes = tex.EncodeToPNG();
 
         Destroy(tex);
 
  
 
         // Write to a file in the project folder
 
         File.WriteAllBytes(Application.dataPath + "/../" + NameT + ".png", bytes);
 
     }
     
     
     
     
 }

Recapitulating:

1- I want to submit a URL to take the picture. 2 - I want to be able to immediately place the texture on the floor. 3 - I want to save the texture.

Thank you for your attention. Help me.

Comment
Add comment · Show 2
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 netkingZ · Apr 14, 2013 at 07:56 AM 0
Share

Help me. Thank you.

avatar image netkingZ · Apr 16, 2013 at 10:30 AM 0
Share

Help me. Thank you.

0 Replies

· Add your reply
  • Sort: 

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

10 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

Related Questions

Terrain textures "reset" 0 Answers

Is there a way to save a texture to the iPhone/iPad? 2 Answers

Is it possible to save loaded textures and reuse after close app? 1 Answer

how to save a texture in background by looking at it. 2 Answers

Assigning UV Map to model at runtime 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