Ejemplo n.º 1
0
    void updateSpring()
    {
        dashhorizontal.gameObject.SetActive(true);
        dashmoving.gameObject.SetActive(false);
        label.gameObject.SetActive(true);

        SpringControl spring = this.gameObject.GetComponent <SpringControl>();
        v3            pos    = spring.attachPoint2;

        pos.z = 0;
        v3 localpos = Camera.main.WorldToScreenPoint(pos) / this.canvas.localScale.x;

        localpos.z = 0;

        //set position and angle
        dashhorizontal.anchoredPosition = localpos;
        dashhorizontal.eulerAngles      = v3.zero;

        float length = trans.localScale.y * Util.SpringHeightMultiplier * Util.WorldToScreenMultiplier;

        dashhorizontal.sizeDelta = new v2(length, 3f);

        v3    movingdir   = (spring.attachPoint1 - spring.attachPoint2);
        float signedangle = v2.SignedAngle(new v2(100, 0), movingdir);

        Text t = label.GetComponent <Text>();

        t.text = Mathf.Round(Mathf.Abs(signedangle) * 100f) / 100f + "°";

        signedangle /= 2f;
        v3 direction = new v3(Mathf.Cos(Mathf.Deg2Rad * signedangle), Mathf.Sin(Mathf.Deg2Rad * signedangle)).normalized;

        length = 90;
        label.anchoredPosition = localpos + direction * length;
    }
 public AnchorUI(AnchorEditor editor)
 {
     this.editor = editor;
     this.left = new SpringControl(this);
     this.right = new SpringControl(this);
     this.top = new SpringControl(this);
     this.bottom = new SpringControl(this);
     this.tabOrder = new SpringControl[] { this.left, this.top, this.right, this.bottom };
     this.InitializeComponent();
 }
Ejemplo n.º 3
0
 public AnchorUI(AnchorEditor editor)
 {
     this.editor   = editor;
     this.left     = new SpringControl(this);
     this.right    = new SpringControl(this);
     this.top      = new SpringControl(this);
     this.bottom   = new SpringControl(this);
     this.tabOrder = new SpringControl[] { this.left, this.top, this.right, this.bottom };
     this.InitializeComponent();
 }
Ejemplo n.º 4
0
            public AnchorUI(AnchorEditor editor)
            {
                this.editor = editor;
                left        = new SpringControl(this);
                right       = new SpringControl(this);
                top         = new SpringControl(this);
                bottom      = new SpringControl(this);
                tabOrder    = new[] { left, top, right, bottom };

                InitializeComponent();
            }
Ejemplo n.º 5
0
            public AnchorUI(AnchorEditor editor)
            {
                this.editor = editor;
                left        = new SpringControl(this)
                {
                    AccessibleRole = AccessibleRole.CheckButton
                };
                right = new SpringControl(this)
                {
                    AccessibleRole = AccessibleRole.CheckButton
                };
                top = new SpringControl(this)
                {
                    AccessibleRole = AccessibleRole.CheckButton
                };
                bottom = new SpringControl(this)
                {
                    AccessibleRole = AccessibleRole.CheckButton
                };
                tabOrder = new[] { left, top, right, bottom };

                InitializeComponent();
            }
Ejemplo n.º 6
0
 public SpringControlAccessibleObject(SpringControl owner) : base(owner)
 {
 }
