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

Error CS0234: The type or namespace name `IActiveBuildTargetChanged' does not exist in the namespace `UnityEditor.Build'. Even after moving Editor folder.

$
0
0
Hi, I was searching for this error and I found [this](http://answers.unity3d.com/questions/1114080/the-type-or-namespace-name-unityeditor-could-not-b-2.html ) answer but it is not working. I moved Editor folder from StandardAssets/CrossPlatformInput/Scripts to StandardAssets folder and it is still throwing this error. I tried to put this folder in every single other folder but it is still not working. Should I put ALL scrips in Editor folder? I'm using Unity 5.6.2 on WIndows, and I imported whole CrossPlatformInput package and also couple of other standard packages.

Namespace error from external assets

$
0
0
Hi everyone, english is not my first language so i'll try to explain you the problem as well as i can. I'm working on a project compiled from many people before me so i don't really know what did they do in it. This project contains a lot of assets imported from the asset store and, when i try to build it, every namespace relative to those assets give me the classic error "The type or namespace name `com' could not be found. Are you missing an assembly reference?" Every asset is in the Assets folder so I don't really know what to do to fix those 60 errors.

Is there a way to see namespaces in Editor ? (complete class name)

$
0
0
Hi, Unity doesn't show complete class name, this can be confusing, for instance with the search box in the inspector. (if same class name but different namespace) Is there a solution or good practices?

Compiled managed dll that references Unity APIs from different Unity versions

$
0
0
Let's say there's some API A in Unity 5.6.x that is deprecated in 2017 and there is some other API B in 2017 that does not exist yet in 5.6.x. Is there any way to create a compiled managed dll that uses API A when run in 5.6.x and API B when run in 2017? It doesn't seem to be possible to use conditional compilation since the defines are evaluated when the dll is generated. As a more tangible example, 5.6.x has UnityEngine.VR.VRSettings while 2017.2b has UnityEngine.XR.XRSettings. Can a compiled dll be created that supports both versions if the code depends on these settings?

error CS0118: 'Player' is a 'namespace' but a 'type' was expected

$
0
0
using System.Collections; using System.Collections.Generic; using UnityEngine; using Player ; namespace Player { public class MonoBehaviour { Player pl1 = new Player (); GameObject [] pauseObjects; GameObject [] finishObjects; //player Player; void OnTriggerEnter2D(Collider2D other){ if(other.gameObject.tag == "Player"){ other.gameObject.GetComponent().alive = false; Time.timeScale = 0; } } void Start () { Time.timeScale = 1; pauseObjects = GameObject.FindGameObjectsWithTag("ShowOnPause"); //gets all objects with tag ShowOnPause finishObjects = GameObject.FindGameObjectsWithTag("ShowOnFinish"); //gets all objects with tag ShowOnFinish hidePaused(); hideFinished(); //Checks to make sure MainLevel is the loaded level if(Application.loadedLevelName == "MainLevel") playerController = GameObject.FindGameObjectWithTag("Player").GetComponent(); } void Update () { if(Input.GetKeyDown(KeyCode.P)) { if(Time.timeScale == 1 && player.alive == true) { Time.timeScale = 0; showPaused(); } else if (Time.timeScale == 0 && player.alive == true){ Time.timeScale = 1; hidePaused(); } } } public void Reload(){ Application.LoadLevel(Application.loadedLevel); } public void pauseControl(){ if(Time.timeScale == 1) { Time.timeScale = 0; showPaused(); } else if (Time.timeScale == 0){ Time.timeScale = 1; hidePaused(); } } public void showPaused(){ foreach(GameObject g in pauseObjects){ g.SetActive(true); } } //hides objects with ShowOnPause tag public void hidePaused(){ foreach(GameObject g in pauseObjects){ g.SetActive(false); } } //shows objects with ShowOnFinish tag public void showFinished(){ foreach(GameObject g in finishObjects){ g.SetActive(true); } } //hides objects with ShowOnFinish tag public void hideFinished(){ foreach(GameObject g in finishObjects){ g.SetActive(false); } } //loads inputted level public void LoadLevel(string level){ Application.LoadLevel(level); } } }

Assets/Looper.cs(4,23): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?.

$
0
0
hey everybody i've got this script from someone but it wont work and i can't get it to work it keeps giving me this error IN CONSOLE Assets/Looper.cs(4,23): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?. Error building Player because scripts had compiler errors this notification comes out after I build into a file with exe extension, in Microsoft Visual Studio it successful build and compile but error in build and run to axe. please give me solution and tips to solve this problem. ![alt text][1] using System.Collections; using System.Collections.Generic; using UnityEngine; public class Looper : MonoBehaviour { int number1, number2, number3, number4, number5, countdown; // Use this for initialization void Start () { number1 = 0; number2 = 0; number3 = 0; number4 = 0; number5 = 0; countdown = 3; InvokeRepeating("CountDown", 1, 1); } // Update is called once per frame void Update () { if (countdown == 0) { number1++; } } void FixedUpdate() { if (countdown == 0) { number2++; } } void CountDown(){ countdown--; if (countdown == 0) { InvokeRepeating("Looping1", 1, 1); InvokeRepeating("Looping2", 5, 0.5f); Invoke("NoLooping", 10); CancelInvoke("CountDown"); } } void Looping1() { number3++; } void Looping2() { number4++; } void NoLooping() { number5++; } void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, 400, 200)); if (countdown == 0) { GUILayout.Label("Update Increment:" + number1.ToString()); GUILayout.Label("FixedUpdate Increment" + number2.ToString()); GUILayout.Label("Start At:1 Sec(Interval 1):" + number3.ToString()); GUILayout.Label("Start At:5 Sec(Interval 0.5): " + number4.ToString()); GUILayout.Label("Star At :10 Sec(Looping): " + number5.ToString()); } else { GUILayout.Label("Count Down:" + countdown.ToString()); } GUILayout.EndArea(); } } [1]: /storage/temp/101857-tompel.png

UnityEngine found but MonoBehaviour or Vector3 not found in MonoDevelop

$
0
0
Hi all, I have recently noticed that UnityEngine dependencies were not recognized in MonoDevelop for one of my projects. It works fine for all my other projects, even ones made last year. And UnityEngine itself is not highlighted. It seems to work fine in VS as well. I get the error CS0103 : "MonoBehaviour" doesn't exist in the current context. Yet, Unity is able to compile the code and I get no errors in the console, and the game play mode work fine. The real issue is that without MonoBehaviour auto-complete it is very hard to write code as I keep having to re-write things over and over due to auto-complete to things which are not MonoBehaviour. Any suggestions would be much appreciated. Feel free to comment to ask for particular setting details or info. I don't really know where the problem comes from so I don't know what extra info to provide. Thanks

Namespace not working

$
0
0
I am making a script that should simplify things for other scripts, and to use the functions I decided to use a namespace. The script looks like this: using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Namespace { public class Helper : MonoBehaviour { public Value value1; private Value value2; private Value value3 public void SetValues(value number, value number2) { value2 = number; value3 = number2; } public void Activate() { // some code here StartCoroutine(Cooldown); } public IEnumerator Cooldown() { //some code here } } } I can use the `using Namespace;` and when I want to acces a funtion like `Helper.Activate();` it recognize the `Helper` but the `Activate()` isn't recognized. Can someone help me with this issue?

.NET dll seen as native in Unity3D

$
0
0
I got a NI USB-6001 I/O device but it cant be used in unity3D. The purpose of the hardware here is to connect buttons, joystick, switches etc. to it and then to read it out by using the API and turning the channel values into parameters that can be used in de simulation. Basicly the point is to make a custom controller for unity3D. But i have the following problem with trying to use NI hardware as I/O. ![alt text][1] If the NationalInstruments.DAQmx.dll gets imported into Unity3D it is recognized as a type Native .dll and not a .NET .dll which it should be. Because of this it wont be added to the references what results in the namespace name not existing. Does anyone know if there is a way to resolve this? [1]: /storage/temp/104483-ni-dll.png

Variable type Target Unity

$
0
0
The script (In C#): public class Gun : MonoBehaviour { public GameObject enemy; // Use this for initialization void Start () { } public float damage = 100f; // Update is called once per frame void Update () { if (Input.GetButtonDown("Fire1")) { shoot(); } } void shoot() { RaycastHit hit; if (Physics.Raycast(transform.position,transform.forward, out hit)) { Target targ = GetComponent(); if (enemy != null) { Destroy(enemy); } } } } Okay, so here is the line of code which is not working: Target targ = GetComponent(); in which I am trying to create a variable type target as I saw in this video: https://www.youtube.com/watch?v=THnivyG0Mvo However, when I tried to do this it tells me the type or namespace "Target" could not be found (are you missing a using directive or an assembly reference?) And I already tried looking for errors on this and some people say this error is caused because the script is named "Target" however, that is not the case for me as this script is labelled as Gun. Could somebody please tell me how I could fix this line of code? (Also the entire script isn't the ideal one, I plan to replace the Destroy(gameObject) with something more suitable if I could find the solution to my problem.

Get All Unity Namespaces (string array)

$
0
0
Hi All, I'm making a custom file creator, where you can specify your file name, location, and also the namespaces to include. I've been able to include all generic c# namespaces, as well as any custom ones (GetExecutingAssembly() and GetCallingAssembly(), respectively), but these do not include namespaces such as UnityEngine, UnityEngine.AI, etc. Does anyone know how I can get a list of all of these namespaces?

How do you use namespace functions?

$
0
0
I have a weird problem that no one seems to be talking about. I'm trying to use namespaces for my script mainly to see how it works but no matter how simple the function is it gives me a nullreferenceexception. heres a example namespace namespaceExample { public class TestClass : MonoBehaviour { public void TestFunction(string message) { print(message); } } } class TestClass2 { public string message = "Hello World!"; namespaceExample.TestClass test; void Test() { test.TestFunction(message); } } can someone explain to my why this happens? I'm using unity 2017.2.0f3

MonoDevelop not recognizing "UnityEngine namespace"

$
0
0
For some odd reason MonoDevelop can't recognize this. I've searched around online and on the forums and nothing seems to work. I've tried uninstalling and re-installing, which at first worked, but the next day I'm back in square one. I've tried setting my .NET framework to the correct version I have installed. I've also tried deleting certain files in the Unity Project Directory as directed by many answers I've found online. Any help would be appreciated! Thanks in advance.

Using variables without overflow

$
0
0
I have a 2 scripts test.cs and test2.cs. I want it test2 to access test, and it works, but i don't want to make a new variable every function. Maybe the code will tell more :D Current Code (works): using MrRockis.Test; namespace MrRockis.Test.Actions { public class test2 : MonoBehaviour { public void Test() { promo = new Test(); Debug.Log (promo.statusText.text); } } } But i don't want to type "promo = new Test(); inside every function! This code gives stack overflow error: using MrRockis.Test; namespace MrRockis.Test.Actions { public class test2 : MonoBehaviour { private Test promo = new Test(); //This row gives me the error public void Test() { Debug.Log (promo.statusText.text); } } } How could i do this without putting "promo = new Test();" inside every function?

Best way to communicate between scripts

$
0
0
Hello everyone. I would like to know what is the best way to communicate between scripts without referencing them through the inspector. I've found some very helpful answers but I'm not sure which is best and why. For example, we have a main script where all our info is saved or loaded and some secondary scripts with info. Most secondary scripts will need to use values from our main script pretty commonly and i know for sure `GetComponent` is not the best way to do it, especially if you are going to reference them a lot . I could also create a variable and then drag the game object that holds the main script to it but then i would need to do that for every single secondary script and some scripts may need to be destroyed in runtime or some game objects may change many times which i think is waste of time, which is why I'm interested in being able to make a whole class static and use it's values or perhaps use namespaces? Any help would be appreciated and sorry for the confusing, I'm really confused as well!

Types and namespace not found...

$
0
0
Ok, so I'm new to Unity and C# but I wrote a tiny script which runs without a problem inside Unity. But when I try to export it (build) I get a bunch of errors all telling me types are not found, and it's pretty much all the types I used... So it doesn't find MonoBehaviour, Vector3 or Transform. The script looks like this : * using System.Collections.Generic; using UnityEngine; public class CameraBehaviour : MonoBehaviour { Vector3 myVectorZ; Vector3 myVectorY; Vector3 myVectorX; Transform myTransform; void Awake () { myTransform = GetComponent (); myVectorZ = new Vector3 (myTransform.position.x, myTransform.position.y, myTransform.position.z+2); myVectorY = new Vector3 (myTransform.position.x, myTransform.position.y+2, myTransform.position.z); myVectorX = new Vector3 (myTransform.position.x+2, myTransform.position.y, myTransform.position.z); } // Use this for initialization void Start () { } // Update is called once per frame void FixedUpdate () { if ( Input.GetKey( "space" ) ) { transform.Translate( myVectorZ , Space.Self); Debug.Log ("Fixed :"); Debug.Log (myTransform.position.z); } } void Update () { if ( Input.GetKey( "space" ) ) { transform.Translate( myVectorZ , Space.Self); Debug.Log ("NotFixed :"); Debug.Log (myTransform.position.z); } } } * I'm guessing I didn't think of a simple thing that ruin everything but I didn't find an answer fitting my problem. Sorry if I'm not clear, not english... Thanks in advance for your answers !

Visual Studio 2017 namespace cannot be found on installed package

$
0
0
I've installed the FileHelpers package http://www.filehelpers.net using the package manager console in Visual Studio 2017 and when I start Unity I get the error message "The type or namespace name `FileHelpers' could not be found. Are you missing an assembly reference?". I am using .NET 4.6. Any help would be appreciated.

AsyncGPUReadbackRequest could not found

$
0
0
I am getting errors like "The type or namespace name 'AsyncGPUReadbackRequest' could not be found (are you missing a using directive or an assembly reference?)" "The name 'AsyncGPUReadback' does not exist in the current context" Although I have included using UnityEngine.Experimental.Rendering. Can you please tell me how to resolve this issue? I am using Unity 5.6.4p4.

Recording video from webCam

$
0
0
Hello, I'm trying to use the script from [VideoCapture](https://docs.unity3d.com/ScriptReference/XR.WSA.WebCam.VideoCapture.html), on editor mode doesn't reflect any issue but when it comes to the deployment on PC standalone, it tells me: The type or namespace name `WebCam' does not exist in the namespace `UnityEngine.XR.WSA'. Are you missing an assembly reference? and I know it changed from VR to XR but I'm not missing any name space. using Unity 2017.3 Here is my code: using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine.XR.WSA.WebCam; using UnityEngine.SceneManagement; public class WebCamera : MonoBehaviour { static readonly float MaxRecordingTime = 15.0f; VideoCapture m_VideoCapture = null; float m_stopRecordingTimer = float.MaxValue; // Use this for initialization void Start() { StartVideoCaptureTest(); } void Update() { if (m_VideoCapture == null || !m_VideoCapture.IsRecording) { return; } if (Time.time > m_stopRecordingTimer) { m_VideoCapture.StopRecordingAsync(OnStoppedRecordingVideo); } } void StartVideoCaptureTest() { Resolution cameraResolution = VideoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First(); Debug.Log(cameraResolution); float cameraFramerate = VideoCapture.GetSupportedFrameRatesForResolution(cameraResolution).OrderByDescending((fps) => fps).First(); Debug.Log(cameraFramerate); VideoCapture.CreateAsync(false, delegate (VideoCapture videoCapture) { if (videoCapture != null) { m_VideoCapture = videoCapture; Debug.Log("Created VideoCapture Instance!"); CameraParameters cameraParameters = new CameraParameters(); cameraParameters.hologramOpacity = 0.0f; cameraParameters.frameRate = cameraFramerate; cameraParameters.cameraResolutionWidth = cameraResolution.width; cameraParameters.cameraResolutionHeight = cameraResolution.height; cameraParameters.pixelFormat = CapturePixelFormat.BGRA32; m_VideoCapture.StartVideoModeAsync(cameraParameters, VideoCapture.AudioState.ApplicationAndMicAudio, OnStartedVideoCaptureMode); } else { Debug.LogError("Failed to create VideoCapture Instance!"); } }); } void OnStartedVideoCaptureMode(VideoCapture.VideoCaptureResult result) { Debug.Log("Started Video Capture Mode!"); string timeStamp = Time.time.ToString().Replace(".", "").Replace(":", ""); string filename = string.Format("TestVideo_{0}.mp4", timeStamp); string filepath = System.IO.Path.Combine(Application.persistentDataPath, filename); filepath = filepath.Replace("/", @"\"); m_VideoCapture.StartRecordingAsync(filepath, OnStartedRecordingVideo); } void OnStoppedVideoCaptureMode(VideoCapture.VideoCaptureResult result) { Debug.Log("Stopped Video Capture Mode!"); } void OnStartedRecordingVideo(VideoCapture.VideoCaptureResult result) { Debug.Log("Started Recording Video!"); m_stopRecordingTimer = Time.time + MaxRecordingTime; } void OnStoppedRecordingVideo(VideoCapture.VideoCaptureResult result) { Debug.Log("Stopped Recording Video!"); m_VideoCapture.StopVideoModeAsync(OnStoppedVideoCaptureMode); } public void TheEnd() { SceneManager.LoadScene("End"); } } I been having this issue for over 3 days and I search for any issue related without any luck. Thanks for the help. Have a good one!!!!

Any reason not to use namespace for scripts for asset store

$
0
0
I noticed that some asset store packages name their assets like this company or project name _ then a class name (like vp_Something). This might be to find the classes from a specific asset faster and to know which classes belong to which asset while typing. But this can be also done with namespaces. Is there any reason to do this instead of CompanyName.ProjectName.ClassName. Also is there any document that defines the default way you should name classes and namespaces for unity asset store?
Viewing all 398 articles
Browse latest View live


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