Example #1
0
        protected override void OnEnable()
        {
            base.OnEnable();

            rootVisualElement.styleSheets.Add(Resources.Load <StyleSheet>(MainStyleSheet));

            VisualTreeAsset mainVisualTree = Resources.Load <VisualTreeAsset>(WindowLayout);

            mainVisualTree.CloneTree(rootVisualElement);

            ProjectManifest manifest = new ProjectManifest();

            manifest.Read();

            _behaviorMode = rootVisualElement.Q <EnumField>("enum-behavior-mode");
            _behaviorMode.Init(EditorBehaviorMode.Mode3D);
            _behaviorMode.value = EditorSettings.defaultBehaviorMode;

            _productName       = rootVisualElement.Q <TextField>("text-product-name");
            _productName.value = PlayerSettings.productName;

            _productVersion       = rootVisualElement.Q <TextField>("text-product-version");
            _productVersion.value = PlayerSettings.bundleVersion;

            _useSpine       = rootVisualElement.Q <Toggle>("toggle-feature-spine");
            _useSpine.value = manifest.UseSpine;

            _useDOTween       = rootVisualElement.Q <Toggle>("toggle-feature-dotween");
            _useDOTween.value = manifest.UseDOTween;

            _useNetworking       = rootVisualElement.Q <Toggle>("toggle-feature-networking");
            _useNetworking.value = manifest.UseNetworking;
        }
    VisualTreeAsset SetUpEnemy()
    {
        VisualTreeAsset aAsset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/UXML Files/EnemyEditor.uxml");

        mCurrentObjectElement     = aAsset.CloneTree();
        mEnAttackSound            = mCurrentObjectElement.Q <ObjectField>("enemy_attack_sound");
        mEnAttackSound.objectType = typeof(AudioClip);
        mEnAttackSound.RegisterCallback <ChangeEvent <Object> >((aEv) => GenHelpers.OnAttackSoundSelection((AudioClip)aEv.newValue, mEnAttackSound));
        mEnDeathSound            = mCurrentObjectElement.Q <ObjectField>("enemy_death_sound");
        mEnDeathSound.objectType = typeof(AudioClip);
        mEnDeathSound.RegisterCallback <ChangeEvent <Object> >((aEv) => GenHelpers.OnDeathSoundSelection((AudioClip)aEv.newValue, mEnDeathSound));
        mEnemyType = mCurrentObjectElement.Q <EnumField>("enemy_type");
        mEnemyType.Init(Enemy.Type.Collider);
        mEnemyType.RegisterCallback <ChangeEvent <System.Enum> >((aEv) => OnEnemyTypeChanged((Enemy.Type)aEv.newValue));
        mEnProjectile            = mCurrentObjectElement.Q <ObjectField>("enemy_projectile");
        mEnProjectile.objectType = typeof(Projectile);
        mEnProjectile.RegisterCallback <ChangeEvent <Object> >((aEv) => GenHelpers.OnEnemyProjectileSelection((Projectile)aEv.newValue, mEnProjectile));
        mEnemyAnimList = new ReorderableList(new List <AnimationData>(), typeof(AnimationData));
        mEnemyAnimList.drawHeaderCallback = (Rect aRect) =>
        {
            EditorGUI.LabelField(aRect, "Move Animation Sprites");
        };
        mEnemyAnimList.drawElementCallback = UpdateEnemyAnimationList;
        mEnemyAnimList.onAddCallback       = AddNewAnimation;
        mCurrentObjectElement.Q <IMGUIContainer>("enemy_animation_sprites").onGUIHandler = EnemyOnGUI;
        return(aAsset);
    }
    private void ShowFoodItemEditor()
    {
        rootVisualElement.Clear();

        var visualTree = Resources.Load <VisualTreeAsset>(foodItemTreePath);

        visualTree.CloneTree(rootVisualElement);

        // Setup food item editor screen
        Button       createItemButton = rootVisualElement.Q(name: "base-item-data-create-button") as Button;
        TextField    itemNameField    = rootVisualElement.Q(name: "item-data-name") as TextField;
        IntegerField itemValueField   = rootVisualElement.Q(name: "item-data-value") as IntegerField;
        TextField    itemDescField    = rootVisualElement.Q(name: "item-data-desc") as TextField;

        EnumField itemTypeField = rootVisualElement.Q(name: "item-data-type") as EnumField;

        itemTypeField.Init(workingItemType);

        EnumField itemRarityField = rootVisualElement.Q(name: "item-data-rarity") as EnumField;

        itemRarityField.Init(RarityType.Common);

        ObjectField itemIconField = rootVisualElement.Q(name: "item-data-icon") as ObjectField;

        itemIconField.objectType = typeof(Sprite); // Set the object fields type.

        if (createItemButton != null)
        {
            createItemButton.clickable.clicked += () =>
            {
                FoodItemData itemData = new FoodItemData(itemNameField.value, itemDescField.value, itemValueField.value, workingItemType, (RarityType)itemRarityField.value, (Sprite)itemIconField.value);
                CreateFoodItem(itemData);
            };
        }
    }
        public override VisualElement CreateInspectorGUI()
        {
            var rootView = new VisualElement();

            string pathUxml = PackagePath + "Editor/MeshSubdivisionRenderer.uxml";
            string pathUss  = PackagePath + "Editor/MeshSubdivisionRenderer.uss";

            var treeAsset  = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(pathUxml);
            var styleAsset = AssetDatabase.LoadAssetAtPath <StyleSheet>(pathUss);

            treeAsset.CloneTree(rootView);
            rootView.styleSheets.Add(styleAsset);

            _meshTypeEnum = rootView.Q <EnumField>("enumMeshType");
            _meshTypeEnum.Init(MeshTypeInEditor.Quad);
            _meshTypeEnum.value = GetMeshType((Mesh)_meshProp.objectReferenceValue);
            _meshTypeEnum.RegisterCallback <ChangeEvent <Enum> >(
                (evt) => OnChangeMesh(evt.newValue));

            _meshShadingEnum = rootView.Q <EnumField>("enumMeshShading");
            _meshShadingEnum.Init(MeshShading.Lit);
            _meshShadingEnum.value = GetMeshShading();
            _meshShadingEnum.RegisterCallback <ChangeEvent <Enum> >(
                (evt) => OnChangeMeshShading(evt.newValue));

            _subdInterpEnum = rootView.Q <EnumField>("enumSubdInterp");
            _subdInterpEnum.Init(SubdInterp.None);
            _subdInterpEnum.value = GetSubdInterp();
            _subdInterpEnum.RegisterCallback <ChangeEvent <Enum> >(
                (evt) => OnChangeSubdInterp(evt.newValue));

            _castShadowsToggle       = rootView.Q <Toggle>("toggleCastShadows");
            _castShadowsToggle.value = _castShadowsProp.boolValue;
            _castShadowsToggle.RegisterCallback <ChangeEvent <bool> >(
                (evt) => OnChangeCastShadows(evt.newValue));

            _cullingToggle       = rootView.Q <Toggle>("toggleCulling");
            _cullingToggle.value = _enableCullingProp.boolValue;
            _cullingToggle.RegisterCallback <ChangeEvent <bool> >(
                (evt) => OnChangeDoCulling(evt.newValue));

            _targetPixelSlider       = rootView.Q <SliderInt>("sliderTargetPixel");
            _targetPixelSlider.value = _targetPixelSizeProp.intValue;
            _targetPixelSlider.RegisterCallback <ChangeEvent <int> >(
                (evt) => OnChangeTargetPixelSize(evt.newValue));

            _targetPixelText       = rootView.Q <TextField>("textTargetPixel");
            _targetPixelText.value = _targetPixelSizeProp.intValue.ToString();
            _targetPixelText.RegisterCallback <ChangeEvent <string> >(
                (evt) => OnChangeTargetPixelSize(evt.newValue));

            _debugCameraObject            = rootView.Q <ObjectField>("objectDebugCamera");
            _debugCameraObject.objectType = typeof(Camera);
            _debugCameraObject.value      = _debugCameraProp.objectReferenceValue;
            _debugCameraObject.RegisterCallback <ChangeEvent <UnityEngine.Object> >(
                (evt) => OnChangeDebugCamera(evt.newValue));

            return(rootView);
        }
 private EnumField GetOrCreateEnumField(Enum enumValue)
 {
     bool isCreation = childCount == 0;
     EnumField field = GetOrCreateField<EnumField, Enum>();
     if (isCreation)
         field.Init(enumValue);
     return field;
 }
