Type casting SerializedProperty.objectReferenceValue doesn't work?

public class Achievement
{
public string description;
public bool status;
}

    public class AchievementsManager : MonoBehaviour 
    {
       public Achievement ach = new Achievement();
    }
    
    ////////////////////////////THE PART WHERE I GET MY PROBLEM///////////////////////////////
    
    
    
    using UnityEditor;
    using UnityEngine;
    using System.Collections;
    
    [CustomEditor (typeof(AchievementsManager))]
    public class AchievementsEditor : Editor 
    {
    	SerializedObject m_object;
    	SerializedProperty m_achievement;
    	public void OnEnable () 
    	{
    		m_object = new SerializedObject(target);
    		m_achievement = m_object.FindProperty("ach");
    	}
    
    	public override void OnInspectorGUI ()
    	{
    		m_object.Update();
**//////////////I cannot type cast the m_achievement.objectReferenceValue in the next line to Achievement. BUt i saw something like that in a video//////////**
    		var temp = m_achievement.objectReferenceValue as Achievement;
    		m_object.ApplyModifiedProperties();
    	}
    
    }

Achievement is not a derivative of UnityEngine.Object; it derives from System.Object, and thus the compiler cannot convert them porperly.

To fix this, you have the rather strange, non-Unity way of:

Achievement temp = m_achievement.objectReferenceValue as System.Object as Achievement;

or alternatively make your Achievement derive from ScriptableObject.

You can get the property from the target:

Achievement  temp = (AchievementsManager)target.ach as Achievement;

After your operations on temp, you can serialize target again and copy the value to serialzedObject:

serializedObject.CopyFromSerializedProperty(new SerializedObject(target).FindProperty("ach"));

If you just want to display the properties, you can use:

SerializedProperty descriptionProperty = m_achievement.FindPropertyRelative("description");
EditorGUILayout.PropertyField(descriptionProperty);