private void ReceiveTechnique(NetworkMessage message)
    {
        StringMessage techniqueJson = message.ReadMessage <StringMessage>();

        Technique t = JsonUtility.FromJson <Technique>(techniqueJson.value);

        TechniqueFileHelper.Save(t);

        OnTechniqueReceived?.Invoke();
    }
Example #2
0
    public void Export()
    {
        errorText.text = String.Empty;

        string techniqueName = TechniqueNameField.text;
        string userName      = UserNameField.text;

        bool validTechName = ValidTechName();
        bool validUserName = ValidUserName();
        bool validData     = validUserName && validTechName;

        if (!validUserName)
        {
            errorText.text += "Invalid username.\n";
        }

        if (!validTechName)
        {
            errorText.text += "Invalid technique name";
        }

        if (validData)
        {
            SerializableSkeleton[] techniqueFrames = Playback.SkeletonFrames
                                                     .Where((s, i) => i >= Playback.StartFrame && i < Playback.EndFrame)
                                                     .ToArray();

            TechniqueFileHelper.Save(new Technique(techniqueName, techniqueFrames, userName));

            exportedText.text = $"{techniqueName} exported successfully.";
            menuControl.OnStateChanged(MenuStates.ExportFinished);
        }
        else
        {
            menuControl.OnStateChanged(MenuStates.ErrorEdit, false);
        }
    }