Example #6
0
 void AddField(bool flag = false)
 {
     //値の追加
     enumField = new EnumField();
     enumField.Init(boolField);
     enumField.value = (flag == true ? BoolField.True : BoolField.False);
     mainContainer.Add(enumField);
     RefreshExpandedState();
 }
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);
                var ate = ve as BuilderAttributesTestElement;

                ate.Clear();

                ate.stringAttr = m_String.GetValueFromBag(bag, cc);
                ate.Add(new TextField("String")
                {
                    value = ate.stringAttr
                });

                ate.floatAttr = m_Float.GetValueFromBag(bag, cc);
                ate.Add(new FloatField("Float")
                {
                    value = ate.floatAttr
                });

                ate.doubleAttr = m_Double.GetValueFromBag(bag, cc);
                ate.Add(new DoubleField("Double")
                {
                    value = ate.doubleAttr
                });

                ate.intAttr = m_Int.GetValueFromBag(bag, cc);
                ate.Add(new IntegerField("Integer")
                {
                    value = ate.intAttr
                });

                ate.longAttr = m_Long.GetValueFromBag(bag, cc);
                ate.Add(new LongField("Long")
                {
                    value = ate.longAttr
                });

                ate.boolAttr = m_Bool.GetValueFromBag(bag, cc);
                ate.Add(new Toggle("Toggle")
                {
                    value = ate.boolAttr
                });

                ate.colorAttr = m_Color.GetValueFromBag(bag, cc);
                ate.Add(new ColorField("Color")
                {
                    value = ate.colorAttr
                });

                ate.enumAttr = m_Enum.GetValueFromBag(bag, cc);
                var en = new EnumField("Enum");

                en.Init(m_Enum.defaultValue);
                en.value = ate.enumAttr;
                ate.Add(en);
            }
Example #8
0
 public void AddBoolField(bool isBase)
 {
     //値の追加
     enumField       = new EnumField();
     enumField.label = "Is Base";
     enumField.Init(boolField);
     enumField.value = (isBase == true ? BoolField.True : BoolField.False);
     inputContainer.Add(enumField);
     RefreshExpandedState();
 }
        public SimpleStackNode(MathStackNode node)
        {
            var visualTree = Resources.Load("SimpleStackNodeHeader") as VisualTreeAsset;

            m_Header = visualTree.Instantiate();

            m_TitleItem = m_Header.Q <Label>(name: "titleLabel");
            m_TitleItem.AddToClassList("label");

            m_TitleEditor = m_Header.Q(name: "titleField") as TextField;

            m_TitleEditor.AddToClassList("textfield");
            m_TitleEditor.visible = false;

            m_TitleEditor.RegisterCallback <FocusOutEvent>(e => { OnEditTitleFinished(); });
            m_TitleEditor.Q("unity-text-input").RegisterCallback <KeyDownEvent>(OnKeyPressed);


            headerContainer.Add(m_Header);

            m_OperationControl = m_Header.Q <EnumField>(name: "operationField");
            m_OperationControl.Init(MathStackNode.Operation.Addition);
            m_OperationControl.value = node.currentOperation;
            m_OperationControl.RegisterCallback <ChangeEvent <Enum> >(v =>
            {
                node.currentOperation = (MathStackNode.Operation)v.newValue;

                MathNode mathNode = userData as MathNode;

                if (mathNode != null && mathNode.mathBook != null)
                {
                    mathNode.mathBook.inputOutputs.ComputeOutputs();
                }
            });

            var inputPort  = InstantiatePort(Orientation.Vertical, Direction.Input, Port.Capacity.Single, typeof(float));
            var outputPort = InstantiatePort(Orientation.Vertical, Direction.Output, Port.Capacity.Single, typeof(float));

            inputPort.portName  = "";
            outputPort.portName = "";

            inputContainer.Add(inputPort);
            outputContainer.Add(outputPort);

            RegisterCallback <MouseDownEvent>(OnMouseUpEvent);

            userData            = node;
            viewDataKey         = node.nodeID.ToString();
            title               = node.name;
            inputPort.userData  = node;
            outputPort.userData = node;
        }
    VisualTreeAsset SetUpStaticObject()
    {
        VisualTreeAsset aAsset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/UXML Files/StaticObjectEditor.uxml");

        mCurrentObjectElement  = aAsset.CloneTree();
        mSObjSprite            = mCurrentObjectElement.Q <ObjectField>("static_object_sprite");
        mSObjSprite.objectType = typeof(Sprite);
        mSObjSprite.RegisterCallback <ChangeEvent <Object> >((aEv) => GenHelpers.OnSpriteSelection((Sprite)aEv.newValue, mSObjSprite));
        mColliderType = mCurrentObjectElement.Q <EnumField>("static_object_collider");
        mColliderType.Init(GameScriptable.ColliderType.None);
        mColliderType.RegisterCallback <ChangeEvent <System.Enum> >((aEv) => OnColliderTypeChanged((GameScriptable.ColliderType)aEv.newValue));
        return(aAsset);
    }
Example #11
0
        // ######################## UNITY EVENT FUNCTIONS ######################## //

        #region UNITY EVENT FUNCTIONS

        public void OnEnable()
        {
            // show as an utility window with a fixed size
            ShowUtility();
            minSize = new Vector2(300, 600);
            maxSize = minSize;

            // Import UXML
            VisualTreeAsset visualTreeAsset = Resources.Load <VisualTreeAsset>("ColorPickerWindow_layout");

            visualTreeAsset.CloneTree(rootVisualElement);

            // load styles
            rootVisualElement.styleSheets.Add(Resources.Load <StyleSheet>("ColorPickerWindow_styles"));
            rootVisualElement.styleSheets.Add(Resources.Load <StyleSheet>("Styles"));

            // get elements
            EnumField modeField = rootVisualElement.Q <EnumField>("modeField");

            _colorComparisonSwatch = rootVisualElement.Q <ColorComparisonSwatch>();
            _hlsWheel        = rootVisualElement.Q <ColorWheel>();
            _sliderContainer = rootVisualElement.Q("sliderContainer");
            _colorSliders[0] = rootVisualElement.Q <ColorSlider>("colorSlider1");
            _colorSliders[1] = rootVisualElement.Q <ColorSlider>("colorSlider2");
            _colorSliders[2] = rootVisualElement.Q <ColorSlider>("colorSlider3");
            _hexField        = rootVisualElement.Q <TextField>("hexField");

            // add alpha slider
            _alphaSlider = new ColorSlider();
            _alphaSlider.AddToClassList("color-slider");
            _alphaSlider.label     = "A";
            _alphaSlider.lowValue  = 0;
            _alphaSlider.highValue = 1;

            // register callbacks
            _colorComparisonSwatch.OnColorClicked += SetColor;
            _hlsWheel.OnColorChanged += UpdateColorFromHslWheel;
            _colorSliders[0].RegisterValueChangedCallback(UpdateColorFromSlider0);
            _colorSliders[1].RegisterValueChangedCallback(UpdateColorFromSlider1);
            _colorSliders[2].RegisterValueChangedCallback(UpdateColorFromSlider2);
            _alphaSlider.RegisterValueChangedCallback(UpdateAlpha);
            _hexField.RegisterCallback <FocusOutEvent>(UpdateColorFromHex);

            // initialize with hsl mode
            SetSliderMode(SliderMode.HSL);
            UpdateSliders();

            // initialize the mode field with the current mode and register to its callback
            modeField.Init(_mode);
            modeField.RegisterValueChangedCallback(evt => SetSliderMode((SliderMode)evt.newValue));
        }
        public ConnectionRenderer(string label) : base(label)
        {
            statusField = new EnumField("Status");
            statusField.SetEnabled(false);
            statusField.Init(default(global::Improbable.Restricted.Connection.ConnectionStatus));
            Container.Add(statusField);

            dataLatencyMsField = new TextField("Data Latency Ms");
            dataLatencyMsField.SetEnabled(false);
            Container.Add(dataLatencyMsField);

            connectedSinceUtcField = new TextField("Connected Since Utc");
            connectedSinceUtcField.SetEnabled(false);
            Container.Add(connectedSinceUtcField);
        }
    VisualTreeAsset SetUpPickable()
    {
        VisualTreeAsset aAsset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/UXML Files/PickableEditor.uxml");

        mCurrentObjectElement = aAsset.CloneTree();
        mItemType             = mCurrentObjectElement.Q <EnumField>("item_type");
        mItemType.Init(Item.Type.HealthBoost);
        mItemType.RegisterCallback <ChangeEvent <System.Enum> >((aEv) => OnItemTypeChanged((Item.Type)aEv.newValue));
        mItemSound            = mCurrentObjectElement.Q <ObjectField>("item_collect_sound");
        mItemSound.objectType = typeof(AudioClip);
        mItemSound.RegisterCallback <ChangeEvent <Object> >((aEv) => GenHelpers.OnCollectSoundSelection((AudioClip)aEv.newValue, mItemSound));
        mItemSprite            = mCurrentObjectElement.Q <ObjectField>("item_idle_sprite");
        mItemSprite.objectType = typeof(Sprite);
        mItemSprite.RegisterCallback <ChangeEvent <Object> >((aEv) => GenHelpers.OnSpriteSelection((Sprite)aEv.newValue, mItemSprite));
        return(aAsset);
    }
Example #14
0
    public BoolNode(bool flag, BaseEdge edge)
    {
        title = "Bool";
        var port = Port.Create <Edge>(Orientation.Horizontal, Direction.Output, Port.Capacity.Single, typeof(bool));

        port.portName = "Value";

        outputContainer.Add(port);

        //値の追加
        enumField = new EnumField();
        enumField.Init(boolField);
        enumField.value = (flag == true ? BoolField.True : BoolField.False);
        mainContainer.Add(enumField);

        RefreshExpandedState();
    }
    private void ShowStartingScreen()
    {
        rootVisualElement.Clear();

        var visualTree = Resources.Load <VisualTreeAsset>(screen1TreePath);

        visualTree.CloneTree(rootVisualElement);

        // Setup item type enum field
        itemTypeEnumScreen1 = rootVisualElement.Q(name: "item-type-enum-field") as EnumField;
        itemTypeEnumScreen1.Init(ItemType.Default);


        // Setup confirm button
        Button confirmButton = rootVisualElement.Q(name: "confirm-button-screen1") as Button;

        confirmButton.clickable.clicked += () => ShowItemCreationScreen();
    }