Ejemplo n.º 7
0
    public void fieldValueChange(int idx)
    {
        double val;
        string text = inputFields[idx].text;

        if (text == "")
        {
            val = 0;
        }
        else if (!double.TryParse(text, out val))
        {
            return;
        }

        if (idx == 0)
        {
            (float, float)bounds = (0.01f, 1000f);
            float value = (float)val;
            value       = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
            rbcurr.mass = value;
            sliders[idx].SetValueWithoutNotify((value - bounds.Item1) / bounds.Item2);
            if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
            {
                inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
            }
        }
        else if (idx == 1)
        {
            (float, float)bounds = (0.01f, 1000f);
            float value = (float)val;
            value = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
            float length = value;
            if (namecurr == "FixedRectangle")
            {
                transcurr.localScale = new v2(length / Util.FixedRectWidthMultiplier, transcurr.localScale.y);
            }
            else if (namecurr == "MoveableRectangle")
            {
                transcurr.localScale = new v2(length / Util.MoveableRectWidthMultiplier, transcurr.localScale.y);
            }
            sliders[idx].SetValueWithoutNotify((length - bounds.Item1) / bounds.Item2);
            if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
            {
                inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(length * 100f) / 100f);
            }
        }
        else if (idx == 2)
        {
            (float, float)bounds = (0.01f, 1000f);
            float value = (float)val;
            value = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
            float width = value;
            if (namecurr == "FixedRectangle")
            {
                transcurr.localScale = new v2(transcurr.localScale.x, width / Util.FixedRectHeightMultiplier);
            }
            else if (namecurr == "MoveableRectangle")
            {
                transcurr.localScale = new v2(transcurr.localScale.x, width / Util.MoveableRectHeightMultiplier);
            }
            sliders[idx].SetValueWithoutNotify((width - bounds.Item1) / bounds.Item2);
            if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
            {
                inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(width * 100f) / 100f);
            }
        }
        else if (idx == 3) //circle
        {
            (float, float)bounds = (0.01f, 100f);
            float value = (float)val;
            value = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
            transcurr.localScale = new v2(value, value);
            sliders[idx].SetValueWithoutNotify((value - bounds.Item1) / bounds.Item2);
            if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
            {
                inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
            }
        }
        else if (idx == 4)
        {
            (float, float)bounds = (0.01f, 1000f);
            float value = (float)val;
            value = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
            SpringControl spring = focused.GetComponent <SpringControl>();
            spring.setSpringConstant(value);
            sliders[idx].SetValueWithoutNotify((value - bounds.Item1) / bounds.Item2);
            if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
            {
                inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
            }
        }
        else if (idx == 5)
        {
            (float, float)bounds = (0.01f, 1000f);
            float value = (float)val;
            value = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
            ForceControl force = focused.GetComponent <ForceControl>();
            if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
            {
                inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
            }
            force.setForce(value);
            //sliders[idx].SetValueWithoutNotify((value - bounds.Item1) / bounds.Item2);
            //inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
        }
        else if (idx == 6)
        {
            (float, float)bounds = (0.01f, 100f);
            float value = (float)val;
            value = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
            VelocityControl velocity = focused.GetComponent <VelocityControl>();
            if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
            {
                inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
            }
            velocity.setSpeed(value);
        }
        else if (idx == 7)
        {
            (float, float)bounds = (0f, 360f);
            float value = (float)val;
            value = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
            if (namecurr == "Force")
            {
                if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
                {
                    inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
                }
                this.focused.GetComponent <ForceControl>().setAngle(value);
            }
            else if (namecurr == "Velocity")
            {
                if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
                {
                    inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
                }
                this.focused.GetComponent <VelocityControl>().setAngle(value);
            }
            else
            {
                transcurr.localEulerAngles = new v3(0, 0, value);
                sliders[idx].SetValueWithoutNotify((value - bounds.Item1) / bounds.Item2);
                if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
                {
                    inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
                }
            }
        }
        else if (idx == 8) //equilibrium length
        {
            (float, float)bounds = (0.01f, 100f);
            float value = (float)val;
            value = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
            SpringControl spring = focused.GetComponent <SpringControl>();
            spring.setElength(value);
            sliders[idx].SetValueWithoutNotify((value - bounds.Item1) / bounds.Item2);
            if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
            {
                inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
            }
        }
        else if (idx == 9) //break force (N)
        {
            (double, double)bounds = (0.01, 999999999);
            SpringControl spring     = focused.GetComponent <SpringControl>();
            double        breakforce = Math.Max(Math.Min(val, bounds.Item2), bounds.Item1);
            spring.setBreakForce(breakforce);
            sliders[idx].SetValueWithoutNotify((float)((breakforce - bounds.Item1) / bounds.Item2));
            if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
            {
                inputFields[idx].SetTextWithoutNotify("" + Math.Round(breakforce * 100f) / 100f);
            }
        }
        else if (idx == 10)
        {
            (float, float)bounds = (0f, 1f);
            Collider2D col   = focused.GetComponent <Collider2D>();
            float      value = (float)val;
            value = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
            col.sharedMaterial.friction = value;
            Attachable.ResetAllColliders();
            sliders[idx].SetValueWithoutNotify((value - bounds.Item1) / bounds.Item2);
            if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains(".")))
            {
                inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
            }
        }
        //else if (idx == 10)
        //{
        //    (float, float) bounds = (0f, 1f);
        //    Collider2D col = focused.GetComponent<Collider2D>();
        //    float value = (float)val;
        //    value = Mathf.Clamp(value, bounds.Item1, bounds.Item2);
        //    col.sharedMaterial.bounciness = value;
        //    sliders[idx].SetValueWithoutNotify((value - bounds.Item1) / bounds.Item2);
        //    if ((text[text.Length - 1] != '.' && text[text.Length - 1] != '0') || (text[text.Length - 1] == '0' && !text.Contains("."))) inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(value * 100f) / 100f);
        //}
        //else if (idx == 11)
        //{

        //}
    }
