Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Hide properties by enums in array elements?

Discussion in 'Scripting' started by DJ_DiX, Sep 11, 2019.

  1. DJ_DiX

    DJ_DiX

    Joined:
    Aug 1, 2017
    Posts:
    3
    Hello.
    How hide some properties of array elements by enum values in this elements?

    Have main script:

    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using UnityEngine;
    5.  
    6. [Serializable]
    7. public partial class Quest : MonoBehaviour
    8. {
    9.     public List<Task> Tasks = new List<Task>();
    10. }
    Script of Task:

    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3.  
    4. [Serializable]
    5. public class Task
    6. {
    7.     public enum taskType { Travel, Travel2 };
    8.     public taskType TaskType;
    9.  
    10.     [Serializable]
    11.     public class TravelTask
    12.     {
    13.         public enum type { To, ForTime, ToForTime }
    14.         public type Type = type.To;
    15.         public bool one = false;
    16.         public Vector3 Point = new Vector3(0, 0, 0);
    17.         public float AreaRadius = 10;
    18.         // Need show when Type == type.ForTime
    19.         public float ForTime = 0;
    20.     }
    21.     // Need show when TaskType == taskType.Travel
    22.     public TravelTask Travel;
    23. }
    How i can hide properties of Task and Task.Travel by their inner enums?
    Custom Property Drawers dont work with inner properties of array elements((
     
    Last edited: Sep 11, 2019
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    709
    Write a property drawer for the TravelTask and Task classes.
     
  3. DJ_DiX

    DJ_DiX

    Joined:
    Aug 1, 2017
    Posts:
    3
    I need an example for this.
    All property drawers that I saw before - was not tied to any class.
     
  4. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,265
    DJ_DiX likes this.