Exemple #1
0
 protected void DrawSimpleObjectField <ObjT>(FuncObjBase fo, string label, ref ObjT value,
                                             float defaultLabelWidth = 80f) where ObjT : UnityEngine.Object
 {
     EditorGUILayout.BeginHorizontal();
     {
         EditorGUILayout.LabelField(label, GUILayout.Width(defaultLabelWidth));
         var input = EditorGUILayout.ObjectField(value, typeof(ObjT), true) as ObjT;
         if (input != value)
         {
             Undo.RegisterCompleteObjectUndo(fo, label + " Change");
             value = input;
             EditorUtility.SetDirty(fo);
         }
     }
     EditorGUILayout.EndHorizontal();
 }
Exemple #2
0
 protected void DrawSimpleBoolField(FuncObjBase fo, string label, ref bool value,
                                    float defaultLabelWidth = 80f)
 {
     EditorGUILayout.BeginHorizontal();
     {
         EditorGUILayout.LabelField(label, GUILayout.Width(defaultLabelWidth));
         var input = EditorGUILayout.Toggle(value);
         if (input != value)
         {
             Undo.RegisterCompleteObjectUndo(fo, label + " Change");
             value = input;
             EditorUtility.SetDirty(fo);
         }
     }
     EditorGUILayout.EndHorizontal();
 }
Exemple #3
0
        protected void DrawSimpleEnumField <EnumT>(FuncObjBase fo, string label, ref EnumT value,
                                                   float defaultLabelWidth = 80f) where EnumT : struct
        {
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField(label, GUILayout.Width(defaultLabelWidth));

                // @TODO cache
                // var input = EditorGUILayout.EnumPopup(value) as EnumT; // これで通ればなぁ...
                var enumPopup = typeof(EditorGUILayout).GetMethod("EnumPopup", BindingFlags.Static | BindingFlags.Public, null, new System.Type[] { typeof(System.Enum), typeof(GUILayoutOption[]) }, null);
                var input     = (EnumT)enumPopup.Invoke(null, new object[] { value, null });
                if (!input.Equals(value))
                {
                    Undo.RegisterCompleteObjectUndo(fo, label + " Change");
                    value = input;
                    EditorUtility.SetDirty(fo);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
Exemple #4
0
        /*=================================================================================================*/

        protected virtual void DrawInvokeMenu(FuncObjBase fo)
        {
            DrawSimpleLabelField("Invoke Menu");
            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Invoke", EditorStyles.miniButton))
                {
                    m_callbackQueue.Push(async() => {
                        m_isTermPollCallbackQueue = true;
                        await fo.Invoke();
                        EditorUtility.DisplayDialog(fo.ToString() + "::Invoke", "Complete", "OK");
                    });
                    m_isTermPollCallbackQueue    = false;
                    EditorApplication.delayCall += PollCallbackQueue;
                }
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5);
            //GUILayout.Box(GUIContent.none, HrStyle.EditorLine, GUILayout.ExpandWidth(true), GUILayout.Height(1f));
            //GUILayout.Space(5);
        }