Unity 3D First Person Controller Script Reference - unity3d

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()

Related

Why shaders doesn't includes to build?

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.

unity3d: how to use OpenFolderPanel

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.

Unity: On scene added/changed event

Currently I'm writing a script that automatically writes a file with all the scene names as variables. I would like to catch a certain event (if it exists) so that I could know when any scene was added or changed it's name. Currently I have to manually press a button whenever I add a scene or rename one. But since I'm not going to be the only one on my team using this, I'd like to automate this.
Some kind of update cycle would work too, I could then check if the current build list matches my list and if not, update it.
I've tried OnHierarchyChange / OnProjectChange, but those only seem to work on certain assets. Any idea to catch this event?
For future readers:
For Unity 5.3 and below use function OnLevelWasLoaded
http://docs.unity3d.com/530/Documentation/ScriptReference/MonoBehaviour.OnLevelWasLoaded.html
Unity 5.4 + use event: SceneManager.sceneLoaded
http://docs.unity3d.com/540/Documentation/ScriptReference/SceneManagement.SceneManager-sceneLoaded.html

Dragging and dropping something onto an xna window?

I have an XNA4 wndow set up and was wondering if I could get it to accept drag+drop actions, what I envision is someone grabs a jpeg and drags it into the window, upon release of the mouse an event is fired off with a string pointing to the jpeg.
Is this doable and if so how?
First, here is a link to a tutorial on doing this with a windows form:
http://support.microsoft.com/kb/307966
and here is a link to a post about doing just this (answer is past a few posts saying that it's impossible):
http://forums.create.msdn.com/forums/p/4020/20419.aspx
finally here is some code for ease of access (you need a reference to the System.Windows.Forms namespace):
protected override void Initialize()
{
Form gameForm = (Form)Form.FromHandle(Window.Handle);
gameForm.AllowDrop = true;
gameForm.DragEnter += new DragEventHandler(gameForm_DragEnter);
gameForm.DragDrop += new DragEventHandler(gameForm_DragDrop);
}
Also, it seems it's possible to run a game inside a Form control as of XNA 2
While I recognise that this is many years too late here is a direct link to a working demo.
The SLN might not want to autoload but you can just drop it into VS2013 and it will update it. I was getting a "licencing" popup when I tried to just run the SLN.
Hope this helps anyone who might still be working on this.
http://geekswithblogs.net/mikebmcl/archive/2011/03/27/drag-and-drop-in-a-windows-xna-game.aspx

How to make a repeatedly scrolling background cocos2d (iPhone)?

I'm extremely new to cocos2D development and I have hit a problem with my background. I want it to repeat scrolling every 2000px so I have looked around and found this (in this tutorial):
[_backgroundNode incrementOffset:ccp(2000,0) forChild:background];
I have set this up in my program however it doesn't recognise the method 'incrementOffset'. Is there something I'm doing wrong? I have imported "CCParallaxNode.h", however it says I need to import "CCParallaxNode-Extras.h" which doesn't exist?!
To quote the tutorial:
I’ve created a category on CCParallaxNode that you can use to solve
this problem, which you can find in the resources for this project in
the Classes folder. Drag CCParallaxNode-Extras.h and
CCParallaxNode-Extras.m into your project, make sure “Copy items into
destination group’s folder” is checked, and click Finish.