Ejemplo n.º 1
0
    void Awake()
    {
        if (luafun_OnSelect == null)
        {
            luaEnv = LuaManager.GetInstance().LuaEnvGetOrNew();
            //luaEnv = new LuaEnv();

            if (onSelectFunName == null || onSelectFunName.Equals(""))
            {
                luaEnv.DoString(script);

                luafun_OnSelect = luaEnv.Global.GetInPath <OnSelectItem> ("OnSelectItem");
                luafun_UnSelect = luaEnv.Global.GetInPath <OnSelectItem> ("OnSelectItem");
            }
            else
            {
                luafun_OnSelect = luaEnv.Global.GetInPath <OnSelectItem> (onSelectFunName);
                luafun_UnSelect = luaEnv.Global.GetInPath <OnSelectItem> (unSelectFunName);
            }
        }
        img = this.GetComponent <Image>();
        OnSelectItem luafun_UILoopItem_Awake = luaEnv.Global.GetInPath <OnSelectItem>(awakefunctionName);

        if (luafun_UILoopItem_Awake != null)
        {
            luafun_UILoopItem_Awake(index, transform, GetData());
        }
    }
Ejemplo n.º 2
0
    private void Awake()
    {
        if (luafun_UILoopItem_Set == null)
        {
            luaEnv = LuaManager.GetInstance().LuaEnvGetOrNew();
            if (functionName == null && functionName.Equals(""))
            {
                luafun_UILoopItem_Set = luaEnv.Global.GetInPath <UILoopItem_Set>("UILoopItem_Set");
            }
            else
            {
                luafun_UILoopItem_Set = luaEnv.Global.GetInPath <UILoopItem_Set>(functionName);
            }
        }
        if (isAutoListener)
        {
            Button[]    btns  = this.transform.GetComponentsInChildren <Button>();
            SelectGroup group = this.transform.parent.GetComponent <SelectGroup>();
            group.AddItem(this);
            foreach (Button btn in btns)
            {
                btn.onClick.AddListener(() => { group.SelectByIndex(this.index); });
            }
        }
        if (luafun_OnSelect == null)
        {
            luaEnv = LuaManager.GetInstance().LuaEnvGetOrNew();
            //luaEnv = new LuaEnv();

            if (onSelectFunName == null || onSelectFunName.Equals(""))
            {
                //luaEnv.DoString(script);

                luafun_OnSelect = luaEnv.Global.GetInPath <OnSelectItem>("OnSelectItem");
                luafun_UnSelect = luaEnv.Global.GetInPath <OnSelectItem>("UnSelectItem");
            }
            else
            {
                luafun_OnSelect = luaEnv.Global.GetInPath <OnSelectItem>(onSelectFunName);
                luafun_UnSelect = luaEnv.Global.GetInPath <OnSelectItem>(unSelectFunName);
            }
        }

        UILoopItem_Set luafun_UILoopItem_Awake = luaEnv.Global.GetInPath <UILoopItem_Set>(awakefunctionName);

        if (luafun_UILoopItem_Awake != null)
        {
            luafun_UILoopItem_Awake(itemIndex, transform, GetData());
        }
    }
