Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 gcscreations · Apr 08, 2018 at 04:48 AM · unity 5

My cam not open using webcamtexture

I just create augment camera to get feature and play some videos....in my code very well working in android but not in ios...If anybody know about this issue help me..

THis is my code:

using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; using System; using UnityEngine.Rendering; using System.IO; using System.Text; using System.Threading; using System.Text.RegularExpressions; using System.Collections; using System.Collections.Generic; using System.Net; using System.Net.NetworkInformation;

//using DeadMosquito.AndroidGoodies;

public class ohg : MonoBehaviour {// Camera screenshotCamera; //private TextAsset asset; //public Text txt; //private StreamWriter writer; private bool camAvailable; private Texture greenlaser; //private Texture errmsg; //Texture2D snap; private int ll = 0;//public string devid; private WebCamTexture backCam;

 private float k2=0;
 private Texture defaultBackground;
 public  RawImage backGround;
 public AspectRatioFitter fit;

 //public Font f;
 //public GameObject neterror;
 //public int ccv = 0;    
 public string Ddf;
 private float k=0;//    private float k1=0;    private float k2=0;    public int cls=0;
 private float k5=0;
 //public int ta = 0;
 //public int ll=0;

 public void Start()
 {
     //anim.Play ("Siva");

     /* FileInfo theSourceFile11 = new FileInfo(Application.persistentDataPath + "/" + "phnonote.txt");


      //FileInfo theSourceFile = new FileInfo (Application.persistentDataPath + "/" + "T.txt");
      StreamReader reader11 = theSourceFile11.OpenText();
      string texturl11;
      texturl11 = reader11.ReadToEnd();
      if (texturl11 != null)
      {
          tables1 = (texturl11.ToString());
          //Debug.Log ("cc"+tables);
      }
      */
     //devid = AGDeviceInfo.GetAndroidId ();
     print(Application.persistentDataPath);
     //Textdi = GetComponent<Text> ();
     defaultBackground = backGround.texture;
     WebCamDevice[] devices = WebCamTexture.devices;
     if (devices.Length == 0)
     {
         Debug.Log("No Camera Detected");
         camAvailable = false;
         return;

     }
     for (int i = 0; i < devices.Length; i++)
     {
         print("Webcam available: " + devices[i].name);

         if (!devices[i].isFrontFacing)
         {
             backCam = new WebCamTexture(devices[i].name, 320, 240);
             //    backCam = new WebCamTexture (devices [i].name,400, 320);
             //    backCam = new WebCamTexture (devices [i].name,480, 400);
         }
     }
     if (backCam == null)
     {
         Debug.Log("Unable to find Back camera");
         return;
     }
     backCam.Play();
     //backgram
     backGround.texture = backCam;
     camAvailable = true;


 }

 private void Update ()
 {

     //backCam.Play();
     //Destroy (snap);

     StartCoroutine(Fade());

     if (!camAvailable)
         return;
     float ratio = (float)backCam.width / (float)backCam.height;
     fit.aspectRatio = ratio;


     float ScaleY = backCam.videoVerticallyMirrored ? -1f : 1f;
     backGround.rectTransform.localScale = new Vector3 (1f, ScaleY, 1f);

     int orient = -backCam.videoRotationAngle;
     backGround.rectTransform.localEulerAngles = new Vector3 (0, 0, orient);
     k++;


 }
 public IEnumerator Fade()
 {
      
     

     Texture2D    snap = new Texture2D((backCam.width),(backCam.height),TextureFormat.RGB24,false);

     snap.SetPixels (backCam.GetPixels()); 

     byte[] bytes = snap.EncodeToJPG();

     //backCam.Stop ();
     Destroy(snap);

     string base64s = Convert.ToBase64String (bytes);
     Debug.Log (backCam.width + "-----" + backCam.height);
     string url = "https://www.sun.com:449/";
     string customUrl = url + "WebForm1.aspx";
     //Debug.Log(tables1);dd
     //tables1 = 544445459;
     //setup a form
     WWWForm form = new WWWForm();
     form.AddField ("usd", base64s);
     form.AddField ("tables", "targettable");
     form.AddField ("phno", "9998877555");

     //print (bytes1);
     WWW www = new WWW(customUrl, form);
     
     yield return StartCoroutine (WaitForRequest (www));

     
 }
 public IEnumerator WaitForRequest(WWW www)
 {
     //Thread.Sleep (100);
     yield return www;
     // check for errors
     if (www.error == null)
     {
         Ddf = www.text;
         Debug.Log (Ddf);

             Handheld.PlayFullScreenMovie(Ddf);

     }
     else
     {

         Debug.Log("WWW Error: " + www.error);
     }

 }     
     

}

Comment
Add comment
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

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

154 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sorting order layer between instantiated prefabs and UI image 1 Answer

MeshCombineUtility problem after upgrade to Unity 5? 2 Answers

Reimporting Error - Empty Scene 0 Answers

error when putting gvrmain camera in project 2 Answers

Bad lighting in automated builds 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