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 /
  • Help Room /
avatar image
0
Question by MrPsychoITA · Oct 12, 2015 at 07:12 PM · apisteamcs0118

Ludosity's Steamworks error CS0118

Hi, today i've installed Ludosity's Steamworks on Unity 5.2, but Unity give me an error, the CS0118 And it tell me: Assets/Plugins/Example Code/Stats.cs(47,33): error CS0118: Stats.GameID' is a field' but a type' was expected; Assets/Plugins/Example Code/Stats.cs(100,33): error CS0118: Stats.GameID' is a field' but a type' was expected;

This is the code where Unity give me the error:

 using System;
 using UnityEngine;
 using ManagedSteam;
 using ManagedSteam.Exceptions;
 
 /// <summary>
 /// A simple example script showing how to get and set Stats.
 /// Remember to also add the Steamworks script to a object so it can setup the library.
 /// 
 /// You will have to add the stats in the Steamworks AppAdmin page to be able to successfully read 
 /// and write the stat values.
 /// </summary>
 public class Stats : MonoBehaviour
 {
     public GameObject GameID;
     private void Start()
     {
         if (Steamworks.SteamInterface == null)
         {
             // Startup of the library failed.
             UnityEngine.Debug.LogError("SteamInterface startup failed!");
             return;
         }
 
         IStats stats = Steamworks.SteamInterface.Stats;
 
         // Register to the event that is raised when stats are received.
         stats.UserStatsReceived += UserStatsReceived;
         // Register to the event that is raised when stats are saved to the server.
         stats.UserStatsStored += UserStatsStored;
 
         // Ask the steam client to download stats for the current user.
         stats.RequestCurrentStats();
     }
 
     /// <summary>
     /// Called when stats for a user have been downloaded.
     /// </summary>
     /// <param name="value"></param>
     private void UserStatsReceived(ManagedSteam.CallbackStructures.UserStatsReceived value)
     {
         int GameID;
         // Make sure that the callback is for this game
         Debug.Log("value.GameID: " + value.GameID.ToString() + "; Steamworks.SteamInterface.AppID: " + Steamworks.SteamInterface.AppID.ToString());
         Debug.Log("value.Result: " + value.Result);
     
         if (value.GameID == new GameID(Steamworks.SteamInterface.AppID.AsUInt64))   <====ERROR
         {
             if (value.Result != ManagedSteam.SteamTypes.Result.OK)
             {
                 UnityEngine.Debug.LogError("Failed to download stats.");
                 return;
             }
 
             // The stats have been downloaded successfully
 
             IStats stats = Steamworks.SteamInterface.Stats;
 
             // Read the value of an INT stat named TestStatInt and a FLOAT stat named TestStatFloat.
             int intData;
             float floatData;
             if (!stats.GetStat("TestStatInt", out intData))
             {
                 UnityEngine.Debug.LogWarning("Failed to read TestStatInt");
             }
             if (!stats.GetStat("TestStatFloat", out floatData))
             {
                 UnityEngine.Debug.LogWarning("Failed to read TestStatFloat");
             }
 
             UnityEngine.Debug.Log("TestStatInt = " + intData.ToString());
             UnityEngine.Debug.Log("TestStatFloat = " + floatData.ToString());
 
 
             // Change the stat values and save them
             intData++;
             floatData += 0.5f;
             if (!stats.SetStat("TestStatInt", intData))
             {
                 UnityEngine.Debug.LogWarning("Failed to write TestStatInt");
             }
             if (!stats.SetStat("TestStatFloat", floatData))
             {
                 UnityEngine.Debug.LogWarning("Failed to write TestStatFloat");
             }
 
             // Tell the steam client that we want to upload the new stat values.
             // This will cause the UserStatsStored method to be called once the upload is complete.
             stats.StoreStats();
         }
     }
 
     /// <summary>
     /// Called when stats have been saved to the steam servers.
     /// </summary>
     /// <param name="value"></param>
     private void UserStatsStored(ManagedSteam.CallbackStructures.UserStatsStored value)
     {
         // Make sure that the callback is for this game
         if (value.GameID == new GameID(Steamworks.SteamInterface.AppID.AsUInt64))  <=====ERROR
         {
             if (value.Result == ManagedSteam.SteamTypes.Result.OK)
             {
                 UnityEngine.Debug.Log("Stats saved to the server successfully.");
             }
             else
             {
                 UnityEngine.Debug.LogWarning("Failed to save stats to the server.");
             }
         }
     }
 
 }




Thanks to all!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by bhrbhrbhr · Oct 15, 2015 at 05:44 PM

If you remove the "new GameID()" constructor, and add ".AsUint64" to the end of the first half of the comparison, it seems to work just fine. It should make it so you are comparing two things that end in ".AsUInt64", so you are comparing two 64 bit unsigned integers.

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

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

31 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

Related Questions

How to store/show player choices 1 Answer

Steam Leaderboards in Unity, upload time since level load 0 Answers

[Steamworks.NET] SteamAPI_Init() failed, Windows, Linux + Proton 0 Answers

Using the Steamworks.NET API in unity personal edition. 1 Answer

Unity 2019.4.3 steamvr asset pack - HMD/controllers not being used, defaults to stereo display 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