Пример #1
0
 private void SetObjects(LE_ObjectMap p_objectMap)
 {
     if (OBJECT_BROWSER != null)
     {
         OBJECT_BROWSER.OnInnerNodeClick += (object p_object, uMyGUI_TreeBrowser.NodeClickEventArgs p_args) =>
         {
             AddButtonClickSoundsToGeneratedUI(OBJECT_BROWSER.transform as RectTransform);
         };
         OBJECT_BROWSER.OnLeafNodePointerDown += (object p_object, uMyGUI_TreeBrowser.NodeClickEventArgs p_args) =>
         {
             LE_Object selectedObj;
             string    selectedResourcePath;
             if (!m_nodeToObject.TryGetValue(p_args.ClickedNode, out selectedObj))
             {
                 Debug.LogError("LE_GUIInterface_uGUIimplDungeon: could not find selected node's object!");
             }
             if (!m_nodeToResourcePath.TryGetValue(p_args.ClickedNode, out selectedResourcePath))
             {
                 Debug.LogError("LE_GUIInterface_uGUIimplDungeon: could not find selected node's path!");
             }
             if (selectedObj != null && selectedResourcePath != null)
             {
                 LE_GUIInterface.Instance.OnObjectSelectDraggable(selectedObj, selectedResourcePath);
             }
         };
         OBJECT_BROWSER.OnNodeInstantiate += (object p_object, uMyGUI_TreeBrowser.NodeInstantiateEventArgs p_args) =>
         {
             // drag for leaf items
             if (p_args.Node.Children == null || p_args.Node.Children.Length == 0)
             {
                 // use GetComponentsInChildren instead of GetComponentInChildren as this is the only way to get inactive components in all Unity versions
                 uMyGUI_Draggable[] draggable = p_args.Instance.GetComponentsInChildren <uMyGUI_Draggable>(true);
                 if (draggable.Length > 0 && draggable[0] != null)
                 {
                     RawImage[] image = draggable[0].GetComponentsInChildren <RawImage>(true);
                     m_treeBrowserLeafNodes.Add(new LeafNodeInstance(draggable[0], image.Length > 0 ? image[0] : null));
                 }
             }
         };
         OBJECT_BROWSER.BuildTree(SetObjectsRecursive(p_objectMap, 0));
         AddButtonClickSoundsToGeneratedUI(OBJECT_BROWSER.transform as RectTransform);
     }
     else
     {
         Debug.LogError("LE_GUIInterface_uGUIimplDungeon: SetObjects: OBJECT_BROWSER is not set in inspector!");
     }
 }
Пример #2
0
        private uMyGUI_TreeBrowser.Node[] SetObjectsRecursive(LE_ObjectMap p_objectMap, int p_indentLevel)
        {
            List <uMyGUI_TreeBrowser.Node> nodes = new List <uMyGUI_TreeBrowser.Node>();

            // inner nodes
            for (int i = 0; i < p_objectMap.SubObjectMaps.Length; i++)
            {
                if (p_objectMap.SubObjectMaps[i] != null)
                {
                    LE_ObjectCategoryNode.SendMessageInitData data = new LE_ObjectCategoryNode.SendMessageInitData(p_objectMap.SubObjectMaps[i].name, p_indentLevel);
                    nodes.Add(new uMyGUI_TreeBrowser.Node(data, SetObjectsRecursive(p_objectMap.SubObjectMaps[i], p_indentLevel + 1)));
                }
                else
                {
                    Debug.LogError("LE_GUIInterface_uGUIimplDungeon: SetObjectsRecursive: sub object map from map '" + p_objectMap.name + "'" +
                                   " at index '" + i + "' is null!");
                }
            }
            // leafs
            for (int i = 0; i < p_objectMap.ObjectPrefabs.Length; i++)
            {
                if (p_objectMap.ObjectPrefabs[i] != null)
                {
                    LE_ObjectPrefabNode.SendMessageInitData data = new LE_ObjectPrefabNode.SendMessageInitData(p_objectMap.ObjectPrefabs[i], p_indentLevel);
                    uMyGUI_TreeBrowser.Node node = new uMyGUI_TreeBrowser.Node(data, null);
                    nodes.Add(node);
                    m_nodeToObject.Add(node, p_objectMap.ObjectPrefabs[i]);
                    m_nodeToResourcePath.Add(node, p_objectMap.ObjectPrefabResourcePaths[i]);
                }
                else
                {
                    Debug.LogError("LE_GUIInterface_uGUIimplDungeon: SetObjectsRecursive: object from map '" + p_objectMap.name + "'" +
                                   " at index '" + i + "' is null!");
                }
            }
            return(nodes.ToArray());
        }
