playMaker

Author Topic: CustomActionEditor and Dll load error  (Read 1484 times)

LudlowFx

  • Guest
CustomActionEditor and Dll load error
« on: March 07, 2015, 04:57:49 PM »
Hi,

So I talked a little bit on another topic, but I prefer to restart to make it a cleaner (and the subject differs slightly).

I built my first CustomActionEditor, I have a little too much hassle because of a dll worry I will explain below. So, as this is my first CustomActionEditor I have a quick question or two.
(See the code below) Is the structure used is correct ? Given that this code will be part of my add-on, I prefer to take my time and work on it if I got caught badly.

Then, in relation to CustomActionEditor and EditorGuiLayout I just noticed a small detail that bothers me. Normally I use in my ActionScript [Tooltip ("Description")] to give information about the variable. But because of the ActionEditor my Tooltip no longer works.

Is it possible to add a Tooltip in CustomActionEditor? I would like on my "EditorGUILayout.Popup" but I have not succeeded and I'm a bit lost suddenly. And RequiredField too... :!

PS: Everything in this "OnEnable ()" is the code used from another asset enabling me to retrieve a List <> containing all existing and used by SmartLocalization languages.
Code: [Select]
using UnityEngine;
using UnityEditor;

using SmartLocalization;
using SmartLocalization.Editor;
using HutongGames.PlayMaker.Actions;

namespace HutongGames.PlayMakerEditor
{
    using HutongGames.PlayMaker.Actions;
    [CustomActionEditor(typeof(ChangeCurrentLanguage))]
    public class ChangeCurrentLanguageActionEditor : CustomActionEditor
    {
        private SmartCultureInfo[] availableCultures;
        private string[] availableCulturesPopup, availableCulturesCodename;

        public override void OnEnable()
        {
            var _allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
            var _availableCultures = LanguageHandlerEditor.CheckAndSaveAvailableLanguages(_allCultures);

            availableCultures = _availableCultures.cultureInfos.ToArray();
            availableCulturesPopup = new string[availableCultures.Length];
            availableCulturesCodename = new string[availableCultures.Length];

            for (var i = 0; i < availableCultures.Length; i++)
            {
                availableCulturesPopup[i] = availableCultures[i].englishName;
                availableCulturesCodename[i] = availableCultures[i].languageCode;
            }
        }

        public override bool OnGUI()
        {
            ChangeCurrentLanguage myTarget = (ChangeCurrentLanguage)target;

            myTarget.availableCulturesCdnArray = availableCulturesCodename;
            myTarget.selectLanguageIndex = EditorGUILayout.Popup("Select Language", myTarget.selectLanguageIndex, availableCulturesPopup);


            //## Error warnings
            if (availableCultures.Length == 0)
                EditorGUILayout.HelpBox("No language is available. Use SmartLocalization tool to create a language.", MessageType.Error);

            else if (myTarget.selectLanguageIndex > availableCultures.Length)
                EditorGUILayout.HelpBox("Watch Out ! This Action returns an index that does not exist. You must select a language.", MessageType.Error);
            //## Error warnings


            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Refresh List"))
                OnEnable();

            if (GUILayout.Button("Manage languages"))
                EditorWindow.GetWindow(typeof(SmartLocalization.Editor.SmartLocalizationWindow));

            GUILayout.EndHorizontal();
            EditorGUILayout.Space();


            EditField("assignTo");
            EditField("sendEvent");

            return GUI.changed;
        }
    }
}

Thank you for your time and your future answers. Now I would like to talk about a very annoying issue.

At first, I had errors everywhere because CustomActionEditor was considered "non-existent" in my code editor. Actually, I've realized that the problem was that just PlayMakerEditor.dll was not loaded in my code editor.

I use Unity 5 and when I click in Unity "Sync Monodevelop Project" Unity forgotten to load PlayMakerEditor.dll in the project so I always have to add it manually which is very annoying. A friend tried it on his computer and Unity 5, and of course it was not the problem.

I tried on Unity 4.6 and magic the problem is not there. So this is my version of Unity 5 specifically problematic ... I uninstalled and reinstalled, nothing changes.

Do you have any idea why this happens? If this has happened to anyone, thank you kindly help me.

Thank you for taking the time to read everything written extensively sorry ^^ "

Best Regards,
LudlowFx

Edit: I think on the Wiki page "Custom Action Editor", you use GUILayout. Me, EditorGUILayout. Is the way you prefer?

« Last Edit: March 08, 2015, 01:12:12 AM by LudlowFx »