Ejemplo n.º 8
0
    public void sliderValueChange(int idx)
    {
        if (sliders[idx].gameObject != EventSystem.current.currentSelectedGameObject)
        {
            return;
        }
        // Debug.Log(idx);
        float value = sliders[idx].value;

        if (idx == 0)
        {
            (float, float)bounds = (0.01f, 1000f);
            float mass = bounds.Item1 + value / 1f * (bounds.Item2 - bounds.Item1);
            rbcurr.mass = mass;
            inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(mass * 100f) / 100f);
        }
        else if (idx == 1)
        {
            (float, float)bounds = (0.01f, 1000f);
            float length = bounds.Item1 + value / 1f * (bounds.Item2 - bounds.Item1);
            if (namecurr == "FixedRectangle")
            {
                transcurr.localScale = new v2(length / Util.FixedRectWidthMultiplier, transcurr.localScale.y);
            }
            else if (namecurr == "MoveableRectangle")
            {
                transcurr.localScale = new v2(length / Util.MoveableRectWidthMultiplier, transcurr.localScale.y);
            }
            inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(length * 100f) / 100f);
        }
        else if (idx == 2)
        {
            (float, float)bounds = (0.01f, 1000f);
            float width = bounds.Item1 + value / 1f * (bounds.Item2 - bounds.Item1);
            if (namecurr == "FixedRectangle")
            {
                transcurr.localScale = new v2(transcurr.localScale.x, width / Util.FixedRectHeightMultiplier);
            }
            else if (namecurr == "MoveableRectangle")
            {
                transcurr.localScale = new v2(transcurr.localScale.x, width / Util.MoveableRectHeightMultiplier);
            }
            inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(width * 100f) / 100f);
        }
        else if (idx == 3) //circle
        {
            (float, float)bounds = (0.01f, 100f);
            float diameter = bounds.Item1 + value / 1f * (bounds.Item2 - bounds.Item1);
            transcurr.localScale = new v2(diameter, diameter);
            inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(diameter * 100f) / 100f);
        }
        else if (idx == 4) //spring constant (N/m)
        {
            (float, float)bounds = (0.01f, 1000f);
            SpringControl spring   = focused.GetComponent <SpringControl>();
            float         constant = bounds.Item1 + value / 1f * (bounds.Item2 - bounds.Item1);
            spring.setSpringConstant(constant);
            inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(constant * 100f) / 100f);
        }
        else if (idx == 5) //force
        {
            (float, float)bounds = (0.01f, 1000f);
            float        newtons = bounds.Item1 + value / 1f * (bounds.Item2 - bounds.Item1);
            ForceControl force   = focused.GetComponent <ForceControl>();
            force.setForce(newtons);
            //inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(newtons * 100f) / 100f);
        }
        else if (idx == 6) //velocity
        {
            (float, float)bounds = (0.01f, 100f);
            float           speed    = bounds.Item1 + value / 1f * (bounds.Item2 - bounds.Item1);
            VelocityControl velocity = focused.GetComponent <VelocityControl>();
            velocity.setSpeed(speed);
        }
        else if (idx == 7)
        {
            (float, float)bounds = (0f, 360f);
            float angle = bounds.Item1 + value / 1f * (bounds.Item2 - bounds.Item1);
            if (namecurr == "Force")
            {
                this.focused.GetComponent <ForceControl>().setAngle(angle);
            }
            else if (namecurr == "Velocity")
            {
                this.focused.GetComponent <VelocityControl>().setAngle(angle);
            }
            else
            {
                transcurr.localEulerAngles = new v3(0, 0, angle);
                inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(angle * 100f) / 100f);
            }
        }
        else if (idx == 8) //equilibrium length
        {
            (float, float)bounds = (0.01f, 100f);
            SpringControl spring  = focused.GetComponent <SpringControl>();
            float         elength = bounds.Item1 + value / 1f * (bounds.Item2 - bounds.Item1);
            spring.setElength(elength);
            inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(elength * 100f) / 100f);
        }
        else if (idx == 9) //break force (N)
        {
            (double, double)bounds = (0.01, 999999999);
            SpringControl spring     = focused.GetComponent <SpringControl>();
            double        breakforce = bounds.Item1 + value * (bounds.Item2 - bounds.Item1);
            spring.setBreakForce(breakforce);
            inputFields[idx].SetTextWithoutNotify("" + Math.Round(breakforce * 100f) / 100f);
        }
        else if (idx == 10)
        {
            (float, float)bounds = (0f, 1f);
            Collider2D col      = focused.GetComponent <Collider2D>();
            float      friction = bounds.Item1 + value * (bounds.Item2 - bounds.Item1);
            col.sharedMaterial.friction = friction;
            Attachable.ResetAllColliders();
            inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(friction * 100f) / 100f);
        }
        //else if (idx == 10)
        //{
        //    (float, float) bounds = (0f, 1f);
        //    Collider2D col = focused.GetComponent<Collider2D>();
        //    float bounciness = bounds.Item1 + value * (bounds.Item2 - bounds.Item1);
        //    col.sharedMaterial.bounciness = bounciness;
        //    inputFields[idx].SetTextWithoutNotify("" + Mathf.Round(bounciness * 100f) / 100f);
        //}
        //else if (idx == 11)
        //{

        //}
    }
