Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to save prefab between the scenes, it is something like inventory, and i have this:
Parent of RectTransform is being set with parent property. Consider using the SetParent method instead, with the worldPositionStays argument set to false. This will retain local orientation and scale rather than world orientation and scale, which can prevent common UI scaling issues.
UnityEngine.Transform:set_parent (UnityEngine.Transform)

who knows how to solve?

What I have tried:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class SAveOnLoad : MonoBehaviour
{

public GameObject ChildObj;
void Start()
{
    ChildObj.transform.parent = null;
}
void Update()
{

DontDestroyOnLoad(ChildObj);
}
}
Posted
Updated 8-Sep-22 9:23am
v3

1 solution

Read the error text again - it tells you what to do:
Quote:
Consider using the SetParent method instead, with the worldPositionStays argument set to false.
It even tells you why ...
Quote:
This will retain local orientation and scale rather than world orientation and scale, which can prevent common UI scaling issues.


And in case of emergency, read the documentation: Unity - Scripting API: Transform.SetParent[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900