Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
4 captures
13 Jun 22 - 14 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 gilangmwa · Jul 02, 2021 at 09:02 AM · texture2drendertexturefreezefreezinggetpixel

Unity crashes trying to get pixels and using Debug.Log

The one that is doing the crases is the one "UnityEngine.Debug.Log(R)" line in the code, if it is deleted it won't crash, but I'll have no idea how to test if it works. This also happens if I made the list variable(InputLayer) public to the inspector. In short, Unity will crash if I try to view the list variable through anything.

Code:

 void Awake()
     {
         CurrentVidFrame = new Texture2D(608, 1080, TextureFormat.ARGB32, false);
 
         VideoPlayer.sendFrameReadyEvents = true;
         VideoPlayer.frameReady += OnNewFrame;
         VideoPlayer.Play();
     }
 
 
     //this is gonna work as the inputs
     void OnNewFrame(VideoPlayer source, long frameIdx)
     {
         RenderTexture.active = (RenderTexture)source.texture;
         Graphics.CopyTexture((RenderTexture)source.texture, CurrentVidFrame);
 
         //UnityEngine.Debug.Log(CurrentVidFrame); 
 
         // clear it every frame
         InputLayer.Clear();
 
         //getting each pixel (heavy as hell)
         for (int i = 0; i <(720 * 1280) - 1; i++)
         {
 
             float Col = i / 720;
             int columnOfFrame;
             columnOfFrame = (int)Math.Floor(Col); // rounds down to get the column number of pixels

             int row = i - (720 * columnOfFrame); // get the row number of the pixels

             // get the pixel color from the calculated numbers
             Color pixColor = CurrentVidFrame.GetPixel(row, columnOfFrame); 
             float R = pixColor.r * 255; // to get a value from 0 - 1
             InputLayer.Add(R); // add it to the list
 
             UnityEngine.Debug.Log(R); // and then this shitty line freezes unity
 
         }
     }



Please feel free to ask questions, I am quite stuck.

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

128 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

Related Questions

Texture2D GetPixel returns the same value everywhere 2 Answers

Using Texture2DArray as RenderTarget and passing data to fragment shader 2 Answers

Unity freezes temporarily when recompiling/refreshing scripts 2 Answers

Color of texture pixels not pure 2 Answers

Freeze when building 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