Recent Posts

Pages: 1 ... 7 8 [9] 10
81
NGUI 3 Support / Re: Load new Scene on Button Press
« Last post by Shifty Geezer on January 31, 2018, 06:24:23 PM »
Use the existing Event system. Attach a UIEventTrigger script to your button in the inspector. Add your script and method with its one parameter in the OnPress event. You pass an object to the parameter and select a property from it. I use a super simple script that just has a public int attached for things like level selection, and I pass that as a parameter in the UIEventTrigger parameter.

So I have two scripts on a level selection button, UI_Number that just has a public int, and UIEventTrigger that passes this int value to the script.
82
NGUI 3 Support / Re: Sprite Atlas Transparency Issues
« Last post by Shifty Geezer on January 31, 2018, 06:14:40 PM »
If you're trying to use sprites for both NGUI and in Unity, why not use a Unity 2D Sprite instead of an NGUI atlas?
83
NGUI 3 Support / Re: Is NGUI still actively supported?
« Last post by Shifty Geezer on January 31, 2018, 06:11:57 PM »
It really needs to be! Unity's GUI is dog slow by comparison, plus I've spent two years slowly getting used to how NGUI works and can't change to another UI now!
84
NGUI 3 Support / UIInput not submitting on Android 'return' key
« Last post by Shifty Geezer on January 31, 2018, 06:08:46 PM »
I've a UIInput field with Return action set to 'submit'. It works as expected on PC, calling its OnSubmit event. On a Shield Tablet running Android 7, the return key adds a new line. Same incorrect behaviour on a Nexus 7 running Android 6.

I'm using NGUI 3.11.4
85
TNet 3 Support / I tryed to make animator sync script,but it has isues
« Last post by defender1213 on January 29, 2018, 01:50:43 PM »
I tryed to make animator sync script,but it has isues and dont works correct at all,please help me to fix this script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TNet;
public class TN_Animator : TNBehaviour{
    Animator anim;
    [SerializeField] int updates=10;
    float uptouse=0;
    float[] data;
    int[] param;
    string[] _name;
    void Awake()
    {
        anim = GetComponent<Animator>();
        param = new int[anim.parameterCount];
        _name = new string[anim.parameterCount];
        for(int i = 0; i != anim.parameterCount; i++)
        {
            if (anim.parameters.type == AnimatorControllerParameterType.Bool) param = 0;
            else if (anim.parameters.type == AnimatorControllerParameterType.Float) param = 1;
            else if (anim.parameters.type == AnimatorControllerParameterType.Int) param = 2;
            else if (anim.parameters.type == AnimatorControllerParameterType.Trigger) param = 3;
            _name =  anim.parameters.name;
        }
        data = new float[anim.parameterCount];
        uptouse = updates;
    }
    void FixedUpdate()
    {
        if (tno.isMine)
        {
            uptouse -= Time.fixedDeltaTime;
            if (uptouse <= 0)
            {
                for (int i = 0; i != anim.parameterCount; i++)
                {
                    if (Equals(param, 0)) if (Equals(anim.GetBool(_name), true)) data = 0; else data = 1;
                    else if (Equals(param, 1)) data = anim.GetFloat(_name);
                    else if (Equals(param, 2)) data = anim.GetInteger(_name);
                    else if (Equals(param, 3)) if (Equals(anim.GetBool(_name), true)) data = 0; else data = 1;
                }
                tno.SendQuickly("UpPram", Target.Others, data);
                Debug.Log(data);
                uptouse = updates;
            }           

        }
    }
    [RFC]void UpPram(float[] data)
    {
        for(int i=0;i!=data.Length;i++)
        {
            if (Equals(param, 0)) if (Equals(data,0 ))anim.SetBool(_name,true); else anim.SetBool(_name, false);
            else if (Equals(param, 1)) anim.SetFloat(_name, data);
            else if (Equals(param, 2)) anim.SetInteger(_name, (int)data);
            else if(Equals(param, 3)) if (Equals(data, 0)) anim.SetTrigger(_name);
        }
        this.data = data;
    }
   
}
86
NGUI 3 Support / I tryed to make animator sync script,but it has isues
« Last post by defender1213 on January 29, 2018, 01:44:39 PM »
I tryed to make animator sync script,but it has isues and dont works correct at all,please help me to fix this script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TNet;
public class TN_Animator : TNBehaviour{
    Animator anim;
    [SerializeField] int updates=10;
    float uptouse=0;
    float[] data;
    int[] param;
    string[] _name;
    void Awake()
    {
        anim = GetComponent<Animator>();
        param = new int[anim.parameterCount];
        _name = new string[anim.parameterCount];
        for(int i = 0; i != anim.parameterCount; i++)
        {
            if (anim.parameters.type == AnimatorControllerParameterType.Bool) param = 0;
            else if (anim.parameters.type == AnimatorControllerParameterType.Float) param = 1;
            else if (anim.parameters.type == AnimatorControllerParameterType.Int) param = 2;
            else if (anim.parameters.type == AnimatorControllerParameterType.Trigger) param = 3;
            _name =  anim.parameters.name;
        }
        data = new float[anim.parameterCount];
        uptouse = updates;
    }
    void FixedUpdate()
    {
        if (tno.isMine)
        {
            uptouse -= Time.fixedDeltaTime;
            if (uptouse <= 0)
            {
                for (int i = 0; i != anim.parameterCount; i++)
                {
                    if (Equals(param, 0)) if (Equals(anim.GetBool(_name), true)) data = 0; else data = 1;
                    else if (Equals(param, 1)) data = anim.GetFloat(_name);
                    else if (Equals(param, 2)) data = anim.GetInteger(_name);
                    else if (Equals(param, 3)) if (Equals(anim.GetBool(_name), true)) data = 0; else data = 1;
                }
                tno.SendQuickly("UpPram", Target.Others, data);
                Debug.Log(data);
                uptouse = updates;
            }           

        }
    }
    [RFC]void UpPram(float[] data)
    {
        for(int i=0;i!=data.Length;i++)
        {
            if (Equals(param, 0)) if (Equals(data,0 ))anim.SetBool(_name,true); else anim.SetBool(_name, false);
            else if (Equals(param, 1)) anim.SetFloat(_name, data);
            else if (Equals(param, 2)) anim.SetInteger(_name, (int)data);
            else if(Equals(param, 3)) if (Equals(data, 0)) anim.SetTrigger(_name);
        }
        this.data = data;
    }
   
}
87
TNet 3 Support / Can't compile for UWP (HoloLens)
« Last post by brookman on January 28, 2018, 05:05:49 PM »
Hello everyone.
I recently bought TNet to sync my apps between multiple AR devices over a local network.
The library is great and works fine on Android (Google Tango) and on desktop.
However I can't get it to compile on the HoloLens (UWP?, WSA?, .Net core?). I'm getting the following errors:

  • Assets\TNet\Common\TNSerializer.cs(17,36): error CS0234: The type or namespace name 'Formatters' does not exist in the namespace 'System.Runtime.Serialization' (are you missing an assembly reference?)
  • Assets\TNet\Common\TNTools.cs(1259,38): error CS0246: The type or namespace name 'ParameterizedThreadStart' could not be found (are you missing a using directive or an assembly reference?)
  • Assets\TNet\Common\TNTools.cs(1275,38): error CS0246: The type or namespace name 'ThreadStart' could not be found (are you missing a using directive or an assembly reference?)
  • Assets\TNet\Server\TNTcpLobbyServer.cs(28,13): error CS0246: The type or namespace name 'TcpListener' could not be found (are you missing a using directive or an assembly reference?)
  • Assets\TNet\Server\TNGameServer.cs(108,13): error CS0246: The type or namespace name 'TcpListener' could not be found (are you missing a using directive or an assembly reference?)

