Beispiel #1
0
        private void DrawFields(QualiScorerData qsData)
        {
            EnumField qualTypeField = new EnumField("type", Qualifier.QualiType.SumOfChildren);

            qualTypeField.BindProperty(serData.FindPropertyRelative("qualiType"));
            LimitedFloatField thresholdField = new LimitedFloatField("threshold", 0, 1);

            thresholdField.BindProperty(serData.FindPropertyRelative("threshold"));

            contentContainer.Add(qualTypeField);
            contentContainer.Add(thresholdField);
        }
Beispiel #2
0
        private void DrawFields(QualifierData qData, List <string> actions)
        {
            EnumField qualTypeField = new EnumField("type", QualiScorer.QualiType.SumOfChildren);

            qualTypeField.BindProperty(serData.FindPropertyRelative("qualiType"));
            LimitedFloatField thresholdField = new LimitedFloatField("threshold", 0, 1);

            thresholdField.BindProperty(serData.FindPropertyRelative("threshold"));
            int actionIndex = actions.IndexOf(qData.actionName);
            PopupField <string> actionNameField = new PopupField <string>("action", actions, actionIndex);

            actionNameField.BindProperty(serData.FindPropertyRelative("actionName"));

            contentContainer.Add(qualTypeField);
            contentContainer.Add(thresholdField);
            contentContainer.Add(actionNameField);
        }
Beispiel #3
0
    VisualElement CreateBeatElement(BeatAttack.BeatDamageProperties damagePropertiese, int beatNum)
    {
        VisualElement element = new VisualElement();

        _visualTreeBeat.CloneTree(element);

        /*
         * element.Add(new Label(damagePropertiese._damageType.ToString()));
         * element.Add(new Label("Damage Type"));
         *
         *
         * element.Add(new Label(damagePropertiese.Strentgh.ToString()));
         * element.Add(new Label("Strentgh"));
         */

        SerializedObject so = new  SerializedObject(_beatAttack);

        foreach (SerializedProperty o in so.GetIterator())
        {
            //Debug.Log("o" + o + " " + o.propertyPath);
        }


        string beat = beatNum.ToString();

        element.Q <Label>("BeatNum").text = "Beat " + beat;

        EnumField damageType = element.Q <EnumField>("DamageType");

        damageType.BindProperty(so.FindProperty("Damages.Array.data[" + beat + "]._damageType"));
        //damageType.value = damagePropertiese._damageType;

        FloatField stength = element.Q <FloatField>("strength");
        //stength.value = damagePropertiese.Strentgh;



        SerializedProperty sp = so.FindProperty("Damages.Array.data[" + beat + "].Strentgh");

        Debug.Log("Sp" + sp);
        stength.BindProperty(sp);


        float maxStr = 0f;

        foreach (BeatAttack.BeatDamageProperties tmpdamagePropertiese in _beatAttack.Damages)
        {
            if (tmpdamagePropertiese.Strentgh > maxStr)
            {
                maxStr = tmpdamagePropertiese.Strentgh;
                break;
            }
        }

        ProgressBar strengthProgressBar = element.Q <ProgressBar>("StrengthBar");
        float       progval             = 0f;

        if (maxStr > 0f)
        {
            progval = damagePropertiese.Strentgh / maxStr;
        }

        strengthProgressBar.value = progval;


        //Debug.Log(typeof(Sprite).AssemblyQualifiedName);
        ObjectField spriteField = element.Q <ObjectField>("Sprite");

        spriteField.BindProperty(so.FindProperty("Damages.Array.data[" + beat + "].sprite"));
        //spriteField.value = damagePropertiese.sprite;

        // TODO - Make this change when you change sprite
        VisualElement beatSprite      = element.Q <VisualElement>("SpriteInBeat");
        IStyle        beatSpriteStyle = beatSprite.style;

        beatSpriteStyle.backgroundImage = damagePropertiese.sprite.texture;


        EnumField moveType = element.Q <EnumField>("MoveDirection");

        moveType.BindProperty(so.FindProperty("Damages.Array.data[" + beat + "].moveDirection"));



        return(element);
    }
        /// <summary>
        /// Creates the UI elements and registers callbacks.
        /// </summary>
        public void OnEnable()
        {
            syncBehaviour     = target as RemoteConfigSyncBehaviour;
            rootVisualElement = new VisualElement();
            rootVisualElement.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(stylePath));

            // Show the Script field (not-editable) like standard inspectors do.
            var script      = MonoScript.FromMonoBehaviour(syncBehaviour);
            var scriptField = new ObjectField("Script")
            {
                value = script
            };

            scriptField.SetEnabled(false);
            rootVisualElement.Add(scriptField);

            // PrefixSource enum dropdown control. When PrefixSource changes, observe whether the
            // KeyPrefix field should be shown/hidden.
            var prefixSourceProp = serializedObject.FindProperty("PrefixSource");

            prefixSourceField = new EnumField("Prefix Source", syncBehaviour.PrefixSource);
            prefixSourceField.BindProperty(prefixSourceProp);
            prefixSourceField.RegisterCallback <ChangeEvent <Enum> >(OnPrefixSourceChange);
            rootVisualElement.Add(prefixSourceField);

            // KeyPrefix control, only shown if syncBehaviour.PrefixSource == PrefixSource.Custom.
            var keyPrefixProperty = serializedObject.FindProperty("KeyPrefix");

            keyPrefixField = new PropertyField(keyPrefixProperty);
            if (syncBehaviour.PrefixSource == PrefixSource.Custom)
            {
                rootVisualElement.Add(keyPrefixField);
            }

            // Sync All Fields control.
            var syncAllProp = serializedObject.FindProperty("SyncAllFields");

            syncAllField = new PropertyField(syncAllProp);
            syncAllField.RegisterCallback <ChangeEvent <bool> >(OnSyncAllFieldsChange);
            rootVisualElement.Add(syncAllField);

            // Include sub-fields
            var includeSubProp = serializedObject.FindProperty("IncludeSubFields");

            includeSubFieldsField = new PropertyField(includeSubProp);
            if (syncBehaviour.SyncAllFields)
            {
                rootVisualElement.Add(includeSubFieldsField);
            }

            var buttonContainer = new TemplateContainer();

            // Use row class to place buttons side-by-side.
            buttonContainer.AddToClassList("row");

            // Add a button that can invoke the SyncFields function on the object during gameplay.
            var syncButton = new Button(() => SyncFields())
            {
                text = "Sync Fields"
            };

            buttonContainer.Add(syncButton);

            // Add a button that prompts RemoteConfigSyncUIWindow to update sync targets.
            var updateButton = new Button(() => SyncWindow.RefreshSyncTargets())
            {
                text = "Update targets"
            };

            buttonContainer.Add(updateButton);

            // Add button to open the RemoteConfigSyncWindow.
            var rcWindowButton = new Button(() => SyncWindow.OpenWindow())
            {
                text = "Open Sync Window"
            };

            buttonContainer.Add(rcWindowButton);
            rootVisualElement.Add(buttonContainer);
        }