Question by
DJ_DiX · Sep 12, 2019 at 09:52 AM ·
custom editorenumpropertydrawer
Hide properties by enums in array element entries.
I need hide properties by fields "TaskType"(enum) and "Type"(enum). But custom Property Drawer can't serialize properties of array elements + i cant write any worked for this situation Custom Editor. Hope someone will can help with this problem. Task script:
using System;
using UnityEngine;
[Serializable]
public class UniversalTask
{
public string Description;
public bool Completed;
public int CurrentAmount;
public int RequiredAmount;
public enum taskType { Travel, Travel2 };
public taskType TaskType;
public bool one = false;
[Serializable]
public class TravelTask
{
public enum type { To, ForTime, ToForTime }
public type Type = type.To;
public bool one = false;
public Vector3 Point = new Vector3(0, 0, 0);
public float AreaRadius = 10;
// Need show when Type == type.ForTime
public float ForTime = 0;
}
// Need show when TaskType == taskType.Travel
public TravelTask Travel;
public TravelTask Travel2;
public UniversalTask(string Description, bool Completed, int CurrentAmount, int RequiredAmount)
{
this.Description = Description;
this.Completed = Completed;
this.CurrentAmount = CurrentAmount;
this.RequiredAmount = RequiredAmount;
}
public void Init() { /* Default init stuff */ }
public void Evaluate() { if (CurrentAmount >= RequiredAmount) Complete(); }
public void Complete() { Completed = true; }
}
Main Quest script:
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class UniversalQuest : MonoBehaviour
{
public List<UniversalTask> Tasks = new List<UniversalTask>();
public string QuestName;
public string Description;
public int ExperienceReward;
// public Item ItemReward { get; set; }
public bool Assigned;
public bool Completed;
public bool Selected;
public void CheckTasks()
{
Completed = Tasks.All(g => g.Completed);
}
}
Comment
Your answer
Follow this Question
Related Questions
Inheritance, List and PropertyDrawer,CustomPropertyDrawer and Inheritance 0 Answers
Inheritance, List and CustomPropertyDrawer 0 Answers
How to edit array/list property with custom PropertyDrawer? 3 Answers
Can't create custom propertydrawer for ScriptableObject 0 Answers
Is it possible to use separator / divider when displaying enum field in inspector? 1 Answer