Пример #3
0
        public LE_LogicObjects(LE_GUI3dObject p_GUI3dObject, LE_ObjectMap p_objectMap)
        {
            m_GUI3dObject = p_GUI3dObject;

            // register to events
            LE_GUIInterface.Instance.events.OnObjectEditSpaceBtn                  += OnObjectEditSpaceBtn;
            LE_GUIInterface.Instance.events.OnObjectEditModeBtn                   += OnObjectEditModeBtn;
            LE_GUIInterface.Instance.events.OnObjectSelectDraggable               += OnObjectSelectDraggable;
            LE_GUIInterface.Instance.events.OnSelectedObjectFocusBtn              += OnSelectedObjectFocusBtn;
            LE_GUIInterface.Instance.events.OnSelectedObjectDuplicateBtn          += OnSelectedObjectDuplicateBtn;
            LE_GUIInterface.Instance.events.OnSelectedPrefabFindBtn               += OnSelectedPrefabFindBtn;
            LE_GUIInterface.Instance.events.OnSelectedObjectDeleteBtn             += OnSelectedObjectDeleteBtn;
            LE_GUIInterface.Instance.events.OnSelectedObjectIsSleepOnStartChanged += OnSelectedObjectIsSleepOnStartChanged;
            LE_GUIInterface.Instance.events.OnSelectedObjectColorChanged          += OnSelectedObjectColorChanged;
            LE_GUIInterface.Instance.events.OnSelectedObjectVariationIndexChanged += OnSelectedObjectVariationIndexChanged;

            // initialize UI
            if (p_objectMap != null)
            {
                if (p_objectMap.ObjectPrefabs.Length > 0 || p_objectMap.ObjectPrefabResourcePaths.Length > 0 || p_objectMap.SubObjectMaps.Length > 0)
                {
                    if (LE_GUIInterface.Instance.delegates.SetObjects != null)
                    {
                        LE_GUIInterface.Instance.delegates.SetObjects(p_objectMap);
                    }
                    else
                    {
                        Debug.LogError("LE_LogicObjects: you have not set the LE_GUIInterface.delegates.SetObjects, but the provided object map is not empty. You have to set this delegate to update your object UI.");
                    }
                }
            }
            else
            {
                Debug.LogError("LE_LogicObjects: ROOT_OBJECT_MAP was not initialized! You need to set it in the inspector of LE_LevelEditorMain.");
            }

            m_GUI3dObject.ObjectEditMode = LE_EObjectEditMode.MOVE;

            // generate some warnings if needed
            if (LE_GUIInterface.Instance.delegates.SetIsSelectedObjectFocusBtnInteractable == null)
            {
                Debug.LogWarning("LE_LogicObjects: you have not set the LE_GUIInterface.delegates.SetIsSelectedObjectFocusBtnInteractable delegate! It might confuse players if you have a focus button, which is always clickable, but works only when an object is selected. Set this delegate to disable the focus button when no object is selected.");
            }
            if (LE_GUIInterface.Instance.delegates.SetIsSelectedObjectDuplicateBtnInteractable == null)
            {
                Debug.LogWarning("LE_LogicObjects: you have not set the LE_GUIInterface.delegates.SetIsSelectedObjectDuplicateBtnInteractable delegate! It might confuse players if you have a duplicate button, which is always clickable, but works only when an object can be duplicated. Set this delegate to disable the duplicate button when no object is selected or this object cannot be created (e.g. max. count reached in this level).");
            }
            if (LE_GUIInterface.Instance.delegates.SetIsSelectedObjectDeleteBtnInteractable == null)
            {
                Debug.LogWarning("LE_LogicObjects: you have not set the LE_GUIInterface.delegates.SetIsSelectedObjectDeleteBtnInteractable delegate! It might confuse players if you have a delete button, which is always clickable, but works only when an object is selected. Set this delegate to disable the delete button when no object is selected.");
            }
            if (LE_GUIInterface.Instance.delegates.SetIsSelectedObjectSleepPropertyInteractable == null)
            {
                Debug.LogWarning("LE_LogicObjects: you have not set the LE_GUIInterface.delegates.SetIsSelectedObjectSleepPropertyInteractable delegate! It might confuse players if you have a property menu, which is always editable, but applied only to some objects. Set this delegate to disable the 'Is Sleep On Start' property menu when the selected object does not support it.");
            }
            if (LE_GUIInterface.Instance.delegates.SetSelectedObjectIsSleepOnStartPropertyValue == null)
            {
                Debug.LogWarning("LE_LogicObjects: you have not set the LE_GUIInterface.delegates.SetIsSelectedObjectSleepPropertyValue delegate! The value of this property can change every time when an object is selected. Set this delegate to get updates for this property.");
            }
            if (LE_GUIInterface.Instance.delegates.SetIsSelectedObjectColorPropertyInteractable == null)
            {
                Debug.LogWarning("LE_LogicObjects: you have not set the LE_GUIInterface.delegates.SetIsSelectedObjectColorPropertyInteractable delegate! It might confuse players if you have a property menu, which is always editable, but applied only to some objects. Set this delegate to disable the 'Color' property menu when the selected object does not support it.");
            }
            if (LE_GUIInterface.Instance.delegates.SetSelectedObjectColorPropertyValue == null)
            {
                Debug.LogWarning("LE_LogicObjects: you have not set the LE_GUIInterface.delegates.SetSelectedObjectColorPropertyValue delegate! The value of this property can change every time when an object is selected. Set this delegate to get updates for this property.");
            }
            if (LE_GUIInterface.Instance.delegates.SetSelectedObjectVariationPropertyValue == null)
            {
                Debug.LogWarning("LE_LogicObjects: you have not set the LE_GUIInterface.delegates.SetSelectedObjectVariationPropertyValue delegate! The value of this property can change every time when an object is selected. Set this delegate to get updates for this property.");
            }
        }