Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

One script in multiple object

Discussion in 'Scripting' started by sanjayMer, Jul 25, 2016.

  1. sanjayMer

    sanjayMer

    Joined:
    Dec 12, 2015
    Posts:
    4
    hello friend.


    i am new in unity and working on project.
    that have two different device like mobile and i use the one script for both object.

    i have two scenario for both device,
    One:- for single user game that game have default devices is ON
    Second :- multiplayer game on that default device is OFF

    So any one can help me out this situation to handel one scrip for different object


    sorry for bad english....

    Thanks
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    not entirely sure what you mean, but for multiplayer you'll need to look into a multiplayer framework like uNet or Proton.

    https://docs.unity3d.com/Manual/UNet.html

    If you are completely new to unity you might be better off working on the single player local game first before getting into the complexities of the multiplayer.
     
  3. sanjayMer

    sanjayMer

    Joined:
    Dec 12, 2015
    Posts:
    4
    yes but my point is who to use one script in multiple object
     
  4. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    yeah, thats the bit that isn't coming across too well :p :)

    to do what specifically?

    do you mean:
    different client mobile devices?
    different gameobjects inside a scene?
    something else?

    not sure if we're dealing with something really basic like script instances on multiple gameobjects, something relating to client/server architecture, a misconception etc. :confused:
     
  5. sanjayMer

    sanjayMer

    Joined:
    Dec 12, 2015
    Posts:
    4
    thanks for replay
    LeftyRighty

    no there is no client/server architecture
    i have one user and i have two scenario and one script that assign with multiple device
    Example :- i have one Lenovo and nexus phone that use same os
    in my scenario i have one script porto popup and this script assign with portophone and mobilo phone
    below script is assign with two object
     

    Attached Files:

    Last edited: Jul 26, 2016
  6. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
    So if I get it right, you the script to be disabled on certain devices? Like it should be on on the Nexus and off on the levono? Something like that?
     
  7. sanjayMer

    sanjayMer

    Joined:
    Dec 12, 2015
    Posts:
    4
    yes Jister,
    but some time it is not working proper

    I am check the object level and i found the issue

    i have reference with above the object and current object value not change but in the hierarchy
    first object is access will we are in last object

    so i am going to remove the script instance.
    lat me check it, i think it is working fine.
     
    Last edited: Jul 26, 2016