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 eshonbel · Dec 07, 2014 at 01:44 PM · guibuttonrectcs1502cs1503

Expression denotes a 'type', where a 'variable', 'value' or 'method group' was expected, and 2 other errors.

I get these errors: Expression denotes a 'type', where a 'variable', 'value' or 'method group' was expected loaded method match for 'UnityEngine.GUI.Password Field(UnityEngine.Rect, string, char)' has some invalid arguments Argument #1' cannot convert object' expression to type UnityEngine.Rect

My code was working before, but because I took out the MonoBehaviourGUI and switched it with GUI.ButtonRect, all these errors happened. I switched because it kept flashing up annoying console errors on my phone. Here's the code:

 using UnityEngine;
 using System.Collections;
 using Prime31;
 using Prime31.WinPhoneEssentials;
 
 
 public class Photo : MonoBehaviour
 {
     public GameObject quad;
 
 #if UNITY_WP8
     
 
     void Start()
     {
     }
 
     
     void OnGUI()
     {
         
         
         if(GUI.Button(Rect(10,10,70,70), "Select Enemy" ))
         {
             Sharing.promptForPhoto( true, ( didComplete, photoBytes ) =>
             {
                 Debug.Log( "photo chooser result: " + didComplete );
 
                 if( didComplete )
                 {
                     Debug.Log( "photo chooser successful. image size: " + photoBytes.Length );
                     // we process the image in a coroutine so that it happens on the proper Unity thread
                     StartCoroutine( loadRawPhotoToTexture( photoBytes ) );
                 }
             });
         }
 
         
     }
 
 
     private IEnumerator loadRawPhotoToTexture( byte[] photoBytes )
     {
         yield return null;
 
         var tex = new Texture2D( 0, 0 );
         tex.LoadImage( photoBytes );
         quad.renderer.material.mainTexture = tex;
     }
 
 #endif
 }

