public void Initialize(string axisAssetName)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("AxisNameObject/");
            sb.Append(axisAssetName);

            axisNames = Resources.Load <AxisNameAsset>(sb.ToString());
            if (axisNames == null)
            {
                axisNames = new AxisNameAsset();
                axisNames.LeftAnalogStickX  = DefaultAxisNames.LeftAnalogStickX;
                axisNames.LeftAnalogStickY  = DefaultAxisNames.LeftAnalogStickY;
                axisNames.RightAnalogStickX = DefaultAxisNames.RightAnalogStickX;
                axisNames.RightAnalogStickY = DefaultAxisNames.RightAnalogStickY;
                axisNames.DPadX             = DefaultAxisNames.DPadX;
                axisNames.DPadY             = DefaultAxisNames.DPadY;
                axisNames.LTrigger          = DefaultAxisNames.LTrigger;
                axisNames.RTrigger          = DefaultAxisNames.RTrigger;
            }

            axisKeys = new List <string>()
            {
                axisNames.LeftAnalogStickX,
                axisNames.LeftAnalogStickY,
                axisNames.RightAnalogStickX,
                axisNames.RightAnalogStickY,
                axisNames.DPadX,
                axisNames.DPadY,
                axisNames.LTrigger,
                axisNames.RTrigger
            };

            axisValueDict = new Dictionary <string, AxisValues>();
            foreach (var key in axisKeys)
            {
                axisValueDict[key] = new AxisValues(key);
            }

            axisValueDict[axisNames.LTrigger].SetThreshold(axisNames.LTriggerThreshold);
            axisValueDict[axisNames.RTrigger].SetThreshold(axisNames.RTriggerThreshold);
            axisValueDict[axisNames.LeftAnalogStickX].SetThreshold(axisNames.LStickXThreshold);
            axisValueDict[axisNames.LeftAnalogStickY].SetThreshold(axisNames.LStickYThreshold);
            axisValueDict[axisNames.RightAnalogStickX].SetThreshold(axisNames.RStickXThreshold);
            axisValueDict[axisNames.RightAnalogStickY].SetThreshold(axisNames.RStickYThreshold);
        }
Esempio n. 2
0
        public void ApplyAxisName(string axisNameAssetPath)
        {
            AxisNameAsset axisNames = Resources.Load <AxisNameAsset>(axisNameAssetPath);

            if (axisNames == null)
            {
                axisNames = new AxisNameAsset();
                axisNames.LeftAnalogStickX  = DefaultAxisNames.LeftAnalogStickX;
                axisNames.LeftAnalogStickY  = DefaultAxisNames.LeftAnalogStickY;
                axisNames.RightAnalogStickX = DefaultAxisNames.RightAnalogStickX;
                axisNames.RightAnalogStickY = DefaultAxisNames.RightAnalogStickY;
                axisNames.DPadX             = DefaultAxisNames.DPadX;
                axisNames.DPadY             = DefaultAxisNames.DPadY;
                axisNames.LTrigger          = DefaultAxisNames.LTrigger;
                axisNames.RTrigger          = DefaultAxisNames.RTrigger;
            }

            axisKeys = new List <string>()
            {
                axisNames.LeftAnalogStickX,
                axisNames.LeftAnalogStickY,
                axisNames.RightAnalogStickX,
                axisNames.RightAnalogStickY,
                axisNames.DPadX,
                axisNames.DPadY,
                axisNames.LTrigger,
                axisNames.RTrigger
            };

            axisValueDict = new Dictionary <string, AxisValues>();
            foreach (var key in axisKeys)
            {
                axisValueDict[key] = new AxisValues(key);
            }

            axisValueDict[axisNames.LTrigger].SetThreshold(axisNames.LTriggerThreshold);
            axisValueDict[axisNames.RTrigger].SetThreshold(axisNames.RTriggerThreshold);
            axisValueDict[axisNames.LeftAnalogStickX].SetThreshold(axisNames.LStickXThreshold);
            axisValueDict[axisNames.LeftAnalogStickY].SetThreshold(axisNames.LStickYThreshold);
            axisValueDict[axisNames.RightAnalogStickX].SetThreshold(axisNames.RStickXThreshold);
            axisValueDict[axisNames.RightAnalogStickY].SetThreshold(axisNames.RStickYThreshold);
        }