Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

omard2000

Premium Member
  • Content Count

    941
  • Joined

  • Last visited

  • Days Won

    11

omard2000 last won the day on July 10 2018

omard2000 had the most liked content!

Community Reputation

125 Excellent

About omard2000

  • Rank
    PHP, C#, Unity, HTML, CSS
  • Birthday 08/20/2000

Profile Information

  • Gender
    Not Telling
  • Location:
    United States
  • Interests
    - PHP and C#

Recent Profile Visitors

2,196 profile views
  1. Hi everyone, So at the moment I have two scripts, one which does inherit from Monobehaviour and the other that does not inherit from Monobehaviour. Right now, I am able to start coroutines in the non-monobehaviour script like this: public class PHP_LoginSystem : MonoBehaviour { private PHP_Account acc; public void Update () { if (Input.GetKeyDown (KeyCode.F)) { StartCoroutine(acc.RefreshProfile()); acc.Print(); } } } public class PHP_Account { public string id; public string username; public string email; public string status; public string parsedUsername; public string plainId; public void SetAccount (string _id, string _username, string _email, string _status) { // Code } public void Print () { Debug.Log(id); Debug.Log(username); Debug.Log(email); Debug.Log(status); } public IEnumerator RefreshProfile() { // Code } } My issue now is how can I create a Loader coroutine INSIDE the script that does not inherit from Monobehaviour? I know I can create a loader coroutine inside the script that does inherit from Monobehaviour but it would be very inconvenient as I would have to place the loader throughout a lot of scripts. Does anyone have any ideas on how to solve this? I the script PHP_LoginSystem I need the coroutine RefreshProfile to finish before calling the print function basically. Thanks!
  2. Never mind, stupid mistake I made lol. Thanks again!
  3. Ohh, this makes sense now. Thank you!
  4. What you are saying makes sense, but I don't understand the output that is being displayed in the console. This is the output with the code that you suggested: "Message from user System.String[]: System.Object[]" Shouldn't it be displaying the username and the message?
  5. Hello,I understand that whenever a message is received this function is called. However, I do not know how I can extract the information that is being received...public void OnGetMessages(string channelName, string[] senders, object[] messages) {string msg = "";for (int i = 0; i < senders.Length; i++) {msg = string.Format("{0}{1}={2}, ", msg, senders, messages);}Debug.LogFormat("OnGetMessages: {0} ({1}) > {2}", channelName, senders.Length, msg);}This is the code that I am referring to.For example, this is the output when I send the message "hello" from another user...OnGetMessages: channelA (1) > 1f83f13b-666d-4f11-97d6-d4adb6624242=hello, How can I get the sender name and the message sent from this information?Thanks!
  6. Yes. However, it will return a md5 hash of the Android ID. Make sure to take a look at the link below, the Unity version that you are using may make a difference. https://forum.unity.com/threads/unique-identifier-details.353256/
  7. omard2000

    Compiler error

    Go to Player Settings -> API compatibility level and make sure it is set to .NET 2.0 Subset
  8. I skimmed through the video and it does cover a decent amount. However, I would not recommend watching a 4 hour video in hope of mastering any programming language. You also did not mention if you have previous knowledge of other languages or C#. Personally, what I would do, is I would cover each topic in depth. For example, if you're learning about arrays I would look up a YouTube tutorial about arrays and find a video that really goes into depth and gives you fully explained code. Make sure to check out the documentation as well if you are having a hard time understanding a concept. I would consider this video somewhat of a starting point maybe? It really all comes down to what you are expecting to learn.
  9. Hi everyone, I am trying to retrieve an image (as a texture) from my website http://www.coldops.rf.gd/1.png through Unity's WWW stream. However, whenever I try downloading it through the WWW stream it displays a big red question mark instead. What is weird is that I have tried it with other images (from different websites) and it seems to be working just fine. Does anyone have any ideas what could be the issue here? For example, this website's image works just fine: http://gameassets.net/GameAssetsLogo.png Here is my code: using System.Collections; using System.Collections.Generic; using UnityEngine.UI; using UnityEngine; public class News_Manager : MonoBehaviour { public RawImage image; IEnumerator Start () { WWW www = new WWW ("http://www.coldops.rf.gd/1.png"); yield return www; image.texture = www.texture; } } Thanks!
  10. Yeah, I just realized that too. In the OnDisable function it should be removecallbacktarget instead, but I don't think that's the issue. I ended up re-writing the script because I couldn't find where I went wrong lol. Hmm... but how would the user control the player and how would I send RPC calls? Shouldn't there only be one player per user?
  11. @OcularCash I checked and there is only 1 object in the scene in both edit and play mode with the script attached to it. Do you think it could be the OnEnable or OnDisable functions?
  12. @OcularCash Yeah it is being logged twice in the console. I can't figure out why though.
  13. Hi Everyone, I have a really quick question. The script is working except it instantiates the player twice and I cannot figure out why. Here is the outline of the script: 1) Waits until enough players join 2) Once enough players have joined a countdown from 5 seconds starts 3) All players are joined into a new multiplayer scene I can't figure out why double of every player are being instantiated. Thanks! Here is my script: using Photon.Pun; using Photon.Realtime; using System.Collections; using System.Collections.Generic; using UnityEngine.SceneManagement; using UnityEngine; using System.IO; public class PhotonRoom : MonoBehaviourPunCallbacks, IInRoomCallbacks { // Player settings private PhotonView PV; public Player [] players; public int playersInRoom; // Game settings private bool isGameLoaded = false; private bool doneLoading = false; private bool readyToStart = false; private int currentScene = 0; private int multiplayerScene = 1; // Count down private float countFrom = 6; void Awake () { DontDestroyOnLoad (this.gameObject); } private void Start () { PV = GetComponent<PhotonView> (); } public override void OnEnable () { base.OnEnable (); PhotonNetwork.AddCallbackTarget (this); SceneManager.sceneLoaded += OnSceneFinishedLoading; } public override void OnDisable () { base.OnDisable (); PhotonNetwork.AddCallbackTarget (this); SceneManager.sceneLoaded -= OnSceneFinishedLoading; } private void Update () { if (!isGameLoaded) { if (readyToStart) { Debug.Log ("Hit1"); countFrom -= Time.deltaTime; Debug.Log ("Time left: " + countFrom); } } if (countFrom <= 0) { if (doneLoading == false) { StartGame (); doneLoading = true; } } } public override void OnJoinedRoom () { base.OnJoinedRoom (); players = PhotonNetwork.PlayerList; playersInRoom = players.Length; if (playersInRoom % 2 == 0) { readyToStart = true; } if (playersInRoom == PhotonNetwork.CurrentRoom.MaxPlayers) { if (!PhotonNetwork.IsMasterClient) return; PhotonNetwork.CurrentRoom.IsOpen = false; } } public override void OnPlayerEnteredRoom (Player newPlayer) { base.OnPlayerEnteredRoom (newPlayer); players = PhotonNetwork.PlayerList; playersInRoom++; if (playersInRoom % 2 == 0) { readyToStart = true; } if (playersInRoom >= PhotonNetwork.CurrentRoom.MaxPlayers) { if (!PhotonNetwork.IsMasterClient) return; PhotonNetwork.CurrentRoom.IsOpen = false; } } void StartGame () { isGameLoaded = true; if (!PhotonNetwork.IsMasterClient) return; PhotonNetwork.CurrentRoom.IsOpen = false; PhotonNetwork.LoadLevel(multiplayerScene); } void OnSceneFinishedLoading (Scene scene, LoadSceneMode mode) { Debug.Log ("This was called"); currentScene = scene.buildIndex; if (currentScene == multiplayerScene) { isGameLoaded = true; PV.RPC ("RPC_LoadedGameScene", RpcTarget.MasterClient); } } [PunRPC] private void RPC_LoadedGameScene () { Debug.Log ("Players in Room: " + playersInRoom); Debug.Log ("PlayerList.Length: " + PhotonNetwork.PlayerList.Length); if (playersInRoom == PhotonNetwork.PlayerList.Length) { PV.RPC ("RPC_CreatePlayer", RpcTarget.All); } } [PunRPC] private void RPC_CreatePlayer () { PhotonNetwork.Instantiate (Path.Combine ("PhotonPrefabs", "PhotonNetworkPlayer"), transform.position, Quaternion.identity, 0); } }
×
×
  • Create New...