Ejemplo n.º 9
0
 private void AdjustValues()
 {
     for (int i = 0, tempmask = currmask; tempmask != 0; i++, tempmask >>= 1)
     {
         if ((tempmask & 1) != 1)
         {
             continue;
         }
         if (i == 0)
         {
             (float, float)bounds = (0.01f, 1000f);
             sliders[i].SetValueWithoutNotify((rbcurr.mass - bounds.Item1) / bounds.Item2);
             inputFields[i].SetTextWithoutNotify("" + Mathf.Round(rbcurr.mass * 100f) / 100f);
         }
         else if (i == 1)
         {
             (float, float)bounds = (0.01f, 1000f);
             float length = 0f;
             if (namecurr == "FixedRectangle")
             {
                 length = transcurr.localScale.x * Util.FixedRectWidthMultiplier;
             }
             else if (namecurr == "MoveableRectangle")
             {
                 length = transcurr.localScale.x * Util.MoveableRectWidthMultiplier;
             }
             sliders[i].SetValueWithoutNotify((length - bounds.Item1) / bounds.Item2);
             inputFields[i].SetTextWithoutNotify("" + Mathf.Round(length * 100f) / 100f);
         }
         else if (i == 2)
         {
             (float, float)bounds = (0.01f, 1000f);
             float width = 0f;
             if (namecurr == "FixedRectangle")
             {
                 width = transcurr.localScale.y * Util.FixedRectHeightMultiplier;
             }
             else if (namecurr == "MoveableRectangle")
             {
                 width = transcurr.localScale.y * Util.MoveableRectHeightMultiplier;
             }
             sliders[i].SetValueWithoutNotify((width - bounds.Item1) / bounds.Item2);
             inputFields[i].SetTextWithoutNotify("" + Mathf.Round(width * 100f) / 100f);
         }
         else if (i == 3) //circle
         {
             (float, float)bounds = (0.01f, 100f);
             float diameter = transcurr.localScale.x;
             sliders[i].SetValueWithoutNotify((diameter - bounds.Item1) / bounds.Item2);
             inputFields[i].SetTextWithoutNotify("" + Mathf.Round(diameter * 100f) / 100f);
         }
         else if (i == 4) //spring constant (N/m)
         {
             (float, float)bounds = (0.01f, 1000f);
             SpringControl spring   = focused.GetComponent <SpringControl>();
             float         constant = Mathf.Clamp(spring.getSpringConstant(), bounds.Item1, bounds.Item2);
             sliders[i].SetValueWithoutNotify((constant - bounds.Item1) / bounds.Item2);
             inputFields[i].SetTextWithoutNotify("" + Mathf.Round(constant * 100f) / 100f);
         }
         else if (i == 5) //force
         {
             (float, float)bounds = (0.01f, 1000f);
             ForceControl force   = focused.GetComponent <ForceControl>();
             float        newtons = Mathf.Clamp(force.getForce(), bounds.Item1, bounds.Item2);
             sliders[i].SetValueWithoutNotify((newtons - bounds.Item1) / bounds.Item2);
             inputFields[i].SetTextWithoutNotify("" + Mathf.Round(newtons * 100f) / 100f);
         }
         else if (i == 6) //velocity
         {
             (float, float)bounds = (0.01f, 100f);
             VelocityControl velocity = focused.GetComponent <VelocityControl>();
             float           speed    = Mathf.Clamp(velocity.getSpeed(), bounds.Item1, bounds.Item2);
             sliders[i].SetValueWithoutNotify((speed - bounds.Item1) / bounds.Item2);
             inputFields[i].SetTextWithoutNotify("" + Mathf.Round(speed * 100f) / 100f);
         }
         else if (i == 7)
         {
             (float, float)bounds = (0f, 360f);
             float angle = transcurr.localEulerAngles.z;
             if (namecurr == "Force")
             {
                 ForceControl force = focused.GetComponent <ForceControl>();
                 if (force == null)
                 {
                     return;
                 }
                 angle = Mathf.Clamp(force.getAngle(), bounds.Item1, bounds.Item2);
             }
             else if (namecurr == "Velocity")
             {
                 VelocityControl velocity = focused.GetComponent <VelocityControl>();
                 if (velocity == null)
                 {
                     return;
                 }
                 angle = Mathf.Clamp(velocity.getAngle(), bounds.Item1, bounds.Item2);
             }
             else
             {
                 angle = Mathf.Clamp(transcurr.localEulerAngles.z, bounds.Item1, bounds.Item2);
             }
             sliders[i].SetValueWithoutNotify((angle - bounds.Item1) / bounds.Item2);
             inputFields[i].SetTextWithoutNotify("" + Mathf.Round(angle * 100f) / 100f);
         }
         else if (i == 8) //equilibrium length
         {
             //cannot set this property when spring is attached
             SpringControl spring = focused.GetComponent <SpringControl>();
             //if (!spring.available()) { this.CoerceAdjustValues(8); return; }
             (float, float)bounds = (0.01f, 100f);
             float elength = Mathf.Clamp(spring.getElength(), bounds.Item1, bounds.Item2);
             sliders[i].SetValueWithoutNotify((elength - bounds.Item1) / bounds.Item2);
             inputFields[i].SetTextWithoutNotify("" + Mathf.Round(elength * 100f) / 100f);
         }
         else if (i == 9) //break force (N)
         {
             (double, double)bounds = (0.01, 999999999);
             SpringControl spring     = focused.GetComponent <SpringControl>();
             double        breakforce = Math.Max(Math.Min(spring.getBreakForce(), bounds.Item2), bounds.Item1);
             sliders[i].SetValueWithoutNotify((float)((breakforce - bounds.Item1) / bounds.Item2));
             inputFields[i].SetTextWithoutNotify("" + Math.Round(breakforce * 100f) / 100f);
         }
         else if (i == 10)
         {
             (float, float)bounds = (0f, 1f);
             Collider2D col = focused.GetComponent <Collider2D>();
             sliders[i].SetValueWithoutNotify((col.sharedMaterial.friction - bounds.Item1) / bounds.Item2);
             inputFields[i].SetTextWithoutNotify("" + Mathf.Round(col.sharedMaterial.friction * 100f) / 100f);
         }
         //else if (i == 10)
         //{
         //    (float, float) bounds = (0f, 1f);
         //    Collider2D col = focused.GetComponent<Collider2D>();
         //    sliders[i].SetValueWithoutNotify((col.bounciness - bounds.Item1) / bounds.Item2);
         //    inputFields[i].SetTextWithoutNotify("" + Mathf.Round(col.bounciness * 100f) / 100f);
         //}
         //else if (i == 11)
         //{
         //    (float, float) bounds = (0f, 1f);
         //    Collider2D col = focused.GetComponent<Collider2D>();
         //    sliders[i].SetValueWithoutNotify((col.friction - bounds.Item1) / bounds.Item2);
         //    inputFields[i].SetTextWithoutNotify("" + Mathf.Round(col.friction * 100f) / 100f);
         //}
     }
 }
