- Home /
How can I assign unique ID's and keep them in inspector.
I have too many GameObjects, I don't want to manually assign them ID's.
How can I assign them ID's in the editor so the data isn't lost when transitioning from runtime back to the editor?
I can't copy paste the scene form runtime either because there's too many gameobjects which causes the engine to crash.
For example I can do this at runtime once, but I need this to persist to the editor.
int i = 0;
foreach(Soil s in sList)
{
s.uniqueId = i;
i++;
}
How can I run this in the editor, or how can I keep the id's after runtime ends. Either option would work.
Thanks.
Answer by Razputin · Aug 17, 2020 at 04:25 PM
I got it to work, here's what I did... ignore what I named things lol...
using System;
using UnityEditor;
using UnityEngine;
[ExecuteInEditMode]
public class DummyThicc : MonoBehaviour
{
public SaveLoadManager sLM;
private void Update()
{
Fuck();
}
bool exe;
void Fuck()
{
if (!exe)
{
int i = 0;
foreach (Soil s in sLM.sList)
{
s.uniqueId = i;
i++;
}
exe = true;
}
}
}
Your answer
Follow this Question
Related Questions
Instantiate ID 2 Answers
Play Services Plugin Google ID doesn't update 0 Answers
How to (de) serialize unity references at runtime? 3 Answers
store contact with last before destruction 3 Answers
Facebook SDK - Get User ID 1 Answer