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 Balthatczar · Jun 07, 2013 at 11:33 AM · iosnativereceiver

UnitySendMessage does and doesn't recognize receiver in 2 similar instances

  • edit

So i guess i've figured out what the problem is, i've assigned the MonoBehaviour also on the GameObject that is in the the level targeted for loading. Turns out that the message telling there's no receiver is actually responding to the GameObject that is in the loaded level. So the level is loaded, but it isn't being displayed. Which makes me think that creating the MPMoviePlayer does eliminate the 'thing' 'component', that is responsible for rendering. Anyone has any thoughts on that ?



I'm writing a small plugin for streaming video native on iOS, and am stuck on an issue with the native code.

When streaming the video the fuction detects for swipes and if so calls on a method called loadLevelNative that sends a message to some GameObject that has a script assigned containing the function public void loadLevelUnity(string str); All this does is load another level like so Application.LoadLevel(str);

The weird thing is that if i send the message in a function declared as C by placing it in an extern "C" block. And let it just do that, it works fine .. the designated level is instantly loaded... so far so good. This however is of course not what i want, the way its supposed to work is having the UISwipeGestureRecognizer added to the movieplayer which calls on a method that sends the message. All this is working... however the Xcode output tells me that in this instance that "SendMessage: object GameObject does not have receiver for function loadLevelUnity!" I fail to understand why..., it does recognize the GameObject fine.

I named the GameObject, GameObject so if i change to SendMessage parameter to something else, say ObjectGame then there's a message that object "ObjectGame" cannot be found, this all speaks for itself but i figured to be as clear as possible.

So to surmise, if UnitySendMessage is called from the method assigned to the gesture recognizer then it won't receive the public function on the GameObject, and i can't figure out why. I'm hoping some of you can help me out here

Its a tiny bit of code (VideoPlugin.mm), i've put it up here : http://pastebin.com/DWbh8mRz

The native code comment is a leftover of the bonjour plugin sample that i used as a template, i left it in there for clarity.

loadLevelUnity is simply this:

 public void loadLevelUnity(string str)
 {
   Application.LoadLevel(str);
 }

and finally the interface defined in VideoPlugin.h

 @interface VideoPlugin : UISwipeGestureRecognizer
 
    - (void)loadLevelNative;
 
 @end 

This is the code of the Unity MonoBehaviour that is attached to GameObject named GameObject in my scene.

 using UnityEngine;
 using System.Collections;
 
 public class vidtest : MonoBehaviour {
 
 
      public void loadLevelUnity(string str) {
 
       Application.LoadLevel(str);
 
     }
 
 
     void Start () {
 
       VideoPlugin.playVideo("http://www.royniginal.nl/small.mp4");
 
     }
 
  } 

And this is the code that interfaces with the native code, its in a separate file.

 using UnityEngine;
 using System.Collections;
 using System.Runtime.InteropServices;
 
 public class VideoPlugin {
 
 /* Interface to native implementation */
 
     [DllImport ("__Internal")]
 
     private static extern void _playVideo (string videoFilepath);
 
 
 /* Public interface for use inside C# / JS code */
 
     public static void playVideo(string videoFilepath) {
 
     if (Application.platform != RuntimePlatform.OSXEditor)
 
     _playVideo(videoFilepath);
 
     }
  }

What is even weirder to me, is that i change the third argument of UnitySendMessage to the name of a level that isn't in the build settings i get a message in Xcode output saying " Level 'pictureLoad' (-1) couldn't be loaded because it has not been added to the build settings. " Yet if that parameter is set up correctly i get a message that the GameObject has no receiver for the function that loads the level ?

Comment
Add comment · Show 7
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 Lovrenc · Jun 07, 2013 at 11:36 AM 1
Share
  1. Stop spam$$anonymous$$g. You posted this question 10 times!!!

  2. Format your code. Its hard to read code after someone especially if it is posted in such unreadable state. $$anonymous$$ake your post nicer and you will get better results.

avatar image Balthatczar · Jun 07, 2013 at 11:49 AM 0
Share

I've posted it twice, once on the forum and once here. I'll format the code, right now.

avatar image Lovrenc · Jun 07, 2013 at 11:55 AM 0
Share

You posted it here 10 or eleven times. I know. Because i had to decline all but one of them...

avatar image Balthatczar · Jun 07, 2013 at 11:59 AM 0
Share

What are you talking about ? I wrote the post once and clicked Ask your question. If thats true, there must be something going wrong with the system i guess...

avatar image Lovrenc · Jun 07, 2013 at 12:06 PM 0
Share

$$anonymous$$ight be. But i havent seen it before.

You're question looks nice now. Good job.

Show more comments

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

16 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

Related Questions

iOS modal viewcontroller disappears 0 Answers

Use of Unity ads in Native Apps IOS 0 Answers

iOS Music Control 0 Answers

How can I get/set iOS Alarms? 1 Answer

Need help ios native share 1 Answer


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