Taken from this main code:

 using UnityEngine;
 using System.Collections;
 using Prime31;
 using Prime31.WinPhoneEssentials;
 
 
 public class WinPhoneEssentialsDemoUI : MonoBehaviourGUI
 {
     public GameObject quad;
 
 #if UNITY_WP8
     
 
     void Start()
     {
         Push.channelUriUpdatedEvent += uri =>
         {
             Debug.Log( "Push channel updated with new uri: " + uri );
         };
     }
 
     
     void OnGUI()
     {
         beginColumn();
         
 
         if( GUILayout.Button( "Update Application Live Tile (standard)" ) )
         {
             // first, create the tile data
             var tileData = new StandardTileData();
             tileData.backContent = "I'm on the back";
             tileData.backTitle = "BACK TITLE";
             tileData.title = "Live Tile Title";
             tileData.count = 12;
 
             // now update the tile
             Tiles.updateApplicationTile( tileData );
         }
 
 
         if( GUILayout.Button( "Create Live Tile (Flip)" ) )
         {
             // first, create the tile data
             var tileData = new FlipTileData();
             tileData.backContent = "Back of the Tile";
             tileData.backBackgroundImage = "http://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Breastfeeding-icon-med.svg/202px-Breastfeeding-icon-med.svg.png";
             tileData.backTitle = "Back Title Here";
             tileData.backgroundImage = "http://cdn.memegenerator.net/instances/250x250/38333070.jpg";
             tileData.smallBackgroundImage = "Assets/Tiles/FlipCycleTileSmall.png";
             tileData.title = "Flip Tile Title";
             tileData.wideBackBackgroundImage = "http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-91-03-metablogapi/5775.WideTileAfter_5F00_49305C14.jpg";
             tileData.wideBackContent = "Wide Back Content";
             tileData.wideBackgroundImage = "Assets/Tiles/FlipCycleTileLarge.png";
             tileData.count = 3;
             
             // now update the tile
             Tiles.createOrUpdateSecondaryLiveTile( "flippy-tile", tileData );
         }
 
 
         if( GUILayout.Button( "Create Live Tile (Iconic)" ) )
         {
             // first, create the tile data
             var tileData = new IconicTileData();
             tileData.iconImage = "http://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Breastfeeding-icon-med.svg/202px-Breastfeeding-icon-med.svg.png";
             tileData.backgroundColor = Prime31.WinPhoneEssentials.Color.colorFromARGB( 255, 40, 255, 40 );
             tileData.smallIconImage = "http://cdn.memegenerator.net/instances/250x250/38333070.jpg";
             tileData.wideContent1 = "Wide content 1";
             tileData.wideContent2 = "Wide content 2";
             tileData.wideContent3 = "Wide content 3";
             tileData.title = "Live Tile Title";
             tileData.count = 3;
 
             // now update the tile
             Tiles.createOrUpdateSecondaryLiveTile( "my-tile", tileData );
         }
 
 
         if( GUILayout.Button( "Get Total Active Live Tiles" ) )
         {
             Debug.Log( "total live tiles: " + Tiles.totalActiveLiveTiles() );
         }
 
         
         if( GUILayout.Button( "Delete Live Tile" ) )
         {
             Tiles.deleteSecondaryLiveTile( "my-tile" );
         }
         
         
         if( GUILayout.Button( "Open Push Channel" ) )
         {
             Push.openChannel( "test-push-channel" );
         }
         
         
         if( GUILayout.Button( "Get App Launch Uri" ) )
         {
             Debug.Log( "app launch uri: " + Push.uriUsedToOpenApplication );
         }
         
         endColumn( true );
 
 
         if( GUILayout.Button( "Show SMS Composer" ) )
         {
             Sharing.showSMSComposer( "5558675309", "Howdy. Let's dine tonight" );
         }
         
         
         if( GUILayout.Button( "Show Link Share UI" ) )
         {
             Sharing.shareLink( "http://prime31.com", "prime[31] web page", "good stuff!" );
         }
         
         
         if( GUILayout.Button( "Show Email Composer" ) )
         {
             Sharing.showEmailComposer( "do it up tonight! " + Application.platform, "We gotta rock some multiplayer", null, null, null );
         }
         
         
         if( GUILayout.Button( "Prompt for Photo" ) )
         {
             Sharing.promptForPhoto( true, ( didComplete, photoBytes ) =>
             {
                 Debug.Log( "photo chooser result: " + didComplete );
 
                 if( didComplete )
                 {
                     Debug.Log( "photo chooser successful. image size: " + photoBytes.Length );
                     // we process the image in a coroutine so that it happens on the proper Unity thread
                     StartCoroutine( loadRawPhotoToTexture( photoBytes ) );
                 }
             });
         }
 
 
         if( GUILayout.Button( "Show Share Status UI" ) )
         {
             Sharing.showShareStatusUI( "Going to the beach!" );
         }
         
         
         if( GUILayout.Button( "Show Marketplace Review" ) )
         {
             Sharing.showMarketplaceReviewPage();
         }
         
         
         if( GUILayout.Button( "Show Web Page" ) )
         {
             Sharing.showWebBrowser( "http://prime31.com" );
         }
 
         endColumn();
     }
 
 
     private IEnumerator loadRawPhotoToTexture( byte[] photoBytes )
     {
         yield return null;
 
         var tex = new Texture2D( 0, 0 );
         tex.LoadImage( photoBytes );
         quad.renderer.material.mainTexture = tex;
     }
 
 #endif
 }
 


Comment
Add comment · Show 5
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 Bunny83 · Dec 07, 2014 at 01:57 PM 0
Share

-1 for not giving the line number of the error.

avatar image eshonbel · Dec 07, 2014 at 02:21 PM 0
Share

Pretty obvious, it's a small script and you could have just asked.

avatar image eshonbel · Dec 07, 2014 at 02:35 PM 0
Share

Thanks guys, the script has no errors but there is no GUI button?

avatar image Bunny83 · Dec 07, 2014 at 02:48 PM 0
Share

@eshonbel:
Well, you have your code in a conditional #if UNITY_WP8 so are you sure that your current selected target is actually Windows Phone 8 and that this script is attached to an active gameobject and the script is enabled?

avatar image eshonbel · Dec 07, 2014 at 02:57 PM 0
Share

Never $$anonymous$$d, works now.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by .Talon · Dec 07, 2014 at 01:53 PM

Rect(...) is missing a "new" keyword

Comment
Add comment · Share
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
1

Answer by Bunny83 · Dec 07, 2014 at 01:58 PM

In line 23 you forgot the "new" keyword:

  if(GUI.Button(new Rect(10,10,70,70), "Select Enemy" ))
Comment
Add comment · Show 2 · Share
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 eshonbel · Dec 07, 2014 at 02:20 PM 0
Share

Thank you both. I was too used to JavaScript not using 'new'!

avatar image eshonbel · Dec 07, 2014 at 02:29 PM 0
Share

The script works, but there is no GUI Button...

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

27 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

Related Questions

Rect to RectTransform on overlay Canvas? 1 Answer

Touch screen coordinates is not same Rect class coordinates? 1 Answer

Whats wrong with my script? GUI C# 2 Answers

error with GUI in c sharp 2 Answers

Gui label errors 5 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