playMaker

Author Topic: Get User Name  (Read 1490 times)

xoart

  • Guest
Get User Name
« on: December 16, 2015, 09:16:33 AM »
Hello,


I need to get the username in order to save data with the action "Write to file" to a specific location. I dind't found any way to set a location not specific to my computer.

I made a custom action but it doesn't works :



using System;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
    [ActionCategory(ActionCategory.Application)]
    [Tooltip("Save the UserName in a string, useful to save data")]
    public class SaveUserName : FsmStateAction
    {
        [RequiredField]
        [UIHint(UIHint.Variable)]
        [Tooltip("Store the final String in a variable.")]
        public FsmString storeResult;

        void DoBuildPath()
        {
            string result = System.Security.Principal.WindowsIdentity.GetCurrent().Name; ;
            storeResult.Value = result;
        }
       

    }
   
}

Can you help me with it ?

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Get User Name
« Reply #1 on: December 16, 2015, 10:20:47 AM »
hi,

you can use playerprefsQ. It will save a txt file in specific unity path. Use the debug action included to see the path and read the code to see what is happening.

xoart

  • Guest
Re: Get User Name
« Reply #2 on: December 17, 2015, 04:19:21 AM »
I don't find the action you are talking about, and i have playprefsQ and arraymaker.

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Get User Name
« Reply #3 on: December 18, 2015, 09:18:24 AM »
debug Path.


the path uses http://docs.unity3d.com/ScriptReference/Application-dataPath.html

It will print the path of the final txt file in the console.