Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Cache-Master · Dec 23, 2019 at 07:58 AM · scripting problemunityeditor

Is it just me or does my Unity not want to work?

I have been using the latest version of Unity 2019 and have had no issues up until recently. For some reason, some of the things that I have coded just stopped working randomly. They were never changed and had worked perfectly fine with other projects previously (all these other projects were made with the same Unity version. However, today simple things such as running a function when a button is hovered over on or even simply displaying a value from an array just don't want to work anymore.

One example I can provide is my command console I recently started working on. From what I can see, I don't think there are any errors in the code (if I missed something please tell me, I truly appreciate all feedback) but the script just does not work. The code is:

 using System;
 using System.Collections.Generic;
 using UnityEngine;
 using Photon.Pun;
 using Photon.Realtime;
 using UnityEngine.UI;
 
 public class console : MonoBehaviourPunCallbacks
 {
     bool consoleOpen = false;
     bool consoleUnlocked = false;
     public GameObject dev_console;
 
     string[] commands = new string[4];
     string[] outputs = new string[4];
 
     public InputField csInput;
     public Text csOutput;
 
     void Start()
     {
         initCommands();
         initOutputs();
     }
 
     void initCommands()
     {
         //cs commands
         commands[0] = "cs_clear";
         commands[1] = "cs_help";
 
         //mp commands
         commands[2] = "mp_join_random";
 
         //dev commands
         commands[3] = "dev_7073";
 
         csOutput.text += "\n(" + DateTime.Now.TimeOfDay.ToString() + ") Commands updated and loaded";
     }
 
     void initOutputs()
     {
         //cs outputs
         outputs[0] = "Clearing...";
         outputs[1] = "";
 
         //mp outputs
         outputs[2] = "Joining random room...";
 
         //dev outputs
         outputs[3] = "까불지 마.";
 
         csOutput.text += "\n(" + DateTime.Now.TimeOfDay.ToString() + ") Outputs updated and loaded";
     }
 
     void Update()
     {
         if (Input.GetKeyDown(KeyCode.BackQuote))
         {
             if (consoleOpen == true)
             {
                 consoleOpen = false;
                 dev_console.SetActive(false);
             }
             else
             {
                 consoleOpen = true;
                 dev_console.SetActive(true);
             }
         }
     }
 
     public void submitEntry()
     {
         string input = csInput.text;
         csInput.text = "";
 
         int index = Array.BinarySearch(commands, input);
 
         if (index < 0)
         {
             csOutput.text += "\n(" + DateTime.Now.TimeOfDay.ToString() + ") Unknown command, use 'cs_help' for a list of available commands.";
         }
         else
         {
             csOutput.text += "\n(" + DateTime.Now.TimeOfDay.ToString() + ") " + outputs[index];
         }
 
         if (input == commands[0])
         {
             csOutput.text = "";
         }
 
         if (input == commands[1])
         {
             foreach (var item in commands)
             {
                 if (item == "dev_7073")
                 {
 
                 }
                 else
                 {
                     csOutput.text += item + ", ";
                 }
             }
         }
 
         if (input == commands[2])
         {
             if (consoleUnlocked == true)
             {
                 PhotonNetwork.JoinRandomRoom();
             }
             else
             {
                 csOutput.text += "\n(" + DateTime.Now.TimeOfDay.ToString() + ") Error: Access Denied.";
             }
         }
 
         if (input == commands[3])
         {
             consoleUnlocked = true;
         }
     }
 
 }
 


Now the main issue with this code is that all commands work perfectly fine except for "dev_7073". When I enter that code, consoleUnlocked does become true which means the function had ran properly. However, the output for the code is not displayed for some reason and returns the "Unknown command" response. But why would it do that? Especially since it executes the command's function.

Any and all help is appreciated :)

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lgarczyn · Dec 23, 2019 at 11:50 PM 0
Share

Please use Debug.Log to log the lines after concatenation. $$anonymous$$aybe even use breakpoints to see what your code is doing.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

283 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Error building Player: CommandInvokationFailure: Failed to re-package resources. 0 Answers

Resolve 'UnityEditor' error 1 Answer

How to run a function after every X minutes in Unity Script? 1 Answer

Unity hangs with scripts on school device. 0 Answers

How can my wallrun script double wallrun ? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges