Quantcast
Channel: Questions in topic: "namespace"
Viewing all 398 articles
Browse latest View live

namespaces and script names

$
0
0
I am working on a large project with loads of games under one repo and unity project. These are considered mini games in some respects. How can I work in this same repository, a different branch and against the branch have some setting that stops the names of scripts from other unwanted games coming up? I dont want to stop the scripts from working; Say im working on an fps mini game and a spacei nvaders mini game. Both will have their own gun mechanics, how do i make it so, i can use the script name gun.cs for both mini-games, and only show the one i want within the inspector add component field ? I already use namespaces.

[Serialize Field] Not working, and another issue

$
0
0
Okay so I have this code that's setting up player movement https://hastebin.com/joyohonoqa.cs My issue lies on the unity side, it says "PlayerMovement.animator" is never assigned to, and will always have default value null, I get the same error but for "PlayerMovement.speed" My other issue lies within this code, in which I am trying to ensure my party doesn't get destroyed upon scene change: https://hastebin.com/maqequgore.cpp the issue states that the "scene" and "loadscenemode" aren't defined as a namespace. I'm still really new to coding so thanks for all your help.

The Issue with 'Func'

$
0
0
I'm having problems with addons defining their own version of 'Func' so that they can use the syntax from later versions of .NET. The problem is that they don't define **func** in their own namespaces and instead define them in the application namespace, which means they inevitably conflict. The package manager itself does this, so for example I can't use several .NET WebSocket classes with Unity without having to erase the package manager from the package cache *every single time I start Unity*, which gets very old. Is it possible for Unity projects to override Func in their **own namespace** and not do so in the package namespace, which should prevent this problem from occurring? Is there any trivial workaround anyone has discovered to resolve this?

Make visual Studio Ignore some folders for namespace refactoring

$
0
0
Hi, I hope this is the right place for this Question, sorry if not. I made a project and wanted to do propper namespaces as I was often told to make Namespaces based on folderstructure. So I wanted to refactor all my scripts to do exactly that, but make it automaticaly in visual studio 2019. The catch is, that I can't seem to bring it to ignore the asset and Script folders wich are over every script folder I made. VS wants to include these folders in the namespace while I want the specific folders Assets and then Scripts to be excluded from that. basically like that: my Imagination: myRootNamespace.Core.Player visual studio: myRootNamespace.Assets.Scripts.Core... is it possible to tell visual studio to ignore these two folders and start only in the directory after that, like how I imagine it? Edit: Markdown

Which is the namespace of the Joystick pack?,Which is the nameSpace of Joystick pack?

$
0
0
I need this namespace of this pack for associate the joystick to player script, the namespace is the name that you put after "using", like: using UnityEngine; HELP ME, PLEASE!!!,I want to know which is the nameSpace of JoystickPack https://assetstore.unity.com/packages/tools/input-management/joystick-pack-107631 I need the nameSpace to associate the joystick to the player, HELP ME PLEASE!!!

How to reference a script within another script?