Example #16
0
        public SimulatorApplicationSettingsUI(Foldout rootElement, ApplicationSimulation applicationSimulation, SimulatorSerializationStates states)
        {
            m_RootElement           = rootElement;
            m_ApplicationSimulation = applicationSimulation;

            m_SystemLanguageEnumField = m_RootElement.Q <EnumField>("application-system-language");
            m_SystemLanguageEnumField.Init(states?.systemLanguage ?? SystemLanguage.English);
            m_ApplicationSimulation.ShimmedSystemLanguage = (SystemLanguage)m_SystemLanguageEnumField.value;
            m_SystemLanguageEnumField.RegisterValueChangedCallback((evt) => { m_ApplicationSimulation.ShimmedSystemLanguage = (SystemLanguage)evt.newValue; });

            m_InternetReachabilityEnumField = m_RootElement.Q <EnumField>("application-internet-reachability");
            m_InternetReachabilityEnumField.Init(states?.networkReachability ?? NetworkReachability.NotReachable);
            m_ApplicationSimulation.ShimmedInternetReachability = (NetworkReachability)m_InternetReachabilityEnumField.value;
            m_InternetReachabilityEnumField.RegisterValueChangedCallback((evt) => { m_ApplicationSimulation.ShimmedInternetReachability = (NetworkReachability)evt.newValue; });

            var onLowMemoryButton = m_RootElement.Q <Button>("application-low-memory");

            onLowMemoryButton.clickable = new Clickable(() => m_ApplicationSimulation.OnLowMemory());
        }
    void CreateNewObjectVE()
    {
        VisualTreeAsset aAsset;

        switch (mActiveType)
        {
        case GameObjectType.None:
            return;

        case GameObjectType.Pickable:
            aAsset = SetUpPickable();
            break;

        case GameObjectType.Projectile:
            aAsset = SetUpProjectile();
            break;

        case GameObjectType.SpawnFactory:
            aAsset = SetUpSpawnFactory();
            break;

        case GameObjectType.Enemy:
            aAsset = SetUpEnemy();
            break;

        case GameObjectType.StaticObject:
            aAsset = SetUpStaticObject();
            break;

        default:
            return;
        }
        if (aAsset == null)
        {
            return;
        }
        mLayerType = mCurrentObjectElement.Q <EnumField>("gobj_layer");
        mLayerType.Init(Level.LayerTypes.Environment);
        mLayerType.RegisterCallback <ChangeEvent <System.Enum> >((aEv) => OnLayerChanged((Level.LayerTypes)aEv.newValue));
        mCurrentObjectElement.Q <Button>("gobj_data").RegisterCallback <MouseUpEvent>((aEv) => SaveAsScriptableAsset());
        mEditoryBlock.Add(mCurrentObjectElement);
    }
Example #18
0
        private void Init(DeviceInfo deviceInfo, ScreenSimulation screenSimulation, SimulationPlayerSettings playerSettings)
        {
            m_ScreenWidthField  = m_RootElement.Q <IntegerField>("screen-width");
            m_ScreenHeightField = m_RootElement.Q <IntegerField>("screen-height");

            m_ScreenSetResolution           = m_RootElement.Q <Button>("screen-set-resolution-button");
            m_ScreenSetResolution.clickable = new Clickable(SetResolution);

            m_FullScreenToggle = m_RootElement.Q <Toggle>("full-screen");
            m_FullScreenToggle.RegisterValueChangedCallback(SetFullScreen);

            m_AutoRotationToggle = m_RootElement.Q <Toggle>("auto-rotation");
            m_AutoRotationToggle.RegisterValueChangedCallback(SetAutoRotation);

            m_ScreenOrientationEnumField = m_RootElement.Q <EnumField>("screen-orientations");
            m_ScreenOrientationEnumField.Init(RenderedScreenOrientation.Portrait);
            m_ScreenOrientationEnumField.RegisterValueChangedCallback(SetScreenOrientation);

            m_RenderedOrientationContainer = m_RootElement.Q <VisualElement>("rendered-orientation-container");
            m_RendererOrientation          = m_RootElement.Q <Label>("rendered-orientation");

            m_AllowedOrientationsSection = m_RootElement.Q <VisualElement>("allowed-orientations");

            m_AllowedPortrait = m_RootElement.Q <Toggle>("orientation-allow-portrait");
            m_AllowedPortrait.RegisterValueChangedCallback((evt) => { Screen.autorotateToPortrait = evt.newValue; });

            m_AllowedPortraitUpsideDown = m_RootElement.Q <Toggle>("orientation-allow-portrait-upside-down");
            m_AllowedPortraitUpsideDown.RegisterValueChangedCallback((evt) => { Screen.autorotateToPortraitUpsideDown = evt.newValue; });

            m_AllowedLandscapeLeft = m_RootElement.Q <Toggle>("orientation-allow-landscape-left");
            m_AllowedLandscapeLeft.RegisterValueChangedCallback((evt) => { Screen.autorotateToLandscapeLeft = evt.newValue; });

            m_AllowedLandscapeRight = m_RootElement.Q <Toggle>("orientation-allow-landscape-right");
            m_AllowedLandscapeRight.RegisterValueChangedCallback((evt) => { Screen.autorotateToLandscapeRight = evt.newValue; });

            // Initialized the control states.
            UpdateOrientationVisualElements(screenSimulation.AutoRotation);
            UpdateAllowedOrientationVisualElements();

            Update(deviceInfo, screenSimulation, playerSettings);
        }
Example #19
0
        protected override void SetBaseVisualElement(VisualElement visualElement)
        {
            VisualElement choseShapeField = new ChoseShapeDataField <ShapeData>(
                ShapeAction.ShapeDataFactory,
                ShapeAction,
                "Chose Shape: ",
                () => ShapeAction.ShapeData,
                shapeData => ShapeAction.SetShapeData(shapeData));

            visualElement.Add(choseShapeField);

            EnumField highlightField = new EnumField("Set Highlight")
            {
                value = ShapeAction.Highlight
            };

            highlightField.Init(ShapeAction.Highlight);
            highlightField.RegisterCallback <ChangeEvent <Enum> >(evt => ShapeAction.SetHighlightType((HighlightType)evt.newValue));

            visualElement.Add(highlightField);
        }
Example #20
0
    public void AddEventsField(ActionData action, int num)
    {
        //値の追加
        conditionField       = new EnumField();
        conditionField.label = "condition" + num;
        conditionField.Init(conditionDataField);
        conditionField.value = (ConditionDataField)action.condition;
        outputContainer.Add(conditionField);

        var conditionData = new TextField();

        conditionData.label = "conditionData";
        conditionData.value = action.conditionData;
        outputContainer.Add(conditionData);


        //値の追加
        contentField       = new EnumField();
        contentField.label = "content";
        contentField.Init(contentDataField);
        contentField.value = (ContentDataField)action.content;
        outputContainer.Add(contentField);
        RefreshExpandedState();

        var contentData = new TextField();

        contentData.label = "contentData";
        contentData.value = action.contentData;
        outputContainer.Add(contentData);

        ActionData data;

        data.condition     = (ConditionDataField)conditionField.value;
        data.conditionData = conditionData.value;
        data.content       = (ContentDataField)contentField.value;
        data.contentData   = contentData.value;

        actionField.Add(data);
        //RefreshExpandedState();
    }
Example #21
0
    void Init(ActionData action)
    {
        //var condition = new FloatField();
        //condition.label = "condition";
        //condition.value = action.condition;
        //mainContainer.Add(condition);

        //値の追加
        conditionField       = new EnumField();
        conditionField.label = "condition";
        conditionField.Init(conditionDataField);
        conditionField.value = (ConditionDataField)action.condition;
        mainContainer.Add(conditionField);

        var conditionData = new TextField();

        conditionData.label = "conditionData";
        conditionData.value = action.conditionData;
        mainContainer.Add(conditionData);

        //var content = new FloatField();
        //content.label = "content";
        //content.value = action.content;
        //mainContainer.Add(content);

        //値の追加
        contentField       = new EnumField();
        contentField.label = "content";
        contentField.Init(contentDataField);
        contentField.value = (ContentDataField)action.content;
        mainContainer.Add(contentField);
        RefreshExpandedState();

        var contentData = new TextField();

        contentData.label = "contentData";
        contentData.value = action.contentData;
        mainContainer.Add(contentData);
    }
