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 RealSoftGames · Jun 28, 2016 at 09:17 AM · c#gameobjectclasstcp

class issues with interacting with unity gameobjects (using c# server )

Hey guys got a major issue here. i wrote my own class to handle network communication and i'm running into some issues integrating it with unity

this code works. but its not my desirable outcome.

             Debug.Log("Componenet name: " + GameObject.Find("NetworkManager").GetComponent<InstantiateList>().instance[0].name);
             GameObject msg = (GameObject)Instantiate(GameObject.Find("NetworkManager").GetComponent<InstantiateList>().instance[0], Vector3.zero, Quaternion.identity);
             msg.GetComponent<Text>().text = message;
             msg.transform.SetParent(GameObject.Find("ChatTxtContent").transform);
             Debug.Log("My object Reference: " + myGameObject.name);
            



this code does not work and it is my desirable outcome

/ Debug.Log("Start Receive Message"); GameObject msg = (GameObject)Instantiate(myGameObject.GetComponent().instance[0], Vector3.zero, Quaternion.identity); msg.GetComponent().text = message; msg.transform.SetParent(GameObject.Find("ChatTxtContent").transform); Debug.Log("End Receive Message"); /

the issue is this. i have a class called Command and it runs my RPC methods for me. but some of those methods need to interact with gameobjects in the game etc chat messages with instantiating text and adding it to the contentView of a ScrollList.

some methods are static and some are standard void that take some params* the code that does not run will only run up until the first Debug.Log("Start Receive Message"); then ignoring the rest of the method. i have referenced the object on connect method at the start passing in this.gameobject storing it in the class as a public GameObject. and i ahve used that to reference, i had tested that it is referenced properly by doing a debuglog of the gameobjects name and it worked. however when i try and use this reference to communicate it does not.

i had made a new instance of the class above in my main script that i am using to communicate with the Command Class as so private Command cmd = new Command(); however nothing i want to access in the game will work unless i use GameObject,Find("ObjectsName") then do my business.

some light on this matter would be much appreciated.

thank you very much for your time in reading this.

Comment
Add comment
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

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

176 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

Related Questions

Can not access GetComponentInParent ( ). usegravity 1 Answer

Error CS1519 1 Answer

Animation won't stop (Solved) 2 Answers

The referenced script on the behaviour is missing error help plz 2 Answers

GameObject not looking at me.. 1 Answer


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