PlayerPrefs saves registry name strange!

Hi, I’m connecting Unity with Labview…

public void HeadTrack()
    {
        RotationX = (int)transform.eulerAngles.x;
        RotationY = (int)transform.eulerAngles.y;
        RotationZ = (int)transform.eulerAngles.z;

        PlayerPrefs.SetInt("RotationX", RotationX);
        PlayerPrefs.SetInt("RotationY", RotationY);
        PlayerPrefs.SetInt("RotationZ", RotationZ);
    }

I save 3 values with this code above (Rotation X to Z).

5218238--519902--upload_2019-11-27_15-9-35.png

It seems work well.

But registry names are different what I want to make. Strange numbers are attached after!..

I set their name such as “RotationX” (like code above).

I hope your kind reply… :slight_smile:

Why do you care what names they are in the registry? PlayerPrefs doesn’t claim the entries in the registry are named exactly as the key you specify, just that when you request the value by the same key you saved as that you get the correct value back.

Where does Unity ever state that the name of the registry entry is the name of the provided key?

1 Like

That’s all you really need to know. You don’t need to care how PP stores values, as long as it works.

If you want to get a file that’s more human-readable for whatever reason, you can serialize values yourself, maybe use JsonUtility, something like that. PlayerPrefs is best for the most basic “fire and forget” sort of permanent data.

Speaking of which, this really looks like a poor usage of PlayerPrefs. What are you actually trying to do with this? It looks like you’d probably be better offer with JsonUtility regardless.

2 Likes

I’m also a LabView user, how are you using both?

Thx for reply Joe!..

I want to send some values from Unity to Labview. To read reg value in Labview, I need exact name of that.

5221766--520484--upload_2019-11-28_10-8-52.png

Now I’m doing this in my own PC. But If I move this other PC I can’t assure Unity will save its reg value in same name in my PC.

So as I learned, I want to make a rule for naming to read reg value regardless of which computer is running what I make.

I dont test yet reading reg value in Unity. I didnt know I can read just with reg name I saved.

1 Like

Thx for reply, StarManta.

I’m trying to send some values from Unity to Labview. I can figure using txt file at first, but It will grow too large over time. And I’m afraid that may make slow all system. So I think a way to send value not saving a file or record will be better and I used PP.

After finish initial configure of whole system I’ll try what you recommend. Thank you!

I used vi files in Windows Registry Access VI
(http://zone.ni.com/reference/en-XX/help/371361R-01/glang/windows_registry_access_vi/)

and to use PlayerPrefs you need add line ‘using UnityEngine.UI’ in head of script.

Exchanging data via the registry is not recommended! Just write to a circular file buffer, or use a custom DLL.

2 Likes

Firstly, this ^

But if you’re curious, these letters/numbers after the key is the hash.

The algorithm used by Unity is in this answer here.
http://answers.unity.com/answers/208076/view.html

1 Like

Yeah, you definitely need to learn to write files yourself - it’s not difficult (and about a hundred times easier than trying to reverse-engineer the PlayerPrefs file format).

2 Likes

May I ask why regsitry is not recommended if you don’t mind?.. I alread read about hooking issue from blogs but Vive used that on their SDK. So I thought that might be safe sending internal program to internal. Thanks for reply!

Thanks for reply! As I understand… Yoda recommended to use ‘Registry’ class(?) than PlayerPrefs.
I got it why Unity adds hash. :slight_smile:

You keep trying/asking about the hardest available ways to do this. JSON is incredibly easy to use in Unity , and you can find stuff about reading JSON in Labview via google.

1 Like

System efficiency. Microsoft recommends storing your data in external files and referencing the files in a registry entry when you need to store more than 2KB. Because storing large amounts of data within the registry will adversely affect system performance.

https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-storage-space
https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-element-size-limits

1 Like

I dont mean to bother you keep asking… Just I need to clear reasons and why/why not to report a reason why I choose any method to my research chief(Also comparison with other methods…).
And personaly a little bit curious why registry method is not recommended (System efficiency - Thx Ryiah!) 'cause Vive SDK sends rotation data to registry.

Again I really hope you not to be irritated. And Thanks for link!.. I’ll refer them. :slight_smile:

Thx Ryiah! I didnt know about that restriction. I may able to talk why I need to change data sending method.

The registry is a complex mechanism with lots of features you probably don’t need. This is the best argument against it. I’m sure there are also many constraints to using it, such as the one Ryiah linked.

Also, PlayerPrefs doesn’t say anything about the registry, so you’re breaking encapsulation by even discovering that it’s writing there. If you want to control where you’re writing to in the registry, use the correct tools.

Make things as simple as possible.

1 Like

What are you trying to accomplish in connecting Labview with Unity? I use both myself, and they are great programs. Passing data via the file system is rarely recommended, and is slow. How frequently is the data changing, and what is the data? And you mentioned “Yoda”, who is that? Someone told you to exchange data via the Registry? I suspect you are making references out of context. The registry is used for app-specific values for data that rarely changes, like storing the most recent used file list that many programs use. This may help http://www.ni.com/tutorial/10060/en/

2 Likes