Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Uni2LwP : Create Live Wallpapers with Unity 3.4.2 /3.5.7/ 4.0/4.0.1

Discussion in 'Assets and Asset Store' started by shinx, Feb 28, 2013.

Thread Status:
Not open for further replies.
  1. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    Shinx, do you know off the top of your head how I can get the code below to hide all objects with the "extraFlowersTag" tag? I think I'm close...

    Code (csharp):
    1.     public void SetShowExtraFlowers (string opt)
    2.     {
    3.         bool show;
    4.        
    5.        
    6.         if (opt == "yes")
    7.             show = true;
    8.         else
    9.             show = false;
    10.        
    11.         foreach (GameObject go in GameObject.FindGameObjectsWithTag ("extraFlowersTag")) {
    12.             renderer.enabled = (show);
    13.         }
    14.     }
     
  2. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295

    I'm not on my home computer to test this, but isn't the "go." missing inside the foreach ?

    Code (csharp):
    1.  
    2.         foreach (GameObject go in GameObject.FindGameObjectsWithTag ("extraFlowersTag")) {
    3.             go.renderer.enabled = show;
    4.         }
    5.  
    6.  
     
  3. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    The ads only appear on the settings menu. If you place ads on the home screen you will probably get a lot of bad reviews on Play Store ...

    How about a Toast message to inform the users to use the double tap feature.

    http://developer.android.com/guide/topics/ui/notifiers/toasts.html


    Code (csharp):
    1.  
    2. Context context = getApplicationContext();
    3. CharSequence text = "Hello toast!";
    4. int duration = Toast.LENGTH_SHORT;
    5.  
    6. Toast toast = Toast.makeText(context, text, duration);
    7. toast.show();
    8.  
     
  4. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    Shinx that's perfect thank you!

    Released a big update to Lily HD last night along with free version. Starting something new soon to seed a different demographic.

    Unity's slow loading is brutal sometimes I hope we or Unity figure out a way to get it faster.
     
  5. StarHunter32

    StarHunter32

    Joined:
    Feb 10, 2013
    Posts:
    99
    Hello, could I please ask where to insert this code for Toast messages? Thanks.
     
  6. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    You can add the Toast message in many places but personally I would put it inside the onCreateEngine method. This way the message is showed twice (when in preview mode and when the user presses the set wallpaper button). Also, change the duration of the Toast message to Toast.LENGTH_LONG. This way the user has time to read the message :)

    Code (csharp):
    1.  
    2. /**
    3.  * Return a new instance of the wallpaper's engine.
    4.  */
    5. @Override
    6. public Engine onCreateEngine() {
    7.     Toast toast = Toast.makeText(this, "Double tap on ....", Toast.LENGTH_LONG);
    8.     toast.show();
    9.      
    10.     return new WallpaperEngine(this);
    11. }
    12.  
     
  7. StarHunter32

    StarHunter32

    Joined:
    Feb 10, 2013
    Posts:
    99
    Thanks. However, I'm getting 3 errors/warnings on the toast line: "Toast can not be resolved/ to a variable/ to a type".
    I'm very vague at writing code and I cannot fix it.
     
  8. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    Place this in the beginning of your file:

    Code (csharp):
    1.  
    2. import android.widget.Toast;
    3.  
     
  9. resheez

    resheez

    Joined:
    Mar 22, 2013
    Posts:
    66
  10. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    Hey Shinx, I cant get that renderer toggle script to work. I'm just trying to search for gameobjects with the tag "extraFlowersTag" and set their renderer to true or false.

    It's working fine with my particle systems but those are singular objects.
     
  11. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    05-02 21:21:32.772: I/Unity(566): NullReferenceException: Object reference not set to an instance of an object
    05-02 21:21:32.772: I/Unity(566): at ElementHide.SetShowExtraFlowers (System.String opt) [0x00000] in <filename unknown>:0
    05-02 21:21:32.772: I/Unity(566):
    05-02 21:21:32.772: I/Unity(566): (Filename: Line: -1)
    05-02 21:21:32.782: I/Reverb(566): getpid() 566, IPCThreadState::self()->getCallingPid() 566

    my elementHide script is on the main camera
     
  12. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    The code that you posted with the "go." fix works perfectly. However, it seems that you are trying to access a method from one script to the other. If that's the case please take a look at the SetRotation method inside the HomeSwitch.cs file.

    Code (csharp):
    1.  
    2.  
    3. foreach (GameObject go in GameObject.FindGameObjectsWithTag ("CubeTag")) {
    4.     go.GetComponent<NAME_OF_YOUR_OTHER_SCRIPT> ().NAME_OF_THE_PUBLIC_METHOD ("hide");
    5. }
    6.  
    I'm sure that other solutions exists, but this one works :)
     
  13. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    I'm not trying to do anything fancy. The doubletap and simulateswipe methods are in the HomeSwitch.cs and my hiding and showing methods are in ElementHide.cs. Both of these scripts are on the camera.

    This javaScript sends to Unity:
    Code (csharp):
    1.         showExtraFlowers = this.pPrefs.getBoolean("showExtraFlowers", true);
    2.        
    3.         if (showExtraFlowers)
    4.             UnityPlayer.UnitySendMessage("Main Camera", "SetShowExtraFlowers", "yes");
    5.         else
    6.             UnityPlayer.UnitySendMessage("Main Camera", "SetShowExtraFlowers", "no");  

    This is the method in ElementHide.cs:
    Code (csharp):
    1.     public void SetShowExtraFlowers (string opt)
    2.     {
    3.         bool show;
    4.        
    5.        
    6.         if (opt == "yes")
    7.             show = true;
    8.         else
    9.             show = false;
    10.        
    11.             GameObject.FindGameObjectWithTag("extraFlowersTag").renderer.enabled = (show);
    12.     }
    The meshes in Unity that are tagged "extraFlowersTag", are nested in game objects that are animated. That shouldnt be a problem though I wouldn't think.
     
  14. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    It was a problem with the tag in Unity. The go method works flawlessly like you said. Thanks man :)
     
    Last edited: May 4, 2013
  15. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    Been gathering shaders for my next wallpaper.

    I'm trying to find a atmospheric scattering shader that works. Yet to get one working.
     
  16. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    Can someone who has gotten admob ads working in their LWP settings menu share their code?

    I'm having a hard time figuring this out.
     
  17. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295

    Admob is already integrated with the latest version of Uni2LwP but It’s only available during the “create live wallpaper” process. If you can’t recreate the lwp project folder again then the only option is to manually add Admob to your project.

    Tomorrow I will create a new tutorial with the name “How to manually add Admob to Uni2LwP” and place it here.
     
  18. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    Hello,

    Just finished writing the Admob tutorial.

    This is a complicated tutorial for everyone that doesn't have much knowledge in Android. I tried to make it as simple as i could. Follow it very carefully and don't forget that everything is case sentive.

    Tutorials page here

    Admob tutorial part 1 and part 2



    Best regards,
    Shinx
     
  19. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    Thanks for this :). I'm going through it when i get home from work.
     
  20. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    Worked flawlessly.
     
  21. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    Should I have two ad banners stacked on the top of my settings menu? I was expecting only one.

    I'm going to leave it that way regardless because its double the chance for someone to see something they're interested in, but I would like to understand where that's being specified.
     
    Last edited: May 7, 2013
  22. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    The code in the tutorial only shows one add banner. If you have 2, then you probably repeated this line in the file wallpaper_settings.xml

    Code (csharp):
    1.  
    2. (...)
    3.     <com.test.livewallpaper.AdmobPreference android:key="adView" ></com.test.livewallpaper.AdmobPreference>
    4. (...)
    5.  
     
  23. invisiblesense

    invisiblesense

    Joined:
    Jan 21, 2013
    Posts:
    41
    Hi Shinx,

    I built my app and everything's ready for launching but now the screen offset does not seem to be working. It works fine on unity player but on my device. Any advice please?

    Thanks.
     
  24. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    If it's working inside Unity then the SetCamOffset method is there and is working. This also means that the problem must be on the other side. Open Eclipse, and in the main class search for this method :

    Code (csharp):
    1.  
    2. public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {
    3.     super.onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixelOffset, yPixelOffset);
    4.  
    5.     if (player != null  !isPreview()  !swipeEmul) {
    6.         UnityPlayer.UnitySendMessage("Main Camera", "SetCamOffset", String.valueOf(xOffset));
    7.     }
    8. }
    9.  
    If it's there then check the swipeEmul variable. The best thing for you to do is add some debug flags and see what's happening. Replace your method with this one:

    Code (csharp):
    1.  
    2. public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {
    3.     super.onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixelOffset, yPixelOffset);
    4.  
    5.     Log.v("-->", "Preview Mode = " + isPreview());
    6.     Log.v("-->", "Swipe Emulation = " + swipeEmul);
    7.  
    8.     if (player != null  !isPreview()  !swipeEmul) {
    9.                
    10.         Log.v("-->", "OffSet x = " + String.valueOf(xOffset));
    11.         UnityPlayer.UnitySendMessage("Main Camera", "SetCamOffset", String.valueOf(xOffset));
    12.     }
    13. }
    14.  
    and import this:
    Code (csharp):
    1.  
    2. import android.util.Log;
    3.  
    Now check LogCat and see if the method is called and what values are being passed to Unity. You must see something like this:

    --> Preview Mode = false
    --> Swipe Emulation = false
    --> OffSet x = 0.5
     
    Last edited: May 7, 2013
  25. invisiblesense

    invisiblesense

    Joined:
    Jan 21, 2013
    Posts:
    41

    Thanks for your help as always Shinx!

    Tried what you suggested and I get the following results:
    The Offsets don't show but the other two are as follows

    --> Preview Mode = false
    --> Swipe Emulation = true
    [/QUOTE]
     
  26. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    This means that you are using the Swipe Emulation intended for Touchwiz devices. Are you testing your live wallpaper in a Samsung device with touchwiz?
    Regardless of using swipe emulation or not, Uni2LwP is ready to work in both situations, and without seeing your code and the changes that you made it's very dificult to guess what went wrong.

    Can you send me your java project? Or at least the java files of your main class and GestureLstr class.
     
  27. invisiblesense

    invisiblesense

    Joined:
    Jan 21, 2013
    Posts:
    41

    Hi Shinx,

    I have emailed you both files as a word document. I was unable to send the whole project due to large size.

    Regards
     
  28. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    Hello everyone,

    I have submitted and sent new version of Uni2LwP to everyone that purchase via PayPal. I skipped from version 1.2c to version 1.3b because of a problem that occurred when I was submitting it to Unity Asset Store. Don't worry about that :)

    This version has 2 major changes/fixes:
    1- Uni2LwP engine now supports OpenGl 1.x 2.0;
    2- Fixed the issue that used to happen when you tried to access touch events from Unity after the live wallpaper was set.


    Because Uni2LwP core engine had to be modified to support Gles1.x I suggest that you use this version on new projects only or on your current project if you still haven’t created/exported your live wallpaper for the first time.

    If you need to use Unity touch events on your current project without updating to version 1.3b follow the faq #6 on my site. http://mirageunity.wordpress.com/faq/


    Best regards,
    Shinx
     
  29. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Hi there, firstly thanks for this product ive been using it for a week or so and its been of great use, its good to have something like this available, i was wondering however when 4.1 compatibility would be implemented because of some texture formats it makes available to android (ARGBHalf for example) that im finding my development be hampered through lack of atm. Its a bit esoteric a problem i guess but it would definitely be nice to know a timescale for this
     
  30. Caliber-Mengsk

    Caliber-Mengsk

    Joined:
    Mar 24, 2010
    Posts:
    689
    Sorry I didn't reply to the people mentioning the framerate. All I did was add an extra variable to the menu, and called a custom function of SetFPS which simply has one line:
    Application.targetFrameRate = input;

    That's how you set the framerate. It's not 100% exact, but no fps limiter is. (It just looks if delta time is smaller then a certain duration. For example 30 fps is 1/30 or .033333. if the number is less then .03333 (meaning higher frame rate then 30 fps) you take .03333 - delta and delay that long. Not perfect, but pretty much works)

    Lowering the FPS "should" decrease the amount of processing done. At 25fps, I tend to only have 4-6% battery drain extra instead of the 8-10% I was getting at the default limit of 60fps... at least on my phone.
     
  31. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295

    Hi,

    Unfortunately I don't think it's possible. Unity 4.1 and 4.1.2 libraries aren’t prepared to run as live wallpaper services and the Unity Player class crashes before reaching my plugin/engine. This is an issue with Unity’s libraries.

    But this doesn't mean that future releases won't work. There was a similar problem with Unity 3.5.0/3.5.1 libraries that only got fixed in versions 3.5.6 and 3.5.7. We have to wait and see. It depends on them fixing that issue in the libraries.

    Kind regards,
    Shinx
     
    Last edited: May 10, 2013
  32. Varkaf

    Varkaf

    Joined:
    May 10, 2013
    Posts:
    2
    Hi,
    I'm having problems when running the livewallpaper unto AVD.
    I created a demo project in unity and followed the instructions you had in the youtube video.
    In eclipse I've got some errors about android 14 and the java compiler so I've changed the Java compiler from 1.7 to 1.6 and the errors disappeared.
    Also I ran the project on API v17 and the emulator on 4.2. But when I try to open the live wallpaper in the emulator I get "Unfortunately, AppName has stopped" and in eclipse I see some errors starting with "exception Main" .

    The eclipse comes from a blank install of the latest ADT package, so everything was clean.
    How should I configure my eclipse? Or is the problem from somewhere else..
     
  33. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295

    Did you configure the AVD using the settings that I have in my site ?
    http://mirageunity.wordpress.com/2013/05/03/android-emulator-configuration/

    Don't forget to enable the "Use Host GPU" or it won't work.
     
  34. Varkaf

    Varkaf

    Joined:
    May 10, 2013
    Posts:
    2
  35. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749

    Thanks for the reply! And no problem i can get around it i think and i hope its fixed in future but doesnt detract from a great product you have here
     
  36. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    The issue Unity has applying the wallpaper over itself is a big one. People are used to adjusting their settings by going to the wallpaper list, selecting the wallpaper and hitting settings, adjusting them to their liking and then applying the wallpaper.

    Unfortunately when the Unity engine is already running it has major issues destroying itself and recreating.

    Does anyone know a way we can address this?
     
  37. feracon

    feracon

    Joined:
    Mar 4, 2013
    Posts:
    84
    This issue will never happen when the wallpaper is pushed from Eclipse. What's different about the way the wallpaper is destroyed then than when it's destroyed by the reapplication process?
     
  38. invisiblesense

    invisiblesense

    Joined:
    Jan 21, 2013
    Posts:
    41
  39. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    I'm glad I could help :)


    Regarding one other issue that just came to my attention... Everyone DON'T install the latest revision(22) of Android. Unity and Eclipse stops working (at least for me). Unity doesn't even let you compile/build staging area of your Android Apps.
     
  40. Detocroix

    Detocroix

    Joined:
    Jul 2, 2010
    Posts:
    75
    Sadly Eclipse don't give me an option to use older Android SDK and instead forces me to update. But Unity does still build. I'm using 3.5.7 version.

    I can't seem to solve this kind of issue though: "R cannot be resolved to a variable" in LiveWallpapersSettings.java (myprojectnameSettings.java) line 21 points to addPreferencesFromResource(R.xml.wallpaper_settings);

    Any thoughts on solution?
     
  41. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    I had that exact problem ...
    This is what I had to do to fix it:

    Inside Eclipse I had to remove every software with revision 22.

    $pic1.png

    After that, install revision 21 from this zip file: https://dl.google.com/android/ADT-21.1.0.zip

    After install, restart eclipse and if it shows you any message then you have the wrong Android SDK.

    In my case, I had to DELETE my entire folder of android SDK and then install it again from this : http://dl.google.com/android/android-sdk_r21.1-windows.zip

    Run SDK Manager.exe, installed Android 4.0 and 4.2 WITHOUT updating the Android SDK Tools (VERY CAREFUL here because it’s automatically selected to install)

    After that, Unity and the live wallpapers started working again :)
     
  42. Detocroix

    Detocroix

    Joined:
    Jul 2, 2010
    Posts:
    75
    It is working now. Thanks for the help and awesome asset! :)
     
  43. resheez

    resheez

    Joined:
    Mar 22, 2013
    Posts:
    66
  44. piotrpo

    piotrpo

    Joined:
    Dec 19, 2012
    Posts:
    8
    Works it with 4.1 or is there any chance to make this plugin compatible with latest release?
     
  45. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    Unfortunately I don't think it's possible. Unity 4.1 and 4.1.2 libraries aren’t prepared to run as live wallpaper services and the Unity Player class crashes before reaching my plugin/engine. This is an issue with Unity’s libraries.

    But this doesn't mean that future releases won't work. There was a similar problem with Unity 3.5.0/3.5.1 libraries that only got fixed in versions 3.5.6 and 3.5.7.
    We have to wait for Unity 4.2 and see. It depends on them fixing that issue in the libraries.
     
  46. piotrpo

    piotrpo

    Joined:
    Dec 19, 2012
    Posts:
    8
    I think I see it are you writing about unityPlayer.init() line and NPE thrown?
     
  47. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    It crashes when we instantiate the UnityPlayer class. So it's happens even before the player init.
     
  48. PixelShroom

    PixelShroom

    Joined:
    Nov 1, 2012
    Posts:
    17
    Hi just popped on by to say thanks! it works great and it does it well... thanks again!

    Quick suggestion, is it possible to add a feature to quickly and easily add preference settings? Thanks to your tutorial, it's fairly easy to do it but we have to edit the code in 5 different places... is it possible to edit it all in one place?
     
    Last edited: May 24, 2013
  49. PixelShroom

    PixelShroom

    Joined:
    Nov 1, 2012
    Posts:
    17
    I get this issue when I try to play it on my emulator

    I think i get this problem as well when I put this on my phone
     
  50. shinx

    shinx

    Joined:
    Feb 28, 2013
    Posts:
    295
    Does it crash? or is just the message ?


    Regarding your suggestion to quickly and easily add preference settings. If it's just to automatically add the link to Google Play Store, then it's quite easy and I could add that option in Uni2LwP.
     
    Last edited: May 25, 2013
Thread Status:
Not open for further replies.