$
0
0
Whenever I try to reference a script in my Enemy's AI script by referencing the namespace of the A*PathfindingPackage's Destination Setter Script, but when I try to reference it using "public Pathfinding (The Namespace is Pathfinding) TargetSetter;" it says it's using the namespace as a type & I know the namespace does have some variables attached to it, so I can't change it... is there anyway I can refrence it as just a regular script? My Custom Enemy AI Script using System.Collections; using System.Collections.Generic; using UnityEngine; public class AI : MonoBehaviour { // Distance Variables public GameObject Player; public GameObject Enemy; public float Distance; // Enemy Stats public float Health; public float Attack; public float GoldReward; public float ExpReward; // Speed Float is in AI Path Script public Pathfinding TargetSetter; // Goes when Game Opened void Awake() { } // As Soon as Scene Opened void Start() { } // Updates Every Frame void Update() { Distance = Vector3.Distance(Player.transform.position, Enemy.transform.position); if (Distance <= 10); { Aggro(); } } // Allows Pathfinding & Attacking void Aggro() { // Pathfinder TargetSetter.enabled = true; // Flee Activation if (Health <= 10); { Flee(); } // Peace after Certain Distance if (Distance > 10); { TargetSetter.enabled = false; } } void Flee() { } } Pathfinding Package Script using UnityEngine; using System.Collections; namespace Pathfinding{ /// /// Sets the destination of an AI to the position of a specified object. /// This component should be attached to a GameObject together with a movement script such as AIPath, RichAI or AILerp. /// This component will then make the AI move towards the set on this component. /// /// See: /// /// [Open online documentation to see images] /// [UniqueComponent(tag = "ai.destination")] [HelpURL("http://arongranberg.com/astar/docs/class_pathfinding_1_1_a_i_destination_setter.php")] public class AIDestinationSetter : VersionedMonoBehaviour { /// The object that the AI should move to public Transform target; IAstarAI ai; void OnEnable () { ai = GetComponent(); // Update the destination right before searching for a path as well. // This is enough in theory, but this script will also update the destination every // frame as the destination is used for debugging and may be used for other things by other // scripts as well. So it makes sense that it is up to date every frame. if (ai != null) ai.onSearchPath += Update; } void OnDisable () { if (ai != null) ai.onSearchPath -= Update; } /// Updates the AI's destination every frame void Update () { if (target != null && ai != null) ai.destination = target.position; } } }

Namespace not found (again, sorry)

$
0
0
Ok, I have my games folder structure set out as follows: Assets/Scripts/Subfolder/script.cs Assets/AddinCompany/AddinName/Scripts/addinScript.cs Assets/AddinCompany/AddinName/Scripts/notTheAddinScript.cs The addinScript.cs is in the AddinCompany.AddinName namespace. I can use this namespace fine in notTheAddinScript.cs with a using declaration. However, if I try to use the same using declaration in script.cs, I get a type or namespace 'AddinCompany' could not be found. . How can I get this working please? (Preferably without moving the scripts location.)

How I can fix This? HELP ME!

$
0
0
Library\PackageCache\com.unity.package-manager-ui@2.0.7\Editor\AssemblyInfo.cs(7,12): error CS0246: The type or namespace name 'UxmlNamespacePrefixAttribute' could not be found (are you missing a using directive or an assembly reference?)

Scripts can't see other scripts in certain folders ("The name does not exist in the current context")

$
0
0
Only recently this has started to become a big problem. Used to be an error that I could solve pretty easily with logic, but in the last couple versions, it happens on half of my projects and the only way I've been able to get around it is by scrapping the project completely and creating a new one from scratch. Not really an elegant solution, and frustrating as all hell. I realize it has something to do with scripts residing in certain folders, but beyond that, there doesn't seem to be any rhyme or reason to the connections there. Simply moving the folders or scripts around produces dependency errors that cause more problems than they solve. I've tried changing execution orders, which has no effect at all. I've tried looking into Assembly Definitions, and that also seems to have no affect on the problem (granted, I'm certain I don't understand them correctly; I haven't been able to find any documentation on them that explains clearly or simply enough how to use them). To be specific, I'm working with Wwise, and struggling to get scripts to recognize `AkSoundEngine`. The Wwise folder is in Assets, but the bulk of the rest of the project is in a separate folder in Assets. This seems to be the root of the issue. Again, I can't simply move the Wwise folder in to the other folder (nor can I move the contents from the other folder up one level into the root of the Assets folder). This causes a whole list of errors from Wwise script dependencies. I can (seemingly) solve these errors by using an Assembly Definition Reference, but that somehow brings back the `AkSoundEngine does not exist` error.

Using two scripts for one GameObject that are in the same namespace not working?!,Using 2 Scrips in 1 GameObject with the same namespace not working?

$
0
0
Hello guys! So I am working on a project for college with some fellow students and to be able to differentiate all the written scripts we started using Namespaces today. And since the moment I put all my scripts into the same namespace one of my scripts can't get loaded into Unity anymore. Here are a few screenshots of inspector view and code: https://imgur.com/a/dbTl8sp It only happens to one script, as soon as I change the namespace to a comment in that script everything is working as it should, when I remove the comments the script doesn't get recognized any longer. We are using Unity 2019.3.6f1. Does anyone know how to fix it? I know I could just remove the namespaces but since it is a project for college and we also have to write a code documentation I'd like all my code to be in the same namespace. Thank you for your answers!

Can't reference other namespaces from within TextMeshPro (TMPro) namespace.

$
0
0
I'm trying to add something to a textmeshpro class, but for some reason it can't find any references I try to make within the textmeshpro namespace. Why is this. From research it seems to maybe be something weird with dlls and the scripts being in the library folder or something? Any solution to this? Thank you.

namespace could not be found

$
0
0
So I have been having massive issues with coding today. I don't really know what happened but my camera controller wasn't working so I deleted the script and rewrote it exactly the same. When I saved it I got an error that said "Assets\CameraController.cs(5,33): error CS0246: The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?)" So I saved my unity project and closed it when I opened it back up I got a second error in addition to the first one that said Assets\CameraController.cs(7,12): error CS0246: The type or namespace name 'Transform' could not be found (are you missing a using directive or an assembly reference?) I don't know what to do I am so confused someone please help.

using Valve.VR isn't importing namespace

$
0
0
This is happening to me with the proper IDE set using Unity 2019.3 with Open VR Desktop 2.0.5 and Steam VR2.2.0. I have regenerated project files for the .csproj from all sources. I have deleted .csproj and .sln as well as .vs files and allowed Unity to regenerate them. Saved closed rebooted etc but the Valve namespace and all sub namespaces fail giving me a repeating error: " NullReferenceException: Object reference not set to an instance of an object Valve.VR.InteractionSystem.Sample.LockToPoint.FixedUpdate () (at Assets/SteamVR/InteractionSystem/Samples/BuggyBuddy/LockToPoint.cs:54) " The LockToPoint script is being called in another script which gives an error "The type or namespace 'LockToPoint' could not be found..." while the using Valve.VR.InteractionSystem.Sample; says "Using Directive is Unnecessary". Removing .Sample from the using removes the last error but the namespace remains grayed out and the reference to LockToPoint still throws errors? Things like // (SteamVR) Player reference public Valve.VR.InteractionSystem.Player player; public Valve.VR.InteractionSystem.Hand leftHand; public Valve.VR.InteractionSystem.Hand rightHand; Which have worked for months all fail now do to a missing assembly reference with using Valve.VR; present. The only other thing I can think of is resetting the dll reference in Visual Studio Community 2017 but I don't know how to do that? Any idea whats going on or how to fix it? Update. Looked up resting the dll's and it didn't help.

Building error with the asset Hexplanet Pro

$
0
0
>quote Yesterday I purchased the Unity Asset Hexplanet Pro which is working fine in the editor, but whenever I try to build for Android, I get the following errors at PlanetVertexData 13, 6 "The namespace name 'Menu Item' could not be found" & "The namespace name 'Menu Item Attribute' could not be found". Typing #if UNITY_EDITOR at the beginning of the file and #endif at the end didn't do anything. Does anybody have an idea how to fix that?

Unity types gone after Visual Studio update

$
0
0
In the title. I re-installed Visual Studio and now "only" half of all types are gone. Stuff like Unity.Mathematics types are there, but the ultra basic UnityEngine types like Camera or [SerializeField] are not recognized, even though the UnityEngine dll is referenced. Help :(

I cant figure out these errors

$
0
0

first Error Msg:

Assets/Opsive/Shared/Game/Scheduler.cs(12,30): error CS0246: The type or namespace name 'SchedulerBase' could not be found. Are you missing an assembly reference?
__________________________________________________________________________________________________________

first error code:

namespace Opsive.Shared.Game
{
    /// summary
    /// Wrapper for the shared Scheduler component.
    /// summary
    public class Scheduler : SchedulerBase
    {
    }
}
_____________________________________________________________________________________________________________

Second Error Msg:

Assets/Opsive/Shared/Game/ObjectPool.cs(12,31): error CS0246: The type or namespace name `ObjectPoolBase' could not be found. Are you missing an assembly reference?
_________________________________________________________________________________________________________

Second error Code:

namespace Opsive.Shared.Game
{
    /// 
    /// Wrapper for the shared ObjectPool component.
    /// 
    public class ObjectPool : ObjectPoolBase
    {
    }
}
__________________________________________________________________________________________________________ If you need more info comment and let me know what you may need.

Unity version is 2017/4.28f1 64bit

How to solve 5k errors.. for photonNetwork

$
0
0
Hello I am using photonnetwork with unity I have 5k errors.. All errors is like screenshot![alt text][1] [1]: /storage/temp/168470-스크린샷-2020-10-01-오후-75700.png

unity ios editor does not exist in the namespace

$
0
0
I cant get all namespaces from ios. I checked I have add IOS module correctly in my unity hub. I have googled several hours, but I cant fix this problem. Please help me, thanks! My unity version is 2019.4.1f1, and compiler is visual studio

Unity Cannot find Namespace 'UnityEngine.Experimental.Rendering.Universal;

$
0
0
I am getting this error error CS0234: The type or namespace name 'Universal' does not exist in the namespace 'UnityEngine.Experimental.Rendering' (are you missing an assembly reference?) I am using Unity 2018.4.16f1 Please help

How can you list all classes inside a namespace (such as UnityEngine) and every message method that class has?,How to list all classes in UnityEngine and all message methods in a class?

$
0
0
I was able to list all methods from a given class by following this link: https://answers.unity.com/questions/657436/how-to-list-all-the-properties-and-methods-from-th.html Though, I now need to get a list of every class a namespace has (such as every class from UnityEngine), which would be the list on the left: https://docs.unity3d.com/ScriptReference/AccelerationEvent.html (every class in the 'Classes' tab) Furthermore, I want to know the 'Message Methods" found in a class. The methods from the first link seem to only be public and static methods, and even without flags I do not receive the 'Awake', 'Start' and so on methods, found here: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html Is there anything that allows us to receive a list of any of these?,I was able to list all methods from a given class by following this link: https://answers.unity.com/questions/657436/how-to-list-all-the-properties-and-methods-from-th.html Though, I now need to get a list of every class a namespace has (such as every class from UnityEngine), which would be the list on the left: https://docs.unity3d.com/ScriptReference/AccelerationEvent.html (every class in the 'Classes' tab) Furthermore, I want to know the 'Message Methods" found in a class. The methods from the first link seem to only be public and static methods, and even without flags I do not receive the 'Awake', 'Start' and so one methods, found here: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html Is there anything that allows us to receive a list of any of these?
Viewing all 398 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>