• Unity3D - Discussion
    5,004 replies, posted
I am trying to make a map selection and I am stuck at a point. Right now I am displaying all maps based on the amount of levels I have and I have a button on each map which will hold the map name. The problem is that the OnClick function on the button. How can I give it a custom value rather than having to write it in. Here are 2 images showing what I am trying to do and the code. Basically what I want to know how I can add the value using code and getting the parent name. [img]http://imagizer.imageshack.com/img661/9470/mv48xy.png[/img] [img]http://imagizer.imageshack.com/img913/2650/DIehH9.png[/img] [code] public void SelectedMapName(string name) { startServer.mapName = name; } [/code]
[QUOTE=BoowmanTech;46627431]I am trying to make a map selection and I am stuck at a point. Right now I am displaying all maps based on the amount of levels I have and I have a button on each map which will hold the map name. The problem is that the OnClick function on the button. How can I give it a custom value rather than having to write it in. Here are 2 images showing what I am trying to do and the code. Basically what I want to know how I can add the value using code and getting the parent name. [IMG]http://imagizer.imageshack.com/img661/9470/mv48xy.png[/IMG] [IMG]http://imagizer.imageshack.com/img913/2650/DIehH9.png[/IMG] [code] public void SelectedMapName(string name) { startServer.mapName = name; } [/code][/QUOTE] This is the way I do custom [I]onClick[/I] methods; [code] // Get the BUTTON component of the object _gMultiPlayer = GameObject.Find("btnMultiplayer").GetComponent<Button>(); // Assign a custom method as the listener _gMultiPlayer.onClick.AddListener(MultiplayerButton_OnClick); [/code] No idea if this is the best way, but it works for me. For yours though, since I assume they're created dynamically, you could just make a new script, and attach it to the button element of the prefab, inside the script would be something like this; [code] private Button _btnMapButton; private void Start() { _btnMapButton = gameObject.GetComponent<Button>(); _btnMapButton.onClick.AddListener(SelectMapName(transform.parent.name)); } private void SelectMapName(string name) { startServer.mapName = name; }[/code]
[QUOTE=LuckyLuke;46627695]This is the way I do custom [I]onClick[/I] methods; [code] // Get the BUTTON component of the object _gMultiPlayer = GameObject.Find("btnMultiplayer").GetComponent<Button>(); // Assign a custom method as the listener _gMultiPlayer.onClick.AddListener(MultiplayerButton_OnClick); [/code] No idea if this is the best way, but it works for me. For yours though, since I assume they're created dynamically, you could just make a new script, and attach it to the button element of the prefab, inside the script would be something like this; [code] private Button _btnMapButton; private void Start() { _btnMapButton = gameObject.GetComponent<Button>(); _btnMapButton.onClick.AddListener(SelectMapName(transform.parent.name)); } private void SelectMapName(string name) { startServer.mapName = name; }[/code][/QUOTE] Thanks for the quick reply, I will give it a try. [editline]3rd December 2014[/editline] Ok so I've been looking for a solution but couldn't find anything. [code] using UnityEngine; using System.Collections; using UnityEngine.UI; public class GetMapName : MonoBehaviour { private Button _btnMapButton; private void Start() { _btnMapButton = gameObject.GetComponent<Button>(); _btnMapButton.onClick.AddListener(SelectMapName(transform.parent.name)); } private void SelectMapName(string name) { startServer.mapName = name; } } [/code] [b]Error[/b] [img]http://imagizer.imageshack.com/img538/9792/ojNXrl.png[/img] [editline]3rd December 2014[/editline] Never mind I have fixed it. (I found the same thing on multiple forums so I decided to give it a try) If someone could explain it to me it would be great. I hate when I just copy and paste bits of code which I don't understand. [code] //Fix - I was missing () => _btnMapButton.onClick.AddListener(() => SelectMapName(transform.parent.name)); [/code]
Does anyone know how I can resize UI Buttons via script?
Hello, is this too much for mobile devices? I can't seem to speed up specific animations with mecanim, which sucks greatly even more D: [img]http://i.imgur.com/dD12Ufn.png[/img]
Update #12 for Orbital Assault A lot has changed in this update. - Finally got around to adding crouch - Changed team auto-assign behavior (if both teams are equal in size, randomly chooses between red and blue) - Added radio announcer - Fixed several bugs involving switching weapons while sprinting - Added more soldier lines [video=youtube;wiIomL_uQJw]http://www.youtube.com/watch?v=wiIomL_uQJw[/video]
Well that's brilliant, I clicked to debug my game, then Unity crashes, now every time I launch Unity, it crashes, I can't open my project, and I can't open Unity. Apparently Unity.exe is causing an access violation, and there's no way in hell I'm reverting the changes I did. I'm still amazed at how often I manage to fuck the shit out of Unity with my projects and make it crash. All I did was add a [I]CanvasGroup [/I]to two game objects which were parents of UI elements, apparently that fucks Unity right up the arse.
[QUOTE=LuckyLuke;46630259]Well that's brilliant, I clicked to debug my game, then Unity crashes, now every time I launch Unity, it crashes, I can't open my project, and I can't open Unity. Apparently Unity.exe is causing an access violation, and there's no way in hell I'm reverting the changes I did. I'm still amazed at how often I manage to fuck the shit out of Unity with my projects and make it crash. All I did was add a [I]CanvasGroup [/I]to two game objects which were parents of UI elements, apparently that fucks Unity right up the arse.[/QUOTE] Weird.. I have plenty of canvas groups in my scene and hasn't crashed at all. I did add these groups during the 4.6 beta, though. One issue I've found with 4.6 is that UnityEvents behave weirdly in the inspector when multi-selecting objects. If you happened to have text serialization, you could try and edit out the CanvasGroups manually?
Well, I think I found out what it was, the project loaded correctly on my laptop, and the reference resolution said it couldn't load the associated script, gonna see if this fixes any of it.
Did a writeup about the multiplayer bot AI in Orbital Assault if anybody's interested. [url]http://www.mophogames.com/orbital-assault-ai-overview/[/url]
I should stop being so useless and make a video game.
[QUOTE=Solis;46660756]I should stop being so useless and make a video game.[/QUOTE] Well, video games are (kindof) useless anyway so it wont make you any less useless :v: [sp]FP devs don't get mad, I know the games are good for many things such as killing time, making your brains faster at solving tasks and many other stuff.[/sp]
[QUOTE=Fourier;46661643]Well, video games are (kindof) useless anyway so it wont make you any less useless :v: [sp]FP devs don't get mad, I know the games are good for many things such as killing time, making your brains faster at solving tasks and many other stuff.[/sp][/QUOTE] When you say it like that, you make me feel like I am wasting my time learning.
[QUOTE=BoowmanTech;46661787]When you say it like that, you make me feel like I am wasting my time learning.[/QUOTE] Sorry. Let me fix this: Skills are transferable, you gain programming & math knowledge, you also build strong sense for logic, not to mention you upgrade your creativity... ..., if you want to be (good) game developer, you need to go through programmers hell (years), you need some math (3D math -> linear algebra, 3d space, vector math), strong sense for logic which also comes after years and yeah..., you need to be patient enough, which not many people are. Also you need to be creative, because without imagination you are dead. Your time has not been wasted, it is just that games are not really useful.. as in for example, medical/surgical equipment, which save lives or some big robots which helps you make cars or build buildings :). And money is always good.
[QUOTE=Fourier;46661907]Sorry. Let me fix this: Skills are transferable, you gain programming & math knowledge, you also build strong sense for logic, not to mention you upgrade your creativity... ..., if you want to be (good) game developer, you need to go through programmers hell (years), you need some math ([B]3D math -> linear algebra, 3d space, vector math[/B]), strong sense for logic which also comes after years and yeah..., you need to be patient enough, which not many people are. Also you need to be creative, because without imagination you are dead. Your time has not been wasted, it is just that games are not really useful.. as in for example, medical/surgical equipment, which save lives or some big robots which helps you make cars or build buildings :). And money is always good.[/QUOTE] I did all that in a single night, I got bored of dreaming in Quantum Theory.
[QUOTE=Winded;46581423][url=http://unity3d.com/unity/whats-new]Unity 4.6[/url] is out! Hopefully they have polished the UI system.[/QUOTE] still no databinding, which makes many things super annoying and frustrating.
[QUOTE=LuaChobo;46671749]asaratha is a pussy and doesnt want to post his ludum dare game here [t]http://puu.sh/dmTOW/3d77797938.png[/t] so im posting it for him [url]http://ludumdare.com/compo/ludum-dare-31/?action=preview&uid=47271[/url][/QUOTE] Lifting bans from gay marriage causes riots? Seems like a proper representation of society.
Wow, Unity Remote is neat. Pretty nice given the horribly slow Android app deploy time.
[QUOTE=Clavus;46674292]Wow, Unity Remote is neat. Pretty nice given the horribly slow Android app deploy time.[/QUOTE] Unity Remote lags like hell for me, it's unusable :( I don't know if its my computer or my phone. Something is definitely bottlenecking the stream. [QUOTE=LuaChobo;46671749] so im posting it for him [url]http://ludumdare.com/compo/ludum-dare-31/?action=preview&uid=47271[/url][/QUOTE] One minute as a dictator and I got assassinated by the mafia. Learning experience!
[QUOTE=Winded;46674480]Unity Remote lags like hell for me, it's unusable :( I don't know if its my computer or my phone. Something is definitely bottlenecking the stream.[/QUOTE] Well yeah, Unity basically encodes the editor view as a video stream and has to push it over USB 2.0's shitty bandwidth, while at the same time streaming sensor / touch data from the device to the editor. It's far from a smooth experience but at least nice for testing most basic features.
I'm really considering buying the bolt engine, do you guys think there will be a Christmas sale anytime soon?
Just bought it on Unity asset store, and I got a old version. The version on Unity asset store is version 0.2.0.4 but on their website the newest version is 0.3.4. How do I get the new version? [editline]9th December 2014[/editline] Nvm found the download page.
[QUOTE=Fixed;46675901]Just bought it on Unity asset store, and I got a old version. The version on Unity asset store is version 0.2.0.4 but on their website the newest version is 0.3.4. How do I get the new version? [editline]9th December 2014[/editline] Nvm found the download page.[/QUOTE] If you want the [B]very latest[/B] version, create a Github account and contact Fholm for Github access, giving him your Github username and asset store invoice number.
Hey friends! I've been trying to get into Unity2D for awhile now. I think it's pretty awesome for what it is (I'm currently in 2 year programming stuff, so I know basics of java plus I've been learning C# on the side) I'd like to maybe start reading deeper into books and stuff and get my booklearnings up to stuff, so I've been looking at books on Amazon. I'm not sure if I'd like to get into 2D or 3D, but since I'm no good at modelling (yet :P) I'd like to get into 2D for now, to see if I like it... I'm looking at this book [url]http://www.amazon.ca/Introduction-Game-Design-Prototyping-Development-ebook/dp/B00LIYS9F0/ref=sr_1_1?ie=UTF8&qid=1418158492&sr=8-1&keywords=unity+game+development+c%23[/url] And it seems to have everything from start to finish, and goes through everything needed to have a (semi)Professional project. Are there any other books someone can reccomend to me?
Can anyone help me with the Event system in bolt? I've created an event named InstantiateEvent. When the client loads the server needs to send the event. [code] [BoltGlobalBehaviour(BoltNetworkModes.Server)] public class ServerCallbacks : Bolt.GlobalEventListener { public override void SceneLoadRemoteDone(BoltConnection connection) { Player player = new Player("", connection); Player.AddPlayer(player); using (var evnt = InstantiateEvent.Raise(Bolt.GlobalTargets.Everyone)) { evnt.Prefab = "Human Cruiser"; evnt.Position = new Vector2(0, 0); } } } [/code] I can see in the debug console that the client receives the event, but my logic I added to a script doesn't execute: [code] public class NetworkInstantiate : Bolt.GlobalEventListener { public override void OnEvent(InstantiateEvent evnt) { Debug.Log("LOL: !"); Instantiate(Resources.Load("Units/" + evnt.Prefab), evnt.Position, Quaternion.identity); } } [/code] How can I do it properly?
Looks fine, did you attach the client script to something? :p
[QUOTE=reevezy67;46690300]Looks fine, did you attach the client script to something? :p[/QUOTE] Huh, you don't have to. I found out that I needed to add [BoltGlobalBehaviour] over "public class NetworkInstantiate".
Oh yeah he changed it. You used to have to attach the scripts to a game object.
Could someone help me out here? It's just two simple 2D box colliders. Not sure what I'm doing wrong. [vid]http://webmup.com/RNYFO/vid.webm[/vid] Edit: Okay, now I'm using rigidbody2D.velocity, but now it's floaty as fuck.
What are you using to move your player? Can I see the code?
Sorry, you need to Log In to post a reply to this thread.