Example #22
0
        protected sealed override void SetupUI()
        {
            var replicatorRowAsset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(k_ReplicatorRowPath);

            replicatorRowAsset.CloneTree(this);

            base.SetupUI();

            m_ContentContainer = this.Q <VisualElement>(k_ContentContainerName);

            m_Foldout = this.Q <Foldout>(k_RowFoldoutName);
            m_Foldout.RegisterValueChangedCallback(evt =>
            {
                var expanded = evt.newValue;
                m_ContentContainer.style.display = expanded ? DisplayStyle.Flex : DisplayStyle.None;
                if (expanded)
                {
                    RulesModule.CollapsedNodes.Remove(BackingObject);
                }
                else
                {
                    RulesModule.CollapsedNodes.Add(BackingObject);
                }

                RulesDrawer.BuildReplicatorsList();
            });

            m_Foldout.RegisterCallback <ExecuteCommandEvent>(RulesModule.PickObject);

            if (IsGroup)
            {
                m_Foldout.visible = false;
            }
            else
            {
                var expanded = !RulesModule.CollapsedNodes.Contains(BackingObject);
                m_Foldout.value = expanded;
                m_ContentContainer.style.display = expanded ? DisplayStyle.Flex : DisplayStyle.None;
            }

            m_MatchCountEnum = this.Q <EnumField>(k_MatchCountEnum);
            m_MatchCountEnum.Init(RulesModule.ReplicatorCountOption.Every);
            m_MatchCountEnum.RegisterCallback <ChangeEvent <System.Enum> >(OnChangeMatchCountDropdown);

            m_MaxCountField = this.Q <IntegerField>(k_MaxInstancesName);
            m_MaxCountField.RegisterValueChangedCallback(OnMaxInstanceChanged);

            m_MaxCountField.RegisterCallback <ExecuteCommandEvent>(RulesModule.PickObject);

            SetupProxyPresetUI(m_Entity);

            m_GroupDrillInButton          = this.Q <Button>(k_GroupDrillIn);
            m_GroupDrillInButton.clicked += () =>
            {
                var ruleSet = m_Entity.GetComponent <ProxyRuleSet>();
                RulesModule.RuleSetInstance = ruleSet;
                RulesDrawer.BuildReplicatorsList();
            };

            if (!IsGroup)
            {
                m_GroupDrillInButton.style.display = DisplayStyle.None;
            }

            m_SimMatchCount = this.Q <Label>(k_SimMatchCountName);

            SetupReplicatorRow();

            if (IsGroup)
            {
                m_AddButtonHoverElement.SetEnabled(false);
            }

            CreateAddContentButton();

            RegisterCallback <KeyDownEvent>(OnKeyDown);
        }
Example #23
0
    public ResponseCurveEditor(UtilityAIConsiderationEditor utilityAIConsiderationEditor, ResponseCurve responseCurve)
    {
        this.utilityAIConsiderationEditor = utilityAIConsiderationEditor;
        this.responseCurve = responseCurve;

        VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/UtilityAI/Scripts/Editor/Response Curve Editor/ResponseCurveEditor.uxml");

        visualTree.CloneTree(this);

        StyleSheet stylesheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/UtilityAI/Scripts/Editor/Response Curve Editor/ResponseCurveEditor.uss");

        this.styleSheets.Add(stylesheet);

        this.AddToClassList("responseCurveEditor");

        EnumField curveTypeField = this.Query <EnumField>("curveType").First();

        curveTypeField.Init(CurveType.Linear);
        curveTypeField.value = responseCurve.curveType;
        curveTypeField.RegisterCallback <ChangeEvent <Enum> >(
            e =>
        {
            responseCurve.curveType = (CurveType)e.newValue;
            utilityAIConsiderationEditor.UpdateResponseCurve();
        }
            );

        FloatField xShiftField = this.Query <FloatField>("xShift").First();

        xShiftField.value = responseCurve.xShift;
        xShiftField.RegisterCallback <ChangeEvent <float> >(
            e =>
        {
            responseCurve.xShift = (float)e.newValue;
            utilityAIConsiderationEditor.UpdateResponseCurve();
        }
            );

        FloatField yShiftField = this.Query <FloatField>("yShift").First();

        yShiftField.value = responseCurve.yShift;
        yShiftField.RegisterCallback <ChangeEvent <float> >(
            e =>
        {
            responseCurve.yShift = (float)e.newValue;
            utilityAIConsiderationEditor.UpdateResponseCurve();
        }
            );

        FloatField slopeField = this.Query <FloatField>("slope").First();

        slopeField.value = responseCurve.slope;
        slopeField.RegisterCallback <ChangeEvent <float> >(
            e =>
        {
            responseCurve.slope = (float)e.newValue;
            utilityAIConsiderationEditor.UpdateResponseCurve();
        }
            );

        FloatField exponentialField = this.Query <FloatField>("exponential").First();

        exponentialField.value = responseCurve.exponential;
        exponentialField.RegisterCallback <ChangeEvent <float> >(
            e =>
        {
            responseCurve.exponential = (float)e.newValue;
            utilityAIConsiderationEditor.UpdateResponseCurve();
        }
            );

        Box box = new Box()
        {
            style =
            {
                flexGrow     =   1,
                marginTop    =   5,
                marginBottom =   5,
                marginLeft   =   5,
                marginRight  =   5,
                height       = 300,
            }
        };

        this.Add(box);

        VisualElement meshContainer = new VisualElement()
        {
            style = { flexGrow = 1, }
        };

        box.Add(meshContainer);
        meshContainer.generateVisualContent += DrawGraph;
    }
