#Codex help

1 messages · Page 1 of 1 (latest)

lean cape
#

Hi, you meant making a thread like this? @hardy robin

hardy robin
#

yea, re describing the current issue is usually whats done first

lean cape
#

well, im trying to make a Codex for my game, y'know like HollowKnight's Journal, Doom Eternal Codex

but ended up more complex than i thought, i followed a tutorial, i think you posted it i dont remember,

but now when i close the UI triggers that error
and a entry i deleted all ways of unlocking remains unlocked

#

SO


[CreateAssetMenu(fileName = "CassielDictando", menuName = "Cassiel/Journal Entry")]
public class CassielEntrySO : ScriptableObject
{
    public Sprite Foto;
    public string Nombre;
    public string descripcion;
    public int categoria;
}
hardy robin
#

You save and reload the data from PlayerPrefs so the first question is do you clear this when you want to clear the data?

lean cape
#

wat

lean cape
#

data should go when i close the game

#

and then reappear when i test it again

#

thats why its used saving-methods, for prevent this

hardy robin
#

player prefs is persistent so it wont go away unless YOU change it

lean cape
#

player prefs?

hardy robin
#

Do you not even know what its doing in ValeriaMemories.SaveUnlocks() ??

lean cape
#

the preferences

#

oh right

#

holup lemme

#

ah yeah

#

i thought it was like a more polished way to save it pergame

#

i didnt thought would well, be permanent......

interesting...............

#

anyways
then what i should do?

lean cape
hardy robin
#

On windows playerprefs gets stored in the registry. But if you dont want this data to be kept between game sessions just remove this code

#

It should be obvious

#

Why did you add this in the first place?

lean cape
#

for the UX i want it to be permanent

#

for the DX

#

no

hardy robin
#

unity has a menu option to clear player prefs for your project

lean cape
#

really?

hardy robin
#

so you can use that to "reset your data"

lean cape
#

also btw, how do fully the player prefs saving works, i can save, EVERYTHING?

hardy robin
#

I forget where it is

lean cape
#

i mean cuz also something i been trying to investigate is, how to save

#

is a long game

#

i mean, it will be

hardy robin
#

player prefs can hold the major core data types so it would be up to you to save what you need to restore game state later

#

its not recommended however and most people instead use something like json to save + load data.
If you wanted to release the game on steam for example and use cloud save, you would need to stop using player prefs.

lean cape
#

ok

#

how json save works?

#

also, if i use json saves i would also have to modify this code right?

hardy robin
#

yea you would but perhaps thats too complex for you to do at this moment

lean cape
#

ok

lean cape
hardy robin
#

er probably fine there I don't think they have cloud saves right?

lean cape
#

yeah

hardy robin
#

its still not great because its not easy for the general user to back up/move save files if the data is in the registry

#

anyway, can you paste this error you get?

lean cape
#

MissingReferenceException: The object of type 'UnityEngine.RectTransform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.

hardy robin
#

everything plz including the stack trace

lean cape
#

ok

#

MissingReferenceException: The object of type 'UnityEngine.RectTransform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at <b5bf0c891ea345fe93688f835df32fdc>:0)
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at <b5bf0c891ea345fe93688f835df32fdc>:0)
UnityEngine.RectTransform.get_anchoredPosition () (at <b5bf0c891ea345fe93688f835df32fdc>:0)
UnityEngine.UI.ScrollRect.SetNormalizedPosition (System.Single value, System.Int32 axis) (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/UI/Core/ScrollRect.cs:1071)
UnityEngine.UI.ScrollRect.SetVerticalNormalizedPosition (System.Single value) (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/UI/Core/ScrollRect.cs:1055)
UnityEngine.Events.InvokableCall1[T1].Invoke (T1 args0) (at <b5bf0c891ea345fe93688f835df32fdc>:0) UnityEngine.Events.UnityEvent1[T0].Invoke (T0 arg0) (at <b5bf0c891ea345fe93688f835df32fdc>:0)
UnityEngine.UI.Scrollbar.Set (System.Single input, System.Boolean sendCallback) (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/UI/Core/Scrollbar.cs:248)
UnityEngine.UI.Scrollbar.set_value (System.Single value) (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/UI/Core/Scrollbar.cs:91)
UnityEngine.UI.ScrollRect.UpdateScrollbars (UnityEngine.Vector2 offset) (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/UI/Core/ScrollRect.cs:933)
UnityEngine.UI.ScrollRect.Rebuild (UnityEngine.UI.CanvasUpdate executing) (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/UI/Core/ScrollRect.cs:540)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at ./Library/PackageCache/com.unity.ugui/Runtime/UGUI/UI/Core/CanvasUpdateRegistry.cs:181)
UnityEngine.Canvas:SendWillRenderCanvases()

hardy robin
#

Huh thats not even from your code, did you destroy the scroll rect content object?

lean cape
#

the what

hardy robin
#

the "Content" object of Scrol rect

lean cape
#

o h

#

yes it does

#

i dont know why tho

#

i think i coded something wrong

hardy robin
#

probably your ClearContent() function

#

but that looks okay actually 🤔

lean cape
#

i had the vertical group layout on the viewport instead on the contet

#

do it should be on the content?

#

and well, reference the content as the one with the buttons

#

instead of the viewport

hardy robin
#

Yes it should be on the content object

lean cape
#

good

hardy robin
#

Content is what holds the stuff to move around in the scroll view

lean cape
#

how i can move it

#

i mean, looks weird

#

verticall is easy, but the reason is on the right, why?

hardy robin
#

Your content object should have the Vertical layout component + Content size fitter (with vertical set to preferred size)
You should spawn the buttons as children of the content object.

lean cape
#

i thought it did

hardy robin
#

I can't see your objects so Im just saying what It should be

lean cape
#

for a weird reason when i put upper-center goes to center...but when i put upper-right goes to left
i mean, i can just put it to upper-center, but this is seems sus

hardy robin
#

alignment shouldnt matter if using content size fitter (which you are not)
Why do we want this? We want the content to auto size its height to fit the buttons

#

done with unity 6

lean cape
#

thanks :3

honest python