I joined in a project, I wanna add new variables to a script but they do not show up in inspector. Variables do not show up in this specific script but they are appear on another script that I just create and copy them. Both are monobehaviour as shown in the pictures. Both scripts are in same directory.
CodePudding user response:
So, there was an editor script, which can manipulate the inspector view and draw PointOfInterest scipt in a custom way on inspector.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(PointOfInterest))]
public class POI_Inspector : Editor
{
private SerializedObject soTarget;
private PointOfInterest p;
private SerializedProperty experienceType;
private SerializedProperty video;
private SerializedProperty videoUrl;
private SerializedProperty LoadType;
private SerializedProperty youTubeUrl;
public SerializedProperty startTime;
public SerializedProperty endTime;
private SerializedProperty imageUrl;
private SerializedProperty subtitle;
private SerializedProperty backdrop360;
private SerializedProperty panoAnchorsCount;
private SerializedProperty experienceName;
private SerializedProperty latitude, longitude;
private SerializedProperty regionMap;
private SerializedProperty regionMapData;
private SerializedProperty image;
private SerializedProperty texture;
private SerializedProperty audioClip;
private SerializedProperty slides;
private SerializedProperty emissionMap;
private SerializedProperty emissionMaps;
private SerializedProperty panoPrefab;
private SerializedProperty assetUrlAndroid;
private SerializedProperty assetUrlIos;
private void OnEnable()
{
p = target as PointOfInterest;
soTarget = new SerializedObject(target);
experienceType = soTarget.FindProperty("experienceType");
// Video, Video360
video = soTarget.FindProperty("video");
videoUrl = soTarget.FindProperty("videoUrl");
LoadType = soTarget.FindProperty("videoLoadType");
youTubeUrl = soTarget.FindProperty("youTubeUrl");
startTime = soTarget.FindProperty("startTime");
endTime = soTarget.FindProperty("endTime");
imageUrl = soTarget.FindProperty("imageUrl");
subtitle = soTarget.FindProperty("subtitle");
// Panoguide
backdrop360 = soTarget.FindProperty("image");
panoPrefab = soTarget.FindProperty("panoPrefab");
experienceName = soTarget.FindProperty("experienceName");
latitude = soTarget.FindProperty("latitude");
longitude = soTarget.FindProperty("longitude");
regionMap = soTarget.FindProperty("regionMap");
regionMapData = soTarget.FindProperty("regionMapData");
image = soTarget.FindProperty("image");
texture = soTarget.FindProperty("texture");
audioClip = soTarget.FindProperty("audioClip");
slides = soTarget.FindProperty("slides");
emissionMap = soTarget.FindProperty("emissionMap");
emissionMaps = soTarget.FindProperty("emissionMaps");
assetUrlAndroid = soTarget.FindProperty("assetUrlAndroid");
assetUrlIos = soTarget.FindProperty("assetUrlIos");
}
public override void OnInspectorGUI()
{
//base.OnInspectorGUI();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(experienceType);
EditorGUILayout.Separator();
switch (p.experienceType)
{
case ExperienceType.VIDEO_360:
{
EditorGUILayout.PropertyField(LoadType);
switch (p.videoLoadType)
{
case global::LoadType.locally:
EditorGUILayout.PropertyField(video);
break;
case global::LoadType.remotly:
EditorGUILayout.PropertyField(videoUrl);
break;
}
EditorGUILayout.PropertyField(subtitle);
break;
}
case ExperienceType.VIDEO_2D:
{
EditorGUILayout.PropertyField(LoadType);
switch (p.videoLoadType)
{
case global::LoadType.locally:
EditorGUILayout.PropertyField(video);
break;
case global::LoadType.remotly:
EditorGUILayout.PropertyField(videoUrl);
break;
}
EditorGUILayout.PropertyField(subtitle);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(emissionMap);
break;
}
case ExperienceType.PANO_GUIDE:
{
EditorGUILayout.PropertyField(LoadType);
EditorGUILayout.PropertyField(panoPrefab);
break;
}
case ExperienceType.REGION_MAP:
{
EditorGUILayout.PropertyField(LoadType);
EditorGUILayout.PropertyField(regionMap);
EditorGUILayout.PropertyField(regionMapData);
break;
}
case ExperienceType.IMAGE_2D:
{
EditorGUILayout.PropertyField(LoadType);
EditorGUILayout.PropertyField(imageUrl);
EditorGUILayout.PropertyField(image);
EditorGUILayout.PropertyField(audioClip);
EditorGUILayout.PropertyField(subtitle);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(emissionMap);
break;
}
case ExperienceType.IMAGE_360:
{
EditorGUILayout.PropertyField(LoadType);
EditorGUILayout.PropertyField(imageUrl);
EditorGUILayout.PropertyField(image);
EditorGUILayout.PropertyField(audioClip);
EditorGUILayout.PropertyField(subtitle);
break;
}
case ExperienceType.SLIDE_SHOW:
{
EditorGUILayout.PropertyField(LoadType);
EditorGUILayout.PropertyField(slides);
EditorGUILayout.PropertyField(audioClip);
EditorGUILayout.PropertyField(subtitle);
EditorGUILayout.Space();
EditorGUILayout.PropertyField(emissionMap);
break;
}
case ExperienceType.YOUTUBE:
{
EditorGUILayout.PropertyField(youTubeUrl);
EditorGUILayout.PropertyField(startTime);
EditorGUILayout.PropertyField(endTime);
break;
}
case ExperienceType.Asset3D:
{
EditorGUILayout.PropertyField(assetUrlAndroid);
EditorGUILayout.PropertyField(assetUrlIos);
break;
}
case ExperienceType.AUDIO:
{
EditorGUILayout.PropertyField(audioClip);
break;
}
}
if (p.emissionMap)
{
EditorGUILayout.PropertyField(emissionMaps);
}
if (EditorGUI.EndChangeCheck())
{
soTarget.ApplyModifiedProperties();
GUI.FocusControl(null);
}
}
}