Example #24
0
    public LevelNode(Vector2 _position, LevelEditorWindow _editorWindow, LevelFlowGraphView _graphView)
    {
        SetPosition(new Rect(_position, defaultNodeSize));

        CreateSubGraphView();

        //Scene Object field
        sceneField = new ObjectField
        {
            objectType        = typeof(Scene),
            allowSceneObjects = false
        };

        sceneField.RegisterValueChangedCallback(ValueTuple =>
        {
            scene         = ValueTuple.newValue;
            title         = ValueTuple.newValue.name;
            scenAssetGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(ValueTuple.newValue as SceneAsset));
            scenePath     = AssetDatabase.GetAssetPath(ValueTuple.newValue as SceneAsset);
            //SetScenePath();
        });
        mainContainer.Add(sceneField);


        //Async? Enum field
        asyncTypeField = new EnumField()
        {
            value = asyncType
        };
        asyncTypeField.Init(asyncType);

        asyncTypeField.RegisterValueChangedCallback((value) =>
        {
            //賦予新value
            asyncType = (AsyncLoadType)value.newValue;
        });

        asyncTypeField.SetValueWithoutNotify(asyncType);

        mainContainer.Add(asyncTypeField);

        //Load Type Enum field
        loadTypeField = new EnumField()
        {
            value = loadType
        };
        loadTypeField.Init(loadType);

        loadTypeField.RegisterValueChangedCallback((value) =>
        {
            //賦予新value
            loadType = (SceneLoadType)value.newValue;
        });

        loadTypeField.SetValueWithoutNotify(loadType);

        mainContainer.Add(loadTypeField);



        //新增節點須refresh
        RefreshExpandedState();
        RefreshPorts();
    }
        private void AddMainUI(VisualElement mainView)
        {
            var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Packages/com.unity.2d.sprite/Editor/UI/SpriteEditor/SpriteFrameModuleInspector.uxml") as VisualTreeAsset;

            m_SelectedFrameInspector = visualTree.CloneTree().Q("spriteFrameModuleInspector");

            m_NameElement = m_SelectedFrameInspector.Q("name");
            m_NameField   = m_SelectedFrameInspector.Q <TextField>("spriteName");
            m_NameField.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    selectedSpriteName = evt.newValue;
                }
            });

            m_NameField.RegisterCallback <FocusOutEvent>((focus) =>
            {
                if (hasSelected)
                {
                    m_NameField.SetValueWithoutNotify(selectedSpriteName);
                }
            });


            m_PositionElement = m_SelectedFrameInspector.Q("position");
            m_PositionFieldX  = m_PositionElement.Q <IntegerField>("positionX");
            m_PositionFieldX.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    var rect           = selectedSpriteRect;
                    rect.x             = evt.newValue;
                    selectedSpriteRect = rect;
                    UpdatePositionField(selectedSpriteRect);
                }
            });

            m_PositionFieldY = m_PositionElement.Q <IntegerField>("positionY");
            m_PositionFieldY.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    var rect           = selectedSpriteRect;
                    rect.y             = evt.newValue;
                    selectedSpriteRect = rect;
                    UpdatePositionField(selectedSpriteRect);
                }
            });

            m_PositionFieldW = m_PositionElement.Q <IntegerField>("positionW");
            m_PositionFieldW.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    var rect           = selectedSpriteRect;
                    rect.width         = evt.newValue;
                    selectedSpriteRect = rect;
                    UpdatePositionField(selectedSpriteRect);
                }
            });

            m_PositionFieldH = m_PositionElement.Q <IntegerField>("positionH");
            m_PositionFieldH.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    var rect           = selectedSpriteRect;
                    rect.height        = evt.newValue;
                    selectedSpriteRect = rect;
                    UpdatePositionField(selectedSpriteRect);
                }
            });

            var borderElement = m_SelectedFrameInspector.Q("border");

            m_BorderFieldL = borderElement.Q <IntegerField>("borderL");
            m_BorderFieldL.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.x             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldL.SetValueWithoutNotify((int)selectedSpriteBorder.x);
                }
            });

            m_BorderFieldT = borderElement.Q <IntegerField>("borderT");
            m_BorderFieldT.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.w             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldT.SetValueWithoutNotify((int)selectedSpriteBorder.w);
                    evt.StopPropagation();
                }
            });

            m_BorderFieldR = borderElement.Q <IntegerField>("borderR");
            m_BorderFieldR.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.z             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldR.SetValueWithoutNotify((int)selectedSpriteBorder.z);
                }
            });

            m_BorderFieldB = borderElement.Q <IntegerField>("borderB");
            m_BorderFieldB.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.y             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldB.SetValueWithoutNotify((int)selectedSpriteBorder.y);
                }
            });

            m_PivotField = m_SelectedFrameInspector.Q <EnumField>("pivotField");
            m_PivotField.Init(SpriteAlignment.Center);
            m_PivotField.label = L10n.Tr("Pivot");
            m_PivotField.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    SpriteAlignment alignment = (SpriteAlignment)evt.newValue;
                    SetSpritePivotAndAlignment(selectedSpritePivot, alignment);
                    m_CustomPivotElement.SetEnabled(selectedSpriteAlignment == SpriteAlignment.Custom);
                    Vector2 pivot = selectedSpritePivotInCurUnitMode;
                    m_CustomPivotFieldX.SetValueWithoutNotify(pivot.x);
                    m_CustomPivotFieldY.SetValueWithoutNotify(pivot.y);
                }
            });


            m_PivotUnitModeField = m_SelectedFrameInspector.Q <EnumField>("pivotUnitModeField");
            m_PivotUnitModeField.Init(PivotUnitMode.Normalized);
            m_PivotUnitModeField.label = L10n.Tr("Pivot Unit Mode");
            m_PivotUnitModeField.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    m_PivotUnitMode = (PivotUnitMode)evt.newValue;

                    Vector2 pivot = selectedSpritePivotInCurUnitMode;
                    m_CustomPivotFieldX.SetValueWithoutNotify(pivot.x);
                    m_CustomPivotFieldY.SetValueWithoutNotify(pivot.y);
                }
            });


            m_CustomPivotElement = m_SelectedFrameInspector.Q("customPivot");
            m_CustomPivotFieldX  = m_CustomPivotElement.Q <FloatField>("customPivotX");
            m_CustomPivotFieldX.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    float newValue = (float)evt.newValue;
                    float pivotX   = m_PivotUnitMode == PivotUnitMode.Pixels
                        ? ConvertFromRectToNormalizedSpace(new Vector2(newValue, 0.0f), selectedSpriteRect).x
                        : newValue;

                    var pivot = selectedSpritePivot;
                    pivot.x   = pivotX;
                    SetSpritePivotAndAlignment(pivot, selectedSpriteAlignment);
                }
            });

            m_CustomPivotFieldY = m_CustomPivotElement.Q <FloatField>("customPivotY");
            m_CustomPivotFieldY.RegisterValueChangedCallback((evt) =>
            {
                if (hasSelected)
                {
                    float newValue = (float)evt.newValue;
                    float pivotY   = m_PivotUnitMode == PivotUnitMode.Pixels
                        ? ConvertFromRectToNormalizedSpace(new Vector2(0.0f, newValue), selectedSpriteRect).y
                        : newValue;

                    var pivot = selectedSpritePivot;
                    pivot.y   = pivotY;
                    SetSpritePivotAndAlignment(pivot, selectedSpriteAlignment);
                }
            });

            //// Force an update of all the fields.
            PopulateSpriteFrameInspectorField();

            mainView.RegisterCallback <SpriteSelectionChangeEvent>(SelectionChange);

            // Stop mouse events from reaching the main view.
            m_SelectedFrameInspector.pickingMode = PickingMode.Ignore;
            m_SelectedFrameInspector.RegisterCallback <MouseDownEvent>((e) => { e.StopPropagation(); });
            m_SelectedFrameInspector.RegisterCallback <MouseUpEvent>((e) => { e.StopPropagation(); });
            m_SelectedFrameInspector.AddToClassList("moduleWindow");
            m_SelectedFrameInspector.AddToClassList("bottomRightFloating");
            mainView.Add(m_SelectedFrameInspector);
        }
        BuilderStyleRow CreateAttributeRow(UxmlAttributeDescription attribute)
        {
            var attributeType = attribute.GetType();

            // Generate field label.
            var             fieldLabel = BuilderNameUtilities.ConvertDashToHuman(attribute.name);
            BindableElement fieldElement;

            if (attribute is UxmlStringAttributeDescription)
            {
                var uiField = new TextField(fieldLabel);
                if (attribute.name.Equals("name") || attribute.name.Equals("view-data-key"))
                {
                    uiField.RegisterValueChangedCallback(e =>
                    {
                        OnValidatedAttributeValueChange(e, BuilderNameUtilities.AttributeRegex, BuilderConstants.AttributeValidationSpacialCharacters);
                    });
                }
                else if (attribute.name.Equals("binding-path"))
                {
                    uiField.RegisterValueChangedCallback(e =>
                    {
                        OnValidatedAttributeValueChange(e, BuilderNameUtilities.BindingPathAttributeRegex, BuilderConstants.BindingPathAttributeValidationSpacialCharacters);
                    });
                }
                else
                {
                    uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                }

                if (attribute.name.Equals("text"))
                {
                    uiField.multiline = true;
                    uiField.AddToClassList(BuilderConstants.InspectorMultiLineTextFieldClassName);
                }

                fieldElement = uiField;
            }
            else if (attribute is UxmlFloatAttributeDescription)
            {
                var uiField = new FloatField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attribute is UxmlDoubleAttributeDescription)
            {
                var uiField = new DoubleField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attribute is UxmlIntAttributeDescription)
            {
                var uiField = new IntegerField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attribute is UxmlLongAttributeDescription)
            {
                var uiField = new LongField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attribute is UxmlBoolAttributeDescription)
            {
                var uiField = new Toggle(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attribute is UxmlColorAttributeDescription)
            {
                var uiField = new ColorField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attributeType.IsGenericType &&
                     !attributeType.GetGenericArguments()[0].IsEnum &&
                     attributeType.GetGenericArguments()[0] is Type)
            {
                var uiField = new TextField(fieldLabel);
                uiField.isDelayed = true;
                uiField.RegisterValueChangedCallback(e =>
                {
                    OnValidatedTypeAttributeChange(e, attributeType.GetGenericArguments()[0]);
                });
                fieldElement = uiField;
            }
            else if (attributeType.IsGenericType && attributeType.GetGenericArguments()[0].IsEnum)
            {
                var propInfo  = attributeType.GetProperty("defaultValue");
                var enumValue = propInfo.GetValue(attribute, null) as Enum;

                // Create and initialize the EnumField.
                var uiField = new EnumField(fieldLabel);
                uiField.Init(enumValue);

                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else
            {
                var uiField = new TextField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }

            // Create row.
            var styleRow = new BuilderStyleRow();

            styleRow.Add(fieldElement);

            // Link the field.
            fieldElement.SetProperty(BuilderConstants.InspectorLinkedStyleRowVEPropertyName, styleRow);
            fieldElement.SetProperty(BuilderConstants.InspectorLinkedAttributeDescriptionVEPropertyName, attribute);

            // Set initial value.
            RefreshAttributeField(fieldElement);

            // Setup field binding path.
            fieldElement.bindingPath = attribute.name;

            // Tooltip.
            var label = fieldElement.Q <Label>();

            if (label != null)
            {
                label.tooltip = attribute.name;
            }
            else
            {
                fieldElement.tooltip = attribute.name;
            }

            // Context menu.
            fieldElement.AddManipulator(new ContextualMenuManipulator(BuildAttributeFieldContextualMenu));

            return(styleRow);
        }
Example #27
0
        BuilderStyleRow CreateAttributeRow(UxmlAttributeDescription attribute)
        {
            var attributeType = attribute.GetType();

            // Generate field label.
            var             fieldLabel = BuilderNameUtilities.ConvertDashToHuman(attribute.name);
            BindableElement fieldElement;

            if (attribute is UxmlStringAttributeDescription)
            {
                // Hard-coded
                if (attribute.name.Equals("value") && currentVisualElement is EnumField enumField)
                {
                    var uiField = new EnumField("Value");
                    if (null != enumField.value)
                    {
                        uiField.Init(enumField.value, enumField.includeObsoleteValues);
                    }
                    else
                    {
                        uiField.SetValueWithoutNotify(null);
                    }
                    uiField.RegisterValueChangedCallback(evt =>
                                                         PostAttributeValueChange(uiField, uiField.value.ToString()));
                    fieldElement = uiField;
                }
                else if (attribute.name.Equals("value") && currentVisualElement is TagField tagField)
                {
                    var uiField = new TagField("Value");
                    uiField.RegisterValueChangedCallback(evt =>
                                                         PostAttributeValueChange(uiField, uiField.value.ToString()));
                    fieldElement = uiField;
                }
                else
                {
                    var uiField = new TextField(fieldLabel);
                    if (attribute.name.Equals("name") || attribute.name.Equals("view-data-key"))
                    {
                        uiField.RegisterValueChangedCallback(e =>
                        {
                            OnValidatedAttributeValueChange(e, BuilderNameUtilities.attributeRegex,
                                                            BuilderConstants.AttributeValidationSpacialCharacters);
                        });
                    }
                    else if (attribute.name.Equals("binding-path"))
                    {
                        uiField.RegisterValueChangedCallback(e =>
                        {
                            OnValidatedAttributeValueChange(e, BuilderNameUtilities.bindingPathAttributeRegex,
                                                            BuilderConstants.BindingPathAttributeValidationSpacialCharacters);
                        });
                    }
                    else
                    {
                        uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                    }

                    if (attribute.name.Equals("text") || attribute.name.Equals("label"))
                    {
                        uiField.multiline = true;
                        uiField.AddToClassList(BuilderConstants.InspectorMultiLineTextFieldClassName);
                    }

                    fieldElement = uiField;
                }
            }
            else if (attribute is UxmlFloatAttributeDescription)
            {
                var uiField = new FloatField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attribute is UxmlDoubleAttributeDescription)
            {
                var uiField = new DoubleField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attribute is UxmlIntAttributeDescription)
            {
                if (attribute.name.Equals("value") && currentVisualElement is LayerField)
                {
                    var uiField = new LayerField("Value");
                    uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                    fieldElement = uiField;
                }
                else if (attribute.name.Equals("value") && currentVisualElement is LayerMaskField)
                {
                    var uiField = new LayerMaskField("Value");
                    uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                    fieldElement = uiField;
                }
                else
                {
                    var uiField = new IntegerField(fieldLabel);
                    uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                    fieldElement = uiField;
                }
            }
            else if (attribute is UxmlLongAttributeDescription)
            {
                var uiField = new LongField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attribute is UxmlBoolAttributeDescription)
            {
                var uiField = new Toggle(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attribute is UxmlColorAttributeDescription)
            {
                var uiField = new ColorField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }
            else if (attributeType.IsGenericType &&
                     !attributeType.GetGenericArguments()[0].IsEnum &&
                     attributeType.GetGenericArguments()[0] is Type)
            {
                var desiredType = attributeType.GetGenericArguments()[0];

                var uiField = new TextField(fieldLabel)
                {
                    isDelayed = true
                };

                var completer = new FieldSearchCompleter <TypeInfo>(uiField);
                uiField.RegisterCallback <AttachToPanelEvent, FieldSearchCompleter <TypeInfo> >((evt, c) =>
                {
                    // When possible, the popup should have the same width as the input field, so that the auto-complete
                    // characters will try to match said input field.
                    c.popup.anchoredControl = ((VisualElement)evt.target).Q(className: "unity-text-field__input");
                }, completer);
                completer.matcherCallback    += (str, info) => info.value.IndexOf(str, StringComparison.OrdinalIgnoreCase) >= 0;
                completer.itemHeight          = 36;
                completer.dataSourceCallback += () =>
                {
                    return(TypeCache.GetTypesDerivedFrom(desiredType)
                           .Where(t => !t.IsGenericType)
                           // Remove UIBuilder types from the list
                           .Where(t => t.Assembly != GetType().Assembly)
                           .Select(GetTypeInfo));
                };
                completer.getTextFromDataCallback += info => info.value;
                completer.makeItem    = () => s_TypeNameItemPool.Get();
                completer.destroyItem = e =>
                {
                    if (e is BuilderAttributeTypeName typeItem)
                    {
                        s_TypeNameItemPool.Release(typeItem);
                    }
                };
                completer.bindItem = (v, i) =>
                {
                    if (v is BuilderAttributeTypeName l)
                    {
                        l.SetType(completer.results[i].type, completer.textField.text);
                    }
                };

                uiField.RegisterValueChangedCallback(e => OnValidatedTypeAttributeChange(e, desiredType));

                fieldElement = uiField;
                uiField.RegisterCallback <DetachFromPanelEvent, FieldSearchCompleter <TypeInfo> >((evt, c) =>
                {
                    c.popup.RemoveFromHierarchy();
                }, completer);
                uiField.userData = completer;
            }
            else if (attributeType.IsGenericType && attributeType.GetGenericArguments()[0].IsEnum)
            {
                var propInfo         = attributeType.GetProperty("defaultValue");
                var defaultEnumValue = propInfo.GetValue(attribute, null) as Enum;

                if (defaultEnumValue.GetType().GetCustomAttribute <FlagsAttribute>() == null)
                {
                    // Create and initialize the EnumField.
                    var uiField = new EnumField(fieldLabel);
                    uiField.Init(defaultEnumValue);

                    uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                    fieldElement = uiField;
                }
                else
                {
                    // Create and initialize the EnumField.
                    var uiField = new EnumFlagsField(fieldLabel);
                    uiField.Init(defaultEnumValue);

                    uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                    fieldElement = uiField;
                }
            }
            else
            {
                var uiField = new TextField(fieldLabel);
                uiField.RegisterValueChangedCallback(OnAttributeValueChange);
                fieldElement = uiField;
            }

            // Create row.
            var styleRow = new BuilderStyleRow();

            styleRow.Add(fieldElement);

            // Link the field.
            fieldElement.SetProperty(BuilderConstants.InspectorLinkedStyleRowVEPropertyName, styleRow);
            fieldElement.SetProperty(BuilderConstants.InspectorLinkedAttributeDescriptionVEPropertyName, attribute);

            // Set initial value.
            RefreshAttributeField(fieldElement);

            // Setup field binding path.
            fieldElement.bindingPath = attribute.name;
            fieldElement.tooltip     = attribute.name;

            // Context menu.
            fieldElement.AddManipulator(new ContextualMenuManipulator(BuildAttributeFieldContextualMenu));

            return(styleRow);
        }
Example #28
0
        private void AddMainUI(VisualElement mainView)
        {
            var visualTree = EditorGUIUtility.Load("UXML/SpriteEditor/SpriteFrameModuleInspector.uxml") as VisualTreeAsset;

            m_SelectedFrameInspector = visualTree.CloneTree(null).Q("spriteFrameModuleInspector");

            m_NameElement = m_SelectedFrameInspector.Q("name");
            m_NameField   = m_SelectedFrameInspector.Q <PropertyControl <string> >("spriteName");
            m_NameField.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    selectedSpriteName = evt.newValue;
                }
            });

            m_PositionElement = m_SelectedFrameInspector.Q("position");
            m_PositionFieldX  = m_PositionElement.Q <PropertyControl <long> >("positionX");
            m_PositionFieldX.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var rect               = selectedSpriteRect;
                    rect.x                 = evt.newValue;
                    selectedSpriteRect     = rect;
                    m_PositionFieldX.value = (long)selectedSpriteRect.x;
                }
            });

            m_PositionFieldY = m_PositionElement.Q <PropertyControl <long> >("positionY");
            m_PositionFieldY.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var rect               = selectedSpriteRect;
                    rect.y                 = evt.newValue;
                    selectedSpriteRect     = rect;
                    m_PositionFieldY.value = (long)selectedSpriteRect.y;
                }
            });

            m_PositionFieldW = m_PositionElement.Q <PropertyControl <long> >("positionW");
            m_PositionFieldW.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var rect               = selectedSpriteRect;
                    rect.width             = evt.newValue;
                    selectedSpriteRect     = rect;
                    m_PositionFieldW.value = (long)selectedSpriteRect.width;
                }
            });

            m_PositionFieldH = m_PositionElement.Q <PropertyControl <long> >("positionH");
            m_PositionFieldH.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var rect               = selectedSpriteRect;
                    rect.height            = evt.newValue;
                    selectedSpriteRect     = rect;
                    m_PositionFieldH.value = (long)selectedSpriteRect.height;
                }
            });

            var borderElement = m_SelectedFrameInspector.Q("border");

            m_BorderFieldL = borderElement.Q <PropertyControl <long> >("borderL");
            m_BorderFieldL.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.x             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldL.value = (long)selectedSpriteBorder.x;
                }
            });

            m_BorderFieldT = borderElement.Q <PropertyControl <long> >("borderT");
            m_BorderFieldT.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.y             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldT.value = (long)selectedSpriteBorder.y;
                }
            });

            m_BorderFieldR = borderElement.Q <PropertyControl <long> >("borderR");
            m_BorderFieldR.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.z             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldR.value = (long)selectedSpriteBorder.z;
                }
            });

            m_BorderFieldB = borderElement.Q <PropertyControl <long> >("borderB");
            m_BorderFieldB.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.w             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldB.value = (long)selectedSpriteBorder.w;
                }
            });

            m_PivotField = m_SelectedFrameInspector.Q <EnumField>("pivotField");
            m_PivotField.Init(SpriteAlignment.Center);
            m_PivotField.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    SpriteAlignment alignment = (SpriteAlignment)evt.newValue;
                    SetSpritePivotAndAlignment(selectedSpritePivot, alignment);
                    m_CustomPivotElement.SetEnabled(selectedSpriteAlignment == SpriteAlignment.Custom);

                    Vector2 pivot             = selectedSpritePivotInCurUnitMode;
                    m_CustomPivotFieldX.value = pivot.x;
                    m_CustomPivotFieldY.value = pivot.y;
                }
            });


            m_PivotUnitModeField = m_SelectedFrameInspector.Q <EnumField>("pivotUnitModeField");
            m_PivotUnitModeField.Init(PivotUnitMode.Normalized);
            m_PivotUnitModeField.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    m_PivotUnitMode = (PivotUnitMode)evt.newValue;

                    Vector2 pivot             = selectedSpritePivotInCurUnitMode;
                    m_CustomPivotFieldX.value = pivot.x;
                    m_CustomPivotFieldY.value = pivot.y;
                }
            });


            m_CustomPivotElement = m_SelectedFrameInspector.Q("customPivot");
            m_CustomPivotFieldX  = m_CustomPivotElement.Q <PropertyControl <double> >("customPivotX");
            m_CustomPivotFieldX.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    float newValue = (float)evt.newValue;
                    float pivotX   = m_PivotUnitMode == PivotUnitMode.Pixels
                            ? ConvertFromRectToNormalizedSpace(new Vector2(newValue, 0.0f), selectedSpriteRect).x
                            : newValue;

                    var pivot = selectedSpritePivot;
                    pivot.x   = pivotX;
                    SetSpritePivotAndAlignment(pivot, selectedSpriteAlignment);
                }
            });

            m_CustomPivotFieldY = m_CustomPivotElement.Q <PropertyControl <double> >("customPivotY");
            m_CustomPivotFieldY.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    float newValue = (float)evt.newValue;
                    float pivotY   = m_PivotUnitMode == PivotUnitMode.Pixels
                            ? ConvertFromRectToNormalizedSpace(new Vector2(0.0f, newValue), selectedSpriteRect).y
                            : newValue;

                    var pivot = selectedSpritePivot;
                    pivot.y   = pivotY;
                    SetSpritePivotAndAlignment(pivot, selectedSpriteAlignment);
                }
            });

            //// Force an update of all the fields.
            PopulateSpriteFrameInspectorField();

            mainView.RegisterCallback <SpriteSelectionChangeEvent>(SelectionChange);

            // Stop mouse events from reaching the main view.
            m_SelectedFrameInspector.pickingMode = PickingMode.Ignore;
            m_SelectedFrameInspector.RegisterCallback <MouseDownEvent>((e) => { e.StopPropagation(); });
            m_SelectedFrameInspector.RegisterCallback <MouseUpEvent>((e) => { e.StopPropagation(); });
            m_SelectedFrameInspector.AddToClassList("moduleWindow");
            m_SelectedFrameInspector.AddToClassList("bottomRightFloating");
            mainView.Add(m_SelectedFrameInspector);
        }
