0

[コマンド] を実行すると、権限に関する警告メッセージが表示されますが、この警告の出所がわかりません。オブジェクトをドラッグすると、これが得られます。

a) 警告メッセージが表示される理由と場所がわかりません。

b) なぜ localplayer ではなく、2 回目の権限を持つのか理解できませんか?

c) localplayer と hasauthority が false のときに yt が「0」である理由がわかりません。

誰かが私にこれを説明してくれたら本当にありがたいです? 教えてくれ?

タッチにはEasyTouchを使用しています。

//======================================================================//
//                                                                        //
//                               On_DragStart                                //
//                                                                        //
//======================================================================//

public void On_DragStart (Gesture gesture) {

    print ("On_DragStart");
    if (!isLocalPlayer) 
        return;

    if (!hasAuthority)
        return;

    if (selected_GO == null)
        return;

//        Cmd_SetAuthority(selected_GO.GetComponent<NetworkIdentity>().netId, gameObject.GetComponent<NetworkIdentity>());

}
private bool firstLoop = true;
private int yt = 0;
//======================================================================//
//                                                                        //
//                                  On_Drag                                //
//                                                                        //
//======================================================================//

public void On_Drag (Gesture gesture) {
//        print ("On_Drag");

    print ("a) " + yt + " isLocalPlayer: " + isLocalPlayer);

    if (!isLocalPlayer)
        return;

    print ("b) " + yt + " hasAuthority: " + hasAuthority);

    if (!hasAuthority)
        return;
    print ("c) " + yt + " selected_GO: " + selected_GO.name);

    if (selected_GO == null)
        return;
    print ("d) " + yt);

    if (firstLoop) {
        print ("e) " + yt);
        if (selected_GO.GetComponent<NetworkIdentity> ().hasAuthority == false) {
            print ("f) " + yt);
            var networkIdentity = selected_GO.GetComponent<NetworkIdentity>();
            var otherOwner = networkIdentity.clientAuthorityOwner;      

            networkIdentity.RemoveClientAuthority(otherOwner);  
        }


        print ("g) " + yt);

    }

    // Only allow drag if player own object
    if (selected_GO.GetComponent<NetworkIdentity> ().hasAuthority == true) {
        // Check if there have been a linecast, if so use that Game Object for drag
        print ("h) " + yt);

        if (selected_GO != null) {

            print ("i) " + yt);
            selected_GO.transform.position = Camera.main.ScreenToWorldPoint (new Vector3 (gesture.position.x, gesture.position.y, 1f));
        } else if (gesture.pickedObject != null) {
            print ("j) " + yt);

            gesture.pickedObject.transform.position = Camera.main.ScreenToWorldPoint (new Vector3 (gesture.position.x, gesture.position.y, 1f));
        }
    }
    print ("k) " + yt);
    yt++;
}

//======================================================================//
//                                                                        //
//                               On_DragEnd                                //
//                                                                        //
//======================================================================//

public void On_DragEnd (Gesture gesture) {
    print ("On_DragEnd");
    if (!isLocalPlayer && !hasAuthority) 
        return;

    if (selected_GO == null)
        return;

    if (containerMode) {
        DisableParentChildRelationship (_syncEngine.cardNames_SList);

        // Color all cards in container white to show that this is not a container anylonger
        foreach (string aSTR in _syncEngine.cardNames_SList) {
            temp_GO = GameObject.FindWithTag (aSTR);
            Cmd_Paint (temp_GO, Color.white);
        }
    } else {
        if (selected_GO.GetComponent<NetworkIdentity> ().hasAuthority == true) {
            Cmd_SetAuthority(selected_GO.GetComponent<NetworkIdentity>().netId, gameObject.GetComponent<NetworkIdentity>());
        }
    }


} 

ドラッグ時にこのコードから得たプリントは次のとおりです。

On_DragStart
On_DragStart
a) 0 isLocalPlayer: True
b) 0 hasAuthority: True
c) 0 selected_GO: _H4_Gun
d) 0
e) 0
f) 0
g) 0
h) 0
i) 0
k) 0
a) 0 isLocalPlayer: False
Command for object without authority [netId=9]
Command for object without authority [netId=9]
Command for object without authority [netId=9]
Command for object without authority [netId=9]
a) 1 isLocalPlayer: True
b) 1 hasAuthority: True
c) 1 selected_GO: _H4_Gun
d) 1
h) 1
i) 1
k) 1
a) 0 isLocalPlayer: False
Command for object without authority [netId=9]
Command for object without authority [netId=9]
a) 2 isLocalPlayer: True
b) 2 hasAuthority: True
c) 2 selected_GO: _H4_Gun
d) 2
h) 2
i) 2
k) 2
a) 0 isLocalPlayer: False
a) 3 isLocalPlayer: True
b) 3 hasAuthority: True
c) 3 selected_GO: _H4_Gun
d) 3
h) 3
i) 3
k) 3
…etc.
4

0 に答える 0