About 12,100 results
Open links in new tab
  1. c# - In Unity, how can I pass values from one script to another ...

    Dec 15, 2012 · seems like it works well in Awake too. Both scripts are added to the same GameObject. public class FirstScript : MonoBehaviour { protected internal GameObject myobject; private void Awake() { myobject = (GameObject)Instantiate(Resources.Load("nameofprefab")); myobject.transform.parent = gameObject.transform; ...

  2. c# - Unity Scripts edited in Visual studio don't provide …

    Mar 4, 2017 · When I want to edit C# Unity scripts, they open in Visual Studio. It is supposed to provide auto complete for all Unity related code, but it doesn't work. Here you can see the missing functionality: As seen, the transform object does not open the autocomplete menu. Unity version: 5.5.2f1 Visual studio 2015 Visual Studio Tools for Unity is installed

  3. unity game engine - Accessing a variable from another script C

    How to use variable from others scripts?-1. How to edit variables in another game object.(Unity C#) 1.

  4. c# - What is the most optimal way of communication between …

    Sep 17, 2018 · Check out this really good article on communicating through Unity's scriptable objects. The removes the need for scripts to have references to each other, facilitating much more modular code. Within that link I shared, I really recommend the links there about Richard Fine and Ryan Hipple's presentations too.

  5. Accessing a script from another script at runtime in Unity C#

    Its worth noting that newly instantiated scripts' Awake() method will be called before Instantiate() returns, while its Start() will be called at the start of following frame, this is a major difference between the two calls, so if your instantiated script needs the refectences in Awake() you should either refactor (move stuff to Start()) or ...

  6. c# - How can I use inheritance in Unity effectively? - Stack Overflow

    Apr 28, 2022 · Then you either add the Enemy and Player scripts to a GameObject in the editor or you can do it programmatically by getting a reference to the target GameObject (by setting the reference in editor or by creating a new GameObject in a script) and then you call targetGameObject.AddComponent<YourComponentToAdd>();.

  7. c# - How to access a variable from another script in another …

    Jul 24, 2015 · For example, static class, regular C# class that is not a MonoBehaviour, etc. However, your code does imply that BombDrop needs to be in the scene because of the Update code that creates Bombs. Also I just realized you can write your code so much simpler.

  8. c# - How to fix issue where a Unity script is missing from Visual ...

    Jun 3, 2022 · Delete all *.csproj and .sln files from your Unity project folder (the one containing Assets, Packages etc) In Unity, choose Edit > Preferences > External Tools; Click Regenerate project files; In the Unity Project window, double-click one of your scripts. Unity automatically regenerates the solution file along with all project files

  9. unity game engine - List of scripts - Stack Overflow

    Dec 12, 2016 · Scripts in Unity extend MonoBehaviour, so you can do the following. public List<MonoBehaviour> Scripts; then you can loop through like you said. foreach(var script in Scripts) { script.enabled = true; }

  10. c# - How To Play Animation Through Script? - Unity - Stack Overflow

    Jun 2, 2020 · I am making a game and I made an animation for the win screen. According to all the tutorials I've watched, the animation is played when you activate the GameObject. However, it plays at the Beginn...