Example #29
0
    public void OnEnable()
    {
        #region Initialization
        if (data == null)
        {
            data = Resources.Load <ProceduralDataObject>("data");
        }
        // Each editor window contains a root VisualElement object
        VisualElement root = rootVisualElement;



        // Import UXML
        var           visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Procedural++/Editor/MapCreatorWindow.uxml");
        VisualElement uxml       = visualTree.CloneTree();


        //Import Stylesheet
        var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Procedural++/Editor/MapCreatorWindow.uss");
        uxml.styleSheets.Add(styleSheet);
        root.Add(uxml);

        #endregion

        #region Buttons
        Button createButton = root.Query <Button>("createMap");
        createButton.clickable.clicked += () => {
            switch ((MapType)enumFieldMap.value)
            {
            case MapType.RandomNoise:
                previousArea = Procedural2DHelper.CreateRandomNoiseArea((int)sliderX.value, (int)sliderY.value, 0, 0);
                break;

            case MapType.Drunkard:
                previousArea = Procedural2DHelper.CreateDrunkardWalkArea((int)sliderX.value, (int)sliderY.value, 0, 0, iterationsDrunkard);
                break;

            case MapType.BSPDungeon:
                previousArea = Procedural2DHelper.CreateBSPDungeonArea((int)sliderX.value, (int)sliderY.value, 0, 0, minRooms, maxRooms, minWidth, minHeight);
                break;

            case MapType.SimpleDungeon:
                previousArea = Procedural2DHelper.CreateSimpleDungeonArea((int)sliderX.value, (int)sliderY.value, 0, 0, tryRooms, extraCorridors, minWidthS, maxWidth, minHeightS, maxHeight);
                break;

            case MapType.CellularAutomata:
                previousArea = Procedural2DHelper.CreateCellularAutomataArea((int)sliderX.value, (int)sliderY.value, cellularConfiguration.probabilities.ToArray(), 0, 0, cellularConfiguration.iterations, cellularConfiguration.numberOfTIles);
                break;
            }


            MapDrawer.DrawMapWithTileMap(previousArea);

            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        };

        Button clearButton = root.Query <Button>("clearMap");
        clearButton.clickable.clicked += () =>
        {
            MapDrawer.ClearTileMap();
        };

        Button saveButton = root.Query <Button>("saveMap");

        saveButton.clickable.clicked += () =>
        {
            if (previousArea.tileInfo != null)
            {
                string name = EditorUtility.SaveFilePanel("Save map", "./Assets", "DataMap", "bin");
                if (name != null)
                {
                    IFormatter formatter = new BinaryFormatter();
                    Stream     stream    = new FileStream(name, FileMode.Create, FileAccess.Write, FileShare.None);
                    formatter.Serialize(stream, previousArea);
                    stream.Close();
                }
            }
            else
            {
                Debug.Log("Generate an Area before saving!");
            }
        };


        Button loadButton = root.Query <Button>("loadMap");
        loadButton.clickable.clicked += () =>
        {
            string name = EditorUtility.OpenFilePanel("Load Map", "./Assets", "bin");
            if (name != null)
            {
                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = new FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read);
                previousArea = (Area)formatter.Deserialize(stream);
                MapDrawer.DrawMapWithTileMap(previousArea);
                stream.Close();
            }
        };

        #endregion

        #region SizeSliders
        sliderX        = root.Query <Slider>("sizeX");
        sizeXText      = root.Query <Label>("sizeXText");
        sizeXText.text = ((int)sliderX.value).ToString() + " size X";
        sliderX.RegisterValueChangedCallback((t) =>
        {
            sizeXText.text = ((int)t.newValue).ToString() + " size X";
        });

        sliderY        = root.Query <Slider>("sizeY");
        sizeYText      = root.Query <Label>("sizeYText");
        sizeYText.text = ((int)sliderY.value).ToString() + " size Y";

        sliderY.RegisterValueChangedCallback((t) =>
        {
            sizeYText.text = ((int)t.newValue).ToString() + " size Y";
        });

        #endregion

        #region Default General Data
        ObjectField field = root.Query <ObjectField>("tileColision");
        field.objectType = typeof(Tile);
        field.value      = data.defaultCollisionTile;

        ObjectField fieldFloor = root.Query <ObjectField>("tileFloor");
        fieldFloor.objectType = typeof(Tile);
        fieldFloor.value      = data.defaultFreeTile;

        field.RegisterValueChangedCallback((t) =>
        {
            data.defaultCollisionTile = (Tile)t.newValue;
        });

        fieldFloor.RegisterValueChangedCallback((t) =>
        {
            data.defaultFreeTile = (Tile)t.newValue;
        });


        Toggle toggle = root.Query <Toggle>("autoClear");
        toggle.value = data.autoClearTileMap;
        toggle.RegisterValueChangedCallback((t) =>
        {
            data.autoClearTileMap = t.newValue;
        });

        #endregion

        #region Map Specific Data
        parentMapSpecificData = root.Query <Box>("rootMapSpecific");
        Slider iterations = new Slider(5000, 1000000);
        iterations.label = "Iterations (5000)";
        iterations.value = iterationsDrunkard;
        iterations.RegisterValueChangedCallback((t) =>
        {
            iterations.label   = "Iterations (" + (int)t.newValue + ")";
            iterationsDrunkard = (int)t.newValue;
        });
        parentMapSpecificData.Add(iterations);



        enumFieldMap = root.Query <EnumField>("mapSelector");
        enumFieldMap.Init(MapType.Drunkard);
        enumFieldMap.RegisterValueChangedCallback((t) =>
        {
            var newValue = (MapType)t.newValue;

            switch (newValue)
            {
            case MapType.RandomNoise:
                RemoveChildsFromMapSpecificParent();
                break;

            case MapType.Drunkard:
                DrunkardEnumSwitch();
                break;

            case MapType.BSPDungeon:
                BSPDungeonSwitch();
                break;

            case MapType.SimpleDungeon:
                SimpleDungeonSwitch();
                break;

            case MapType.CellularAutomata:
                CellularAutomataSwitch();
                break;
            }
        });

        #endregion
    }
    void SelectMonster(Monster selectedMonster)
    {
        _currentSelectedMonster          = selectedMonster;
        _spellContainer.style.display    = DisplayStyle.None;
        _removeSkillButton.style.display = DisplayStyle.Flex;

        _itemInfo = _root.Q("ItemInfo");
        _itemInfo.Clear();

        var iconPreview = new Image();

        iconPreview.style.width  = 100;
        iconPreview.style.height = 100;
        // iconPreview.style.marginLeft = 10;
        iconPreview.image = _currentSelectedMonster.icon.texture;

        var icon = new ObjectField();

        icon.value      = _currentSelectedMonster.icon;
        icon.objectType = typeof(Sprite);
        icon.RegisterValueChangedCallback(changeEvent =>
        {
            iconPreview.image            = ((Sprite)changeEvent.newValue).texture;
            _currentSelectedMonster.icon = (Sprite)changeEvent.newValue;
        });

        var nameTextField = new TextField("Name");

        nameTextField.value = _currentSelectedMonster.displayName;
        nameTextField.labelElement.style.minWidth = 60;
        nameTextField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.displayName = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });

        var nameChangeButton = new Button(() =>
        {
            AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(_currentSelectedMonster), _currentSelectedMonster.displayName);
            EditorUtility.SetDirty(_currentSelectedMonster);
        });

        nameChangeButton.text           = "Change GO Name";
        nameChangeButton.style.minWidth = 60;

        var experienceField = new IntegerField("Exp/Level");

        experienceField.labelElement.style.minWidth = 60;
        experienceField.value = _currentSelectedMonster.experienceGain;
        experienceField.RegisterValueChangedCallback(changeEvent => { _currentSelectedMonster.experienceGain = changeEvent.newValue; });

        var bossToggle = new Toggle("Is Boss?");

        bossToggle.value = _currentSelectedMonster.isBoss;
        bossToggle.labelElement.style.minWidth = 60;
        bossToggle.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.isBoss = changeEvent.newValue;
            AssetDatabase.SetLabels(_currentSelectedMonster, _currentSelectedMonster.isBoss ? new string[] { "MonsterBoss" } : null);
        });

        var typeField = new EnumField("Monster Type");

        typeField.Init(_currentSelectedMonster.type);
        typeField.labelElement.style.minWidth = 90;
        typeField.style.minWidth = 200;
        typeField.RegisterValueChangedCallback(changeEvent => { _currentSelectedMonster.type = (MonsterType)changeEvent.newValue; });

        var styleField = new EnumField("Fighting Style");

        styleField.Init(_currentSelectedMonster.fightingStyle);
        styleField.labelElement.style.minWidth = 90;
        styleField.style.minWidth = 200;
        styleField.RegisterValueChangedCallback(changeEvent => { _currentSelectedMonster.fightingStyle = (FightingStyle)changeEvent.newValue; });

        var infoContainer  = new VisualElement();
        var upperContainer = new VisualElement();
        var leftContainer  = new VisualElement();

        leftContainer.style.width      = 200;
        leftContainer.style.alignItems = Align.Center;
        leftContainer.Add(iconPreview);
        leftContainer.Add(icon);
        var rightContainer = new VisualElement();

        rightContainer.style.width = 200;
        rightContainer.Add(nameTextField);
        rightContainer.Add(nameChangeButton);
        rightContainer.Add(bossToggle);
        rightContainer.Add(experienceField);
        rightContainer.Add(typeField);
        rightContainer.Add(styleField);

        upperContainer.Add(leftContainer);
        upperContainer.Add(rightContainer);
        upperContainer.style.flexDirection = FlexDirection.Row;

        var leftBotContainer = new VisualElement();

        leftBotContainer.style.width = 200;

        var strField = new IntegerField("Strength");

        strField.labelElement.style.minWidth = 80;
        strField.value = _currentSelectedMonster.coreMain.str;
        strField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreMain.str = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        leftBotContainer.Add(strField);

        var conField = new IntegerField("Constitution");

        conField.labelElement.style.minWidth = 80;
        conField.value = _currentSelectedMonster.coreMain.con;
        conField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreMain.con = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        leftBotContainer.Add(conField);

        var dexField = new IntegerField("Dexterity");

        dexField.labelElement.style.minWidth = 80;
        dexField.value = _currentSelectedMonster.coreMain.dex;
        dexField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreMain.dex = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        leftBotContainer.Add(dexField);

        var intField = new IntegerField("Intelligence");

        intField.labelElement.style.minWidth = 80;
        intField.value = _currentSelectedMonster.coreMain.intel;
        intField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreMain.intel = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        leftBotContainer.Add(intField);

        var lckField = new IntegerField("Luck");

        lckField.labelElement.style.minWidth = 80;
        lckField.value = _currentSelectedMonster.coreMain.lck;
        lckField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreMain.lck = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        leftBotContainer.Add(lckField);

        var rightBotContainer = new VisualElement();

        rightBotContainer.style.width = 200;

        var hpField = new IntegerField("Health");

        hpField.labelElement.style.minWidth = 120;
        hpField.value = _currentSelectedMonster.coreSub.hp;
        hpField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.hp = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(hpField);

        var armorField = new IntegerField("Armor");

        armorField.labelElement.style.minWidth = 120;
        armorField.value = _currentSelectedMonster.coreSub.armor;
        armorField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.armor = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(armorField);

        var dodgeField = new IntegerField("Dodge");

        dodgeField.labelElement.style.minWidth = 120;
        dodgeField.value = _currentSelectedMonster.coreSub.dodge;
        dodgeField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.dodge = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(dodgeField);

        var speedField = new IntegerField("Speed");

        speedField.labelElement.style.minWidth = 120;
        speedField.value = _currentSelectedMonster.coreSub.speed;
        speedField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.speed = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(speedField);

        var physDmgField = new IntegerField("Physical Damage");

        physDmgField.labelElement.style.minWidth = 120;
        physDmgField.value = _currentSelectedMonster.coreSub.physDmg;
        physDmgField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.physDmg = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(physDmgField);

        var physCritField = new IntegerField("Phys Crit Damage");

        physCritField.labelElement.style.minWidth = 120;
        physCritField.value = _currentSelectedMonster.coreSub.critDmg;
        physCritField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.critDmg = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(physCritField);

        var magicDmgField = new IntegerField("Magic Damage");

        magicDmgField.labelElement.style.minWidth = 120;
        magicDmgField.value = _currentSelectedMonster.coreSub.magicDmg;
        magicDmgField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.magicDmg = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(magicDmgField);

        var magicCritField = new IntegerField("Magic Crit Damage");

        magicCritField.labelElement.style.minWidth = 120;
        magicCritField.value = _currentSelectedMonster.coreSub.critMagic;
        magicCritField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.critMagic = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(magicCritField);

        var critChanceField = new IntegerField("Critical Chance");

        critChanceField.labelElement.style.minWidth = 120;
        critChanceField.value = _currentSelectedMonster.coreSub.critChance;
        critChanceField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.critChance = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(critChanceField);

        var fireResField = new IntegerField("Fire Resistance");

        fireResField.labelElement.style.minWidth = 120;
        fireResField.value = _currentSelectedMonster.coreSub.fireRes;
        fireResField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.fireRes = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(fireResField);

        var iceResField = new IntegerField("Ice Resistance");

        iceResField.labelElement.style.minWidth = 120;
        iceResField.value = _currentSelectedMonster.coreSub.iceRes;
        iceResField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.iceRes = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(iceResField);

        var lightResField = new IntegerField("Lightning Resistance");

        lightResField.labelElement.style.minWidth = 120;
        lightResField.value = _currentSelectedMonster.coreSub.lightRes;
        lightResField.RegisterValueChangedCallback(changeEvent =>
        {
            _currentSelectedMonster.coreSub.lightRes = changeEvent.newValue;
            EditorUtility.SetDirty(_currentSelectedMonster);
        });
        rightBotContainer.Add(lightResField);

        var middleContainer = new VisualElement();

        middleContainer.Add(leftBotContainer);
        middleContainer.Add(rightBotContainer);
        middleContainer.style.flexDirection = FlexDirection.Row;
        middleContainer.style.marginLeft    = 35;

        infoContainer.Add(upperContainer);

        var dividerLabel = new Label("Monster Stats");

        dividerLabel.AddToClassList("MonsterTypeTitle");
        dividerLabel.styleSheets.Add(_styleSheet);
        dividerLabel.style.marginTop = 25;
        infoContainer.Add(dividerLabel);

        infoContainer.Add(middleContainer);

        var skillsLabel = new Label("Skills");

        skillsLabel.AddToClassList("MonsterTypeTitle");
        skillsLabel.styleSheets.Add(_styleSheet);
        skillsLabel.style.marginTop = 25;
        infoContainer.Add(skillsLabel);

        var botContainer = new VisualElement();

        botContainer.style.flexDirection = FlexDirection.Row;
        botContainer.style.flexWrap      = Wrap.Wrap;
        botContainer.style.marginLeft    = 35;

        if (_currentSelectedMonster.coreSkills != null && _currentSelectedMonster.coreSkills.Length != 0)
        {
            foreach (var skill in _currentSelectedMonster.coreSkills)
            {
                var button = new Button();
                button.AddToClassList("SkillButton");
                button.styleSheets.Add(_styleSheet);

                var skillLabel = new Label(skill.displayName);
                skillLabel.AddToClassList("SkillButtonTitle");
                skillLabel.styleSheets.Add(_styleSheet);
                button.Add(skillLabel);

                var skillIcon = new Image();
                skillIcon.AddToClassList("SkillButtonIcon");
                skillIcon.styleSheets.Add(_styleSheet);
                skillIcon.image = skill.icon.texture;
                button.Add(skillIcon);

                botContainer.Add(button);
            }
        }

        var newButton = new Button(() => ShowSkillPicker());

        newButton.AddToClassList("SkillButton");
        newButton.styleSheets.Add(_styleSheet);

        var newLabel = new Label("Add Skill");

        newLabel.AddToClassList("SkillButtonTitle");
        newLabel.styleSheets.Add(_styleSheet);
        newButton.Add(newLabel);

        botContainer.Add(newButton);
        infoContainer.Add(botContainer);

        _itemInfo.Add(infoContainer);

        _backToSkillsButton.style.display = DisplayStyle.Flex;
        _itemInfo.style.display           = DisplayStyle.Flex;
    }