コード例 #1
0
    public static GameObject RemoveSyncBehaviour(GameObject go)
    {
        if (go == null || instance == null)
        {
            return(null);
        }

        List <FrameSyncBehaviour> behavioursToRemove = new List <FrameSyncBehaviour>(go.GetComponentsInChildren <FrameSyncBehaviour>());

        for (int i = 0; i < behavioursToRemove.Count; i++)
        {
            IFrameSyncBehaviour tsmb = behavioursToRemove[i] as IFrameSyncBehaviour;

            int index = instance.GetBehaviourIndex(instance.ListManagedBehaviors, tsmb);
            if (index >= 0)
            {
                instance.ListManagedBehaviors.RemoveAt(index);
            }
        }
        return(go);
    }
コード例 #2
0
    /**
     * @brief Disables 'OnSyncedInput' and 'OnSyncUpdate' calls to every {@link IFrameSyncBehaviour} attached.
     **/
    public static void SyncedDisableBehaviour(GameObject gameObject)
    {
        MonoBehaviour[] monoBehaviours = gameObject.GetComponentsInChildren <MonoBehaviour>();

        for (int index = 0, length = monoBehaviours.Length; index < length; index++)
        {
            MonoBehaviour tsb = monoBehaviours[index];

            int i = -1;

            if (tsb is IFrameSyncBehaviour && (i = instance.GetBehaviourIndex(instance.mapManagedBehaviors, (IFrameSyncBehaviour)tsb)) >= 0)

            {
                instance.mapManagedBehaviors[i].Value.disabled = true;
            }
        }
    }