I'm using Unity 2020.1.1f1, when I try to add a Component to a GameObject, the component that I search for does not show up for me to add it? The component I have is located in a sub folder of Assets. Should I have imported it elsewhere? I have also restarted Unity to see if it would refresh.
Short answer: It should derives from MonoBehaviour
Looks like there is a thread on this already, I'll close this with the link: Can't add script component because the script class cannot be found?
Related
I am new in Unity and there is something looks weird to me. I created a UnlitTextureYUV.shader file then I use it in my script like this
...
meshRenderer.material = new Material(Shader.Find("UnlitTextureYUV"));
...
Then in editor I click on run button and I see that everything is working properly, ok. Then I click File->Build&Run and I get an error ArgumentNullException that means shader not found.
I tried to find out what is going on and found such answer on Unity community
https://answers.unity.com/questions/1147277/textures-from-local-works-in-editor-missing-in-bui.html
As far as I understand in order to use shaders in build dynamically I need to create dummy material add texture to it and even create dummy object (disabled) and add this material to this object. In this order my shader will be included in build and I will be able to find it dynamically in code by invoke this method Shader.Find("UnlitTextureYUV").
Question is - is there more straight way to include shader in build? Why I need to create dummy objects in order to include this file in build? Or I miss something?
You have to add all your shaders to Unity's 'Always included shaders' list in the
graphic settings.
The FPS Controller Script can be found in Unity Standard Assets folder under Characters/FirstPersonCharacters. I added it to an object called Player. And when I want to pause the game (I've done a pause menu UI), I don't like that it still follows the mouse on the screen, so I want to freeze that rotation. Since I use the free rigidbody version, the RigidbodyConstrains does not work. I need to get a reference to that script to write .enabled = false; But it does not work, the Unity does not recognize it. I wrote:
GameObject.FindGameObjectWithTag("Player").GetComponent<FirstPersonController>().enabled = false;
But it does not work, even if I import UnityStandardAssets(I mean in the script: using UnityStandardAssets;)
I've tried a lot of other solutions, but I can't find the right one! Could you please help me? Thanks in advance!
vs2019error_image
inspector view
i have tested in my visualstudio 2017 i have to add that line:
using UnityStandardAssets.Characters.FirstPerson;
so i have taken the script directly from folder standard Asset
if you see into the script you have this line:
namespace UnityStandardAssets.Characters.FirstPerson
you have to precise the path where to find the class
this line is proposed by VisualStudio 2017, dunno why not by visual studio 2019
For anyone else in the future coming across this, the current firstpersoncontroller script only requires that you add
using StarterAssets;
and then you can use GetComponent()
I'm new to unity. I want to try this tutorial but I failed.
I created a GameObject - UI - Button, and tried to add script to Canvas. But I got this error. Any help would be appreciated.
OpenFolderPanel is an Editor script which lets people to make some customized function for Unity Efitor.
If you want to click button to show file dialog in your game, you can try StandaloneFileBrowser
Alright, I know your mistake. When you create a c# script, do as follows (if you want to attach it to a gameobject).
1) Select the gameobject in the heirarchy.
2) Click add component in the inspector window.
3) Type in the name of your new script, and Unity will generate a basic script derived from MonoBehaviour automatically.
BTW, game objects have monobehaviour derived scripts on them (in singleplayer). The script you are using is derived from EditorWindow, not MonoBehaviour. Personally, I have not used a custom editor, but I think the script you are using should work automatically without having to attach it to a gameobject.
Hi i'm downloading a file in to unity but i need to move the file in to a folder. How can i do this in C#?
Do you mean how to put the game object as a child of another? (That's what it looks like from your screenshot)
If so, you can accomplish that by setting your game-object's transform's parent to the transform of the "folder" you want to put it into.
Something like:
teapot.transform.SetParent(NEWTest.transform);
http://docs.unity3d.com/ScriptReference/Transform.SetParent.html has more information.
I have a custom plugin that adds a link with a class attached. When I view this using the Source button it shows the class and looks as it should. However, when I go back to WYSYWIG view and then view the source again the class has been stripped out.
Any idea how to stop this happening?
Thanks in advance for your help.
Check this blog post.
In CKEditor 4.1 RC we've introduced ACF - Advanced Content Filter. You need to integrate your plugin with it, because otherwise special content created by it is stripped.
For CKEditor4 and for simple config.js modification, disabling the "default filters": see this new question/answer.
(copy)
At config.js you can add something like,
CKEDITOR.config.allowedContent=true;
see "Advanced Content Filter" (ACF) and how to enable/disable it.