It seems like UWP has no implementations for "System.Runtime.Serialization.Formatters.Binary", "System.Threading.ParameterizedThreadStart", "System.Threading.ThreadStart" and "System.Net.Sockets.TcpListener".

Is there any chance that TNet could be adapted to work on the UWP platform? Or should I look for an alternative?

Thanks in advance!
- brookman
88
TNet 3 Support / A few questions (ChannelData, TNObject Data, DataNode, Custom Files)
« Last post by nuverian on January 28, 2018, 12:11:44 PM »
Hello there,

First of all, I have to say that TNet is great. It's easy enough to use, yet powerful to delve deeper.
After using it for a while though and implementing it into our game so far with success, I came by a few questions.
Our game by the way, can best be described as your typical coop survival genre (crafting, building etc). Think "The Forest".

- ChannelData
So, I understand that ServerData is saved in server.dat and PlayerData is saved in player.dat for example, but I am don't really understand where are ChannelData saved. Shouldn't they be saved in a file like the others, or are they rather buffered RFCs ? Shouldn't there be a SetChannelSave similar to how SetPlayerSave exists for example?
What I am after here more or less, is to save the "game" state/data, that is not really tied to either of the players. Such things as the buildings we've build, the common items in our inventory chest, or the resources left on each mine deposit.
I could probably use the hosting player's data, but I thought that ChannelData would be a better (and cleaner) fit for that, or am I misunderstanding something?

- TNObject.Get/Set
Similar question to ChannelData above, are TNObject data, buffered RFCs as well? If so (which I think is true) can they somehow be saved to a file on the server?

- Arbitrary DataNode / JSON File
I see that there exist a very handy TNManager.LoadFile / TNManager.SaveFile already, so I am thinking that I could use a custom DB-like file for saving the game/world state, either in JSON or DataNode format and would probably prefer DataNode so that serialization stays the same to the rest of TNet. In both cases though (JSON/DataNode), I would like to save the file in text format so that they stay human readable and editable. As far as I understand though, using LoadFile/SaveFile is not possible for text format. Is there any other way already provided?

As you can tell, I am after an (as much as possible) data driven approach, where all saved data can be found as editable files on the server. Considering I didn't misunderstood anything about my 1st and 2nd question, using a custom DB-like file, seems to be bypassing some "data persistence" TNet features, but I think that having half data stored as Player DataNode files, while other data simply as buffered calls, will become a bit unmanageable in the long run, and I would much prefer to keep everything in one place.

--

- Bonus Qustion :) Common Objects
Now this is a noob question probably, but are there any best practices to handle TNObjects that are neither static IDs, nor are they tied to any specific player. They are rather objects instantiated from one player, but where all players are able to use it the same, like once again for example, a crafted chest of common among player items.
My question mostly concerns data, as per my previous questions, but also any other idea, thing or feature that I should be aware of, is more than welcome :)


Once again, TNet is really great. I just need to bypass this "data persistence" issue I am facing :)
Any thoughts, directions or suggestions are very welcome.
Thanks!
89
TNet 3 Support / Re: Weird TNManager.Ping Issue
« Last post by Doomlazy on January 28, 2018, 11:27:48 AM »
Never mind I realised TNManager.Ping is for remote servers and I can just use TNManager.ping for the current game server.
90
NGUI 3 Support / Re: Sprite Atlas Transparency Issues
« Last post by Pfaff on January 28, 2018, 09:52:35 AM »
Same problem with sprite transparencies. I'm getting artifacts left and right. Tried playing around with the setting, but nothing solved the issue. I'd appreciate any suggestion on how to sort this out.
Pages: 1 ... 7 8 [9] 10