Hi everyone, I have a problem, that I can’t store the list “distances” inside my serializable class. The UnityEditor “forgets” it after a cycle. The class RAYpoint on the other hand is stored ,therefore I can get x,y,z. Guess its a problem with list in general. I tried some solutions offered by other users, sadly so far, I didn’t get it to work. Hope someone can point me in the right direction. Cheers
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[System.Serializable]
public class RAYpoint{
public RAYpoint(Vector3 vec) { vector = vec; }
public Vector3 vector;
public bool updated = false;
[SerializeField]
public List<_DistancePoint> distances = new List<_DistancePoint>();
public RAYpoint[] neighbors = new RAYpoint[0];
public void reset(){
distances = new List<_DistancePoint>();
neighbors = new RAYpoint[0];
}
public RAYpoint[] GetNeighbors(){
if (!updated) {
SortDistance ();
neighbors = new RAYpoint[distances.Count];
for(int i = 0; i < distances.Count; i++){
neighbors _= distances*.point;*_
* }*
* }*
* return neighbors;*
* }*
* public void AddDistance(float distance, RAYpoint point){*
* updated = false;*
* if (distances == null) {*
* distances = new List<DistancePoint>();
_ }*
* distances.Add (new DistancePoint (distance, point));
_ }*
* public void SortDistance(){*
* if (!updated) {*
* distances.Sort(*
* delegate(_DistancePoint p1, DistancePoint p2) {
_ return p1.distance.CompareTo (p2.distance);*
* });*
* }*
* updated = true;*
* }*
* public float x {*
* get {*
* return vector.x;*
* }*
* set*
* {*
* vector = new Vector3(value, vector.y, vector.z);*
* }*
* }*
* public float y {*
* get {*
* return vector.y;*
* }*
* set*
* {*
* vector = new Vector3(vector.x, value , vector.z);*
* }*
* }*
* public float z {*
* get {*
* return vector.z;*
* }*
* set*
* {*
* vector = new Vector3(vector.x, vector.y, value);*
* }*
* }*
* public static implicit operator Vector3(RAYpoint obj){*
* return obj.vector;*
* }*
* // User-defined conversion from double to Digit*
* public static implicit operator RAYpoint(Vector3 vector){*
* return new RAYpoint(vector);*
* }*
* public override string ToString(){*
* return vector.ToString();*
* }*
_ /**************************************/_
* [System.Serializable]*
* public class _DistancePoint{*
* public float distance { get; set; }*
* public RAYpoint point { get; set; }*
* public _DistancePoint(float distance, RAYpoint point){*
* this.distance = distance;*
* this.point = point;*
* }*
* public override string ToString(){*
* return "Distance: " + distance + " Point: " + point;*
* }*
* }*
}