Math.Round

Hi , I am just starting, using one of tutorials, and I can’t use Mathf.Round - (both “Mathf” and “Round” do not change color indicating acknowledge of function)

When I add “using System;” I can use Math. not Mathf. but Round do not work anyway.

Should I update some library and how, or what?

Did you also include using UnityEngine;?

I am using Microsoft Visual studio, but this should not make difference

using System.Collections;
using System.Collections.Generic;
using UnityEngine

Try running your Visual Studio installer, clicking the “Modify” button on your installation, and then scroll down to see if the Unity Engine workload is checked. If not, check it and update your installation.

It doesn’t make sense that Math.Round doesn’t work when Math is in your library. I don’t know why it isn’t reading Mathf. Maybe reinstall Visual Studio. I had to do it once when I upgraded.

I have Visual Studia Tools For Unity 3.1.0.0

ArgumentException: Value does not fall within the expected range.
SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.LanguageOf (SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit unit)
SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits (System.String method)
SyntaxTree.VisualStudio.Unity.Bridge.CompilationUnit.CompilationUnits ()
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder…ctor ()
SyntaxTree.VisualStudio.Unity.Bridge.ProjectSystem.UnitySolutionBuilder.CreateSolutionFromAssetDatabase ()
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProject ()
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnPreGeneratingCSProjectFiles ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[ ] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.AssetPostprocessingInternal.OnPreGeneratingCSProjectFiles () (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:204)
UnityEditor.VisualStudioIntegration.SolutionSynchronizer.Sync () (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:207)
UnityEditor.SyncVS.SyncIfFirstFileOpenSinceDomainLoad () (at C:/buildslave/unity/build/Editor/Mono/SyncProject.cs:199)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

and

Assets/Scripts/UpgreadeManager.cs(31,26): error CS1501: No overload for method Round' takes 2’ arguments

Maybe, you’d better posting your script here so that someone can take a look at it. :slight_smile:

I am lerning from

check 23:21, and my Mathf is black and unity shows problems shown in previous post.

Please, check if you have two arguments when you call Mathf.Round. (Maybe you accidentally put coma instead of a decimal point?)

I instaled updated Unity and Mathf still black, but Yelow alert is like in video, but still have this long red one in post up.

System.Math takes 2 parameters so you can specify the number of decimal points. UnityEngine.Mathf only takes 1 parameter, and rounds to the nearest whole number. You’ve probably solved this by now, but it sounds like you were trying to use the Unity version like the System version.

lol wut?

I think you need to understand that the Math library of functions found in System IS NOT the same as the one in UnityEngine. The Math library found in System has no Mathf static class - in other words there is no Mathf.Round, only Math.Round