コード例 #1
0
    public override void OnInspectorGUI()
    {
        MovementStateMachine tar = target as MovementStateMachine;

        var playerProp = serializedObject.FindProperty(tar.PlayerPropertyName);

        EditorGUILayout.ObjectField(playerProp, new GUIContent("Player: "));

        MovementStateMachineData data = tar.Data;

        data = EditorGUILayout.ObjectField("Data:", data, typeof(MovementStateMachineData), false) as MovementStateMachineData;

        if (data != null)
        {
            tar.MovementStateMachineDataAssetPath = AssetDatabase.GetAssetPath(data);
        }

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Save"))
        {
            MovementStateMachineData.Save(tar);
        }
        if (GUILayout.Button("Reload"))
        {
            tar.ReloadFromData();
        }
        EditorGUILayout.EndHorizontal();
    }
コード例 #2
0
    private void Draw()
    {
        EntityEdited = EditorGUILayout.ObjectField("Editing", EntityEdited, typeof(MovementStateMachine), true) as MovementStateMachine;

        if (EntityEdited != null)
        {
            prefabAssetPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(EntityEdited);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Movement Options For Entity:");
            EditorGUI.indentLevel += 1;
            for (int i = EntityEdited.GeneralMovementOptions.Count - 1; i >= 0; i--)
            {
                var opt = EntityEdited.GeneralMovementOptions[i];
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(opt.Name);
                if (GUILayout.Button("X"))
                {
                    EntityEdited.RemoveGeneralMovementOption(opt);
                    Save();
                }

                EditorGUILayout.EndHorizontal();
            }
            EditorGUI.indentLevel -= 1;

            if (GUILayout.Button("Add General Movement Option"))
            {
                AddGeneralMovementOption();
            }
            string buttonText = EntityEdited.IsLoaded ? "Reload" : "Load";
            if (GUILayout.Button(buttonText))
            {
                EntityEdited.ReloadFromData();
                OnEntityReloaded?.Invoke();
            }
        }
    }