Ejemplo n.º 10
0
 /* Autogenerated by R# */
 public bool Equals(AdventurePhysics other) => HangTime == other.HangTime && FloorGrip.Equals(other.FloorGrip) && HorizontalSpeedCap.Equals(other.HorizontalSpeedCap) && VerticalSpeedCap.Equals(other.VerticalSpeedCap) && UnknownAccelRelated.Equals(other.UnknownAccelRelated) && Unknown1.Equals(other.Unknown1) && InitialJumpSpeed.Equals(other.InitialJumpSpeed) && SpringControl.Equals(other.SpringControl) && Unknown2.Equals(other.Unknown2) && RollingMinimumSpeed.Equals(other.RollingMinimumSpeed) && RollingEndSpeed.Equals(other.RollingEndSpeed) && Action1Speed.Equals(other.Action1Speed) && MinWallHitKnockbackSpeed.Equals(other.MinWallHitKnockbackSpeed) && Action2Speed.Equals(other.Action2Speed) && JumpHoldAddSpeed.Equals(other.JumpHoldAddSpeed) && GroundStartingAcceleration.Equals(other.GroundStartingAcceleration) && AirAcceleration.Equals(other.AirAcceleration) && GroundDeceleration.Equals(other.GroundDeceleration) && BrakeSpeed.Equals(other.BrakeSpeed) && AirBrakeSpeed.Equals(other.AirBrakeSpeed) && AirDeceleration.Equals(other.AirDeceleration) && RollingDeceleration.Equals(other.RollingDeceleration) && GravityOffsetSpeed.Equals(other.GravityOffsetSpeed) && MidAirSwerveAcceleration.Equals(other.MidAirSwerveAcceleration) && MinSpeedBeforeStopping.Equals(other.MinSpeedBeforeStopping) && ConstantSpeedOffset.Equals(other.ConstantSpeedOffset) && UnknownOffRoad.Equals(other.UnknownOffRoad) && Unknown3.Equals(other.Unknown3) && Unknown4.Equals(other.Unknown4) && CollisionSize.Equals(other.CollisionSize) && GravitationalPull.Equals(other.GravitationalPull) && YOffsetCamera.Equals(other.YOffsetCamera) && YOffset.Equals(other.YOffset);