Ejemplo n.º 3
0
        private void DisplayOneItem(Object toDisplay, string nameInListPath, int index, float width, bool disable)
        {
            if (toDisplay == null && string.IsNullOrEmpty(nameInListPath))
            {
                return;
            }

            if (toDisplay == null && !UnityEssentialsPreferences.GetBool(UnityEssentialsPreferences.SHOW_GAMEOBJECTS_FROM_OTHER_SCENE, true))
            {
                return;
            }

            GUI.color = (PeekSerializeObject.LastSelectedObject == toDisplay && toDisplay != null) ? Color.green : Color.white;

            EditorGUI.BeginDisabledGroup(disable);
            {
                using (HorizontalScope horizontalScope = new HorizontalScope(GUILayout.Width(width), GUILayout.Height(_heightLine)))
                {
                    float widthExtent = CalculateWidthExtentOptions.CalculateWidthExtent(width, index, ListToDisplay.arraySize);
                    float widthButtonWithoutExtent = CalculateWidthExtentOptions.CalculateButtonWidthWithoutExtent(widthExtent, _heightLine, _margin);

                    if (_calculateExtent)
                    {
                        GUILayout.Label("", GUILayout.Width(widthExtent), GUILayout.Height(_heightLine));
                    }
                    //display bookmark button
                    bool clicOnBookMark = BookMarkButtonOptions.ButtonImageWithHover(WIDTH_BUTTON_HOVER, toDisplay != null, _heightLine);
                    if (clicOnBookMark)
                    {
                        OnBookMarkClic?.Invoke(index);
                        return;
                    }
                    //display main logo
                    DisplayLogoByTypeOfObject(toDisplay, _heightLine);
                    if (!disable && !_dragSettings.IsDragging)
                    {
                        Rect logoContent = GUILayoutUtility.GetLastRect();
                        if (logoContent.Contains(Event.current.mousePosition))
                        {
                            EditorGUIUtility.AddCursorRect(logoContent, MouseCursor.MoveArrow);
                            if (Event.current.type == EventType.MouseDown)
                            {
                                _listToDisplayCopy = ListToDisplay.ToObjectList();
                                _dragSettings.StartDragging(index, logoContent);
                                Event.current.Use();
                            }
                        }
                    }
                    //display main button
                    EditorGUI.BeginDisabledGroup(toDisplay == null);
                    {
                        string nameObjectToSelect;
                        if (toDisplay == null)
                        {
                            nameObjectToSelect = !string.IsNullOrEmpty(nameInListPath) ? ObjectNames.NicifyVariableName(nameInListPath) : " --- not found --- ";
                        }
                        else
                        {
                            nameObjectToSelect = ObjectNames.NicifyVariableName(toDisplay.name);
                        }


                        GUIContent buttonSelectContent = ShortenNameIfNeeded(nameObjectToSelect, width, widthButtonWithoutExtent);
                        buttonSelectContent.tooltip = "Clic to select, Right clic to Pin only";
                        if (GUILayout.Button(buttonSelectContent, BookMarkButtonOptions.GuiStyle, GUILayout.ExpandWidth(true), GUILayout.Height(_heightLine)))
                        {
                            if (Event.current.button == 0)
                            {
                                OnSelectItem?.Invoke(index);
                            }
                            else
                            {
                                OnPinItem?.Invoke(index);
                            }
                            return;
                        }
                    }
                    EditorGUI.EndDisabledGroup();

                    //display special scene buttons
                    if (toDisplay == null && OnInfoItem != null)
                    {
                        bool selectScene = false;
                        bool goToScene   = false;

                        DisplaySpecialSceneSettings(ref selectScene, ref goToScene);
                        if (goToScene)
                        {
                            OnInfoForceItem?.Invoke(index);
                            return;
                        }
                        else if (selectScene)
                        {
                            OnInfoItem?.Invoke(index);
                            return;
                        }
                    }

                    //display delete button
                    GUIContent buttonDeletContent = EditorGUIUtility.IconContent(DELETE_ICON);
                    buttonDeletContent.tooltip = "Remove from list";
                    if (GUILayout.Button(buttonDeletContent, BookMarkButtonOptions.GuiStyle, GUILayout.ExpandWidth(false), GUILayout.MaxWidth(WIDTH_BUTTON_HOVER), GUILayout.Height(_heightLine)) &&
                        Event.current.button == 0)
                    {
                        OnRemoveItem?.Invoke(index);
                        return;
                    }
                    if (_calculateExtent)
                    {
                        GUILayout.Label("", GUILayout.Width(widthExtent), GUILayout.Height(_heightLine));
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
        }