Ejemplo n.º 11
0
    public void OnDrop(PointerEventData eventData)
    {
        if (eventData.pointerDrag == null)
        {
            return;
        }
        Vector3 pos = eventData.position;

        //check if pos is inside of scrollViewRect
        if (Util.OnCanvas(pos))
        {
            //this is the object being dropped
            //instantiate a new object in the canvass
            GameObject        ui          = eventData.pointerDrag;
            ObjectDragHandler draghandler = ui.GetComponent <ObjectDragHandler>();
            if (draghandler == null)
            {
                return;
            }
            GameObject reference = draghandler.spritePreFab;
            GameObject newObj    = Instantiate(reference) as GameObject;
            newObj.SetActive(true);
            Vector3 worldPos = Camera.main.ScreenToWorldPoint(eventData.position);
            worldPos.z = 0;
            newObj.transform.position = worldPos;

            //Check for spring
            SpringControl      spring   = newObj.GetComponent <SpringControl>();
            ForceControl       force    = newObj.GetComponent <ForceControl>();
            VelocityControl    velocity = newObj.GetComponent <VelocityControl>();
            PropertiesEditable edit     = newObj.GetComponent <PropertiesEditable>();
            ReplayControl      replay   = newObj.GetComponent <ReplayControl>();
            Name name = newObj.GetComponent <Name>();
            if (spring != null) //if this is a spring
            {
                spring.attachPoint1 = worldPos + new Vector3(0, SpringControl.defaultHeight / 2f, 0);
                spring.attachPoint2 = worldPos - new Vector3(0, SpringControl.defaultHeight / 2f, 0);
            }
            if (force != null) //if this is a force arrow
            {
                force.attachPoint1 = worldPos + new Vector3(0, ForceControl.defaultHeight / 2f, 0);
                force.attachPoint2 = worldPos - new Vector3(0, ForceControl.defaultHeight / 2f, 0);
            }
            if (velocity != null)
            {
                velocity.attachPoint1 = worldPos + new Vector3(0, VelocityControl.defaultHeight / 2f, 0);
                velocity.attachPoint2 = worldPos - new Vector3(0, VelocityControl.defaultHeight / 2f, 0);
            }
            if (replay != null)
            {
                ReplayControl.focusedObject = newObj;
            }
            if (edit != null)
            {
                PropertiesEditable.focusedObject = newObj;
            }
            //if (name.objectname == "FixedRectangle" || name.objectname == "MoveableRectangle" || name.objectname == "Circle")
            //{
            //    Collider2D col = newObj.GetComponent<Collider2D>();
            //    PhysicsMaterial2D material = new PhysicsMaterial2D();
            //    material.friction = 0.4f;
            //    material.bounciness = 0.4f;
            //    col.sharedMaterial = material;
            //}
        }
        //otherwise do nothing;
    }