Знаете ли вы что...

Re: Знаете ли вы что...

Сообщение DbIMok 20 апр 2010, 00:12

Синтаксис:
Используется csharp
public class GUILayoutEntry
{
  // Fields
  protected static int indent;
  internal static Rect kDummyRect = new Rect(0f, 0f, 1f, 1f);
  private GUIStyle m_Style;
  public float maxHeight;
  public float maxWidth;
  public float minHeight;
  public float minWidth;
  public Rect rect;
  public int stretchHeight;
  public int stretchWidth;

  // Methods
  static GUILayoutEntry()
  {
    kDummyRect = kDummyRect;
    indent = 0;
  }

  public GUILayoutEntry(float _minWidth, float _maxWidth, float _minHeight, float _maxHeight, GUIStyle _style)
  {
    this.rect = new Rect(0f, 0f, 0f, 0f);
    this.rect = this.rect;
    this.m_Style = GUIStyle.none;
    this.minWidth = _minWidth;
    this.maxWidth = _maxWidth;
    this.minHeight = _minHeight;
    this.maxHeight = _maxHeight;
    if (_style == null)
    {
      _style = GUIStyle.none;
    }
    this.style = _style;
  }

  public GUILayoutEntry(float _minWidth, float _maxWidth, float _minHeight, float _maxHeight, GUIStyle _style, GUILayoutOption[] options)
  {
    this.rect = new Rect(0f, 0f, 0f, 0f);
    this.rect = this.rect;
    this.m_Style = GUIStyle.none;
    this.minWidth = _minWidth;
    this.maxWidth = _maxWidth;
    this.minHeight = _minHeight;
    this.maxHeight = _maxHeight;
    this.style = _style;
    this.ApplyOptions(options);
  }

  public virtual void ApplyOptions(GUILayoutOption[] options)
  {
    if (options != null)
    {
      GUILayoutOption[] optionArray = options;
      int length = optionArray.Length;
      for (int i = 0; i < length; i++)
      {
        float num3;
        GUILayoutOption option = optionArray[i];
        switch (option.type)
        {
          case GUILayoutOption.Type.fixedWidth:
            num3 = (float) option.value;
            this.maxWidth = num3;
            this.minWidth = num3;
            this.stretchWidth = 0;
            break;

          case GUILayoutOption.Type.fixedHeight:
            num3 = (float) option.value;
            this.maxHeight = num3;
            this.minHeight = num3;
            this.stretchHeight = 0;
            break;

          case GUILayoutOption.Type.minWidth:
            this.minWidth = (float) option.value;
            if (this.maxWidth < this.minWidth)
            {
              this.maxWidth = this.minWidth;
            }
            break;

          case GUILayoutOption.Type.maxWidth:
            this.maxWidth = (float) option.value;
            if (this.minWidth > this.maxWidth)
            {
              this.minWidth = this.maxWidth;
            }
            this.stretchWidth = 0;
            break;

          case GUILayoutOption.Type.minHeight:
            this.minHeight = (float) option.value;
            if (this.maxHeight < this.minHeight)
            {
              this.maxHeight = this.minHeight;
            }
            break;

          case GUILayoutOption.Type.maxHeight:
            this.maxHeight = (float) option.value;
            if (this.minHeight > this.maxHeight)
            {
              this.minHeight = this.maxHeight;
            }
            this.stretchHeight = 0;
            break;

          case GUILayoutOption.Type.stretchWidth:
            this.stretchWidth = (int) option.value;
            break;

          case GUILayoutOption.Type.stretchHeight:
            this.stretchHeight = (int) option.value;
            break;
        }
      }
      if ((this.maxWidth != 0f) && (this.maxWidth < this.minWidth))
      {
        this.maxWidth = this.minWidth;
      }
      if ((this.maxHeight != 0f) && (this.maxHeight < this.minHeight))
      {
        this.maxHeight = this.minHeight;
      }
    }
  }

  protected virtual void ApplyStyleSettings(GUIStyle style)
  {
    this.stretchWidth = ((style.fixedWidth != 0f) || !style.stretchWidth) ? 0 : 1;
    this.stretchHeight = ((style.fixedHeight != 0f) || !style.stretchHeight) ? 0 : 1;
    this.m_Style = style;
  }

  public virtual void CalcHeight()
  {
  }

  public virtual void CalcWidth()
  {
  }

  public virtual void SetHorizontal(float x, float width)
  {
    this.rect.x = x;
    this.rect.width = width;
  }

  public virtual void SetVertical(float y, float height)
  {
    this.rect.y = y;
    this.rect.height = height;
  }

  public override <span class="posthilit">string</span> ToString()
  {
    <span class="posthilit">string</span> str = "";
    for (int i = 0; i < indent; i++)
    {
      str = str + " ";
    }
    object[] objArray1 = new object[12];
    objArray1[0] = str;
    object[] args = new object[] { (this.style == null) ? "NULL" : this.style.name, base.GetType(), this.rect.x, this.rect.xMax, this.rect.y, this.rect.yMax };
    objArray1[1] = <span class="posthilit">string</span>.Format("{1}-{0} (x:{2}-{3}, y:{4}-{5})", args);
    objArray1[2] = "   -   W: ";
    objArray1[3] = this.minWidth;
    objArray1[4] = "-";
    objArray1[5] = this.maxWidth;
    objArray1[6] = (this.stretchWidth == 0) ? "" : "+";
    objArray1[7] = ", H: ";
    objArray1[8] = this.minHeight;
    objArray1[9] = "-";
    objArray1[10] = this.maxHeight;
    objArray1[11] = (this.stretchHeight == 0) ? "" : "+";
    return <span class="posthilit">string</span>.Concat(objArray1);
  }

  // Properties
  public virtual RectOffset margin
  {
    get
    {
      return this.style.margin;
    }
  }

  public GUIStyle style
  {
    get
    {
      return this.m_Style;
    }
    set
    {
      this.m_Style = value;
      this.ApplyStyleSettings(value);
    }
  }
}
 
правильный вопрос - половина ответа. учитесь формулировать вопросы понятно.
Новости > _Telegram чат @unity3d_ru (11.6k/4.8k online) > _Telegram канал @unity_news (4.6k подписчиков) > Телеграм тема > "Спасибо"
Аватара пользователя
DbIMok
Адепт
 
Сообщения: 6372
Зарегистрирован: 31 июл 2009, 14:05

Re: Знаете ли вы что...

Сообщение DbIMok 20 апр 2010, 00:13

Синтаксис:
Используется csharp
public class GUILayoutGroup : GUILayoutEntry
{
  // Fields
  protected float childMaxHeight;
  protected float childMaxWidth;
  protected float childMinHeight;
  protected float childMinWidth;
  private int cursor;
  public ArrayList entries;
  public bool isVertical;
  public bool isWindow;
  private RectOffset m_Margin;
  public bool resetCoords;
  public bool sameSize;
  public float spacing;
  protected int stretchableCountX;
  protected int stretchableCountY;
  private bool userSpecifiedHeight;
  private bool userSpecifiedWidth;
  public int windowID;

  // Methods
  public GUILayoutGroup() : base(0f, 0f, 0f, 0f, GUIStyle.none)
  {
    this.entries = new ArrayList();
    this.isVertical = true;
    this.sameSize = true;
    this.windowID = -1;
    this.stretchableCountX = 100;
    this.stretchableCountY = 100;
    this.childMinWidth = 100f;
    this.childMaxWidth = 100f;
    this.childMinHeight = 100f;
    this.childMaxHeight = 100f;
    this.m_Margin = new RectOffset();
  }

  public GUILayoutGroup(GUIStyle _style, GUILayoutOption[] options) : base(0f, 0f, 0f, 0f, _style)
  {
    this.entries = new ArrayList();
    this.isVertical = true;
    this.sameSize = true;
    this.windowID = -1;
    this.stretchableCountX = 100;
    this.stretchableCountY = 100;
    this.childMinWidth = 100f;
    this.childMaxWidth = 100f;
    this.childMinHeight = 100f;
    this.childMaxHeight = 100f;
    this.m_Margin = new RectOffset();
    if (options != null)
    {
      this.ApplyOptions(options);
    }
    this.m_Margin.left = _style.margin.left;
    this.m_Margin.right = _style.margin.right;
    this.m_Margin.top = _style.margin.top;
    this.m_Margin.bottom = _style.margin.bottom;
  }

  public void Add(GUILayoutEntry e)
  {
    this.entries.Add(e);
  }

  public override void ApplyOptions(GUILayoutOption[] options)
  {
    base.ApplyOptions(options);
    GUILayoutOption[] optionArray = options;
    int length = optionArray.Length;
    for (int i = 0; i < length; i++)
    {
      GUILayoutOption option = optionArray[i];
      switch (option.type)
      {
        case GUILayoutOption.Type.fixedWidth:
        case GUILayoutOption.Type.minWidth:
        case GUILayoutOption.Type.maxWidth:
          this.userSpecifiedHeight = true;
          break;

        case GUILayoutOption.Type.fixedHeight:
        case GUILayoutOption.Type.minHeight:
        case GUILayoutOption.Type.maxHeight:
          this.userSpecifiedWidth = true;
          break;

        case GUILayoutOption.Type.spacing:
          this.spacing = (int) option.value;
          break;
      }
    }
  }

  protected override void ApplyStyleSettings(GUIStyle style)
  {
    base.ApplyStyleSettings(style);
    RectOffset margin = style.margin;
    this.m_Margin.left = margin.left;
    this.m_Margin.right = margin.right;
    this.m_Margin.top = margin.top;
    this.m_Margin.bottom = margin.bottom;
  }

  public override void CalcHeight()
  {
    float vertical;
    if (this.entries.Count == 0)
    {
      vertical = base.style.padding.vertical;
      base.minHeight = vertical;
      base.maxHeight = vertical;
    }
    else
    {
      vertical = 0f;
      this.childMaxHeight = vertical;
      this.childMinHeight = vertical;
      int b = 0;
      int num2 = 0;
      this.stretchableCountY = 0;
      if (this.isVertical)
      {
        int bottom = 0;
        bool flag = true;
      Label_0171:
        foreach (GUILayoutEntry entry in this.entries)
        {
          entry.CalcHeight();
          RectOffset margin = entry.margin;
          if (entry.style != GUILayoutUtility.spaceStyle)
          {
            int num4;
            if (!flag)
            {
              num4 = (bottom <= margin.top) ? margin.top : bottom;
            }
            else
            {
              num4 = 0;
              flag = false;
            }
            this.childMinHeight += (entry.minHeight + this.spacing) + num4;
            this.childMaxHeight += (entry.maxHeight + this.spacing) + num4;
            bottom = margin.bottom;
            this.stretchableCountY += entry.stretchHeight;
            goto Label_0171;
          }
          this.childMinHeight += entry.minHeight;
          this.childMaxHeight += entry.maxHeight;
          this.stretchableCountY += entry.stretchHeight;
        }
        this.childMinHeight -= this.spacing;
        this.childMaxHeight -= this.spacing;
        if (this.entries.Count != 0)
        {
          b = ((GUILayoutEntry) this.entries[0]).margin.top;
          num2 = bottom;
        }
        else
        {
          b = 0;
          num2 = 0;
        }
      }
      else
      {
        bool flag2 = true;
        foreach (GUILayoutEntry entry2 in this.entries)
        {
          entry2.CalcHeight();
          RectOffset offset2 = entry2.margin;
          if (entry2.style != GUILayoutUtility.spaceStyle)
          {
            if (!flag2)
            {
              b = Mathf.Min(offset2.top, b);
              num2 = Mathf.Min(offset2.bottom, num2);
            }
            else
            {
              b = offset2.top;
              num2 = offset2.bottom;
            }
            this.childMinHeight = Mathf.Max(entry2.minHeight, this.childMinHeight);
            this.childMaxHeight = Mathf.Max(entry2.maxHeight, this.childMaxHeight);
          }
          this.stretchableCountY += entry2.stretchHeight;
        }
      }
      float num5 = 0f;
      float num6 = 0f;
      if ((base.style != GUIStyle.none) || this.userSpecifiedHeight)
      {
        num5 = Mathf.Max(base.style.padding.top, b);
        num6 = Mathf.Max(base.style.padding.bottom, num2);
      }
      else
      {
        this.m_Margin.top = b;
        this.m_Margin.bottom = num2;
        vertical = 0f;
        num6 = vertical;
        num5 = vertical;
      }
      base.minHeight = Mathf.Max(base.minHeight, (this.childMinHeight + num5) + num6);
      if (base.maxHeight == 0f)
      {
        base.stretchHeight += this.stretchableCountY + (!base.style.stretchHeight ? 0 : 1);
        base.maxHeight = (this.childMaxHeight + num5) + num6;
      }
      else
      {
        base.stretchHeight = 0;
      }
      base.maxHeight = Mathf.Max(base.maxHeight, base.minHeight);
      if (base.style.fixedHeight != 0f)
      {
        vertical = base.style.fixedHeight;
        base.minHeight = vertical;
        base.maxHeight = vertical;
        base.stretchHeight = 0;
      }
    }
  }

  public override void CalcWidth()
  {
    float horizontal;
    if (this.entries.Count == 0)
    {
      horizontal = base.style.padding.horizontal;
      base.minWidth = horizontal;
      base.maxWidth = horizontal;
    }
    else
    {
      this.childMinWidth = 0f;
      this.childMaxWidth = 0f;
      int b = 0;
      int right = 0;
      this.stretchableCountX = 0;
      bool flag = true;
      if (this.isVertical)
      {
        foreach (GUILayoutEntry entry in this.entries)
        {
          entry.CalcWidth();
          RectOffset margin = entry.margin;
          if (entry.style != GUILayoutUtility.spaceStyle)
          {
            if (!flag)
            {
              b = Mathf.Min(margin.left, b);
              right = Mathf.Min(margin.right, right);
            }
            else
            {
              b = margin.left;
              right = margin.right;
              flag = false;
            }
            this.childMinWidth = Mathf.Max(entry.minWidth + margin.horizontal, this.childMinWidth);
            this.childMaxWidth = Mathf.Max(entry.maxWidth + margin.horizontal, this.childMaxWidth);
          }
          this.stretchableCountX += entry.stretchWidth;
        }
        this.childMinWidth -= b + right;
        this.childMaxWidth -= b + right;
      }
      else
      {
        int num3 = 0;
        foreach (GUILayoutEntry entry2 in this.entries)
        {
          entry2.CalcWidth();
          RectOffset offset2 = entry2.margin;
          if (entry2.style != GUILayoutUtility.spaceStyle)
          {
            int num4;
            if (!flag)
            {
              num4 = (num3 <= offset2.left) ? offset2.left : num3;
            }
            else
            {
              num4 = 0;
              flag = false;
            }
            this.childMinWidth += (entry2.minWidth + this.spacing) + num4;
            this.childMaxWidth += (entry2.maxWidth + this.spacing) + num4;
            num3 = offset2.right;
            this.stretchableCountX += entry2.stretchWidth;
            continue;
          }
          this.childMinWidth += entry2.minWidth;
          this.childMaxWidth += entry2.maxWidth;
          this.stretchableCountX += entry2.stretchWidth;
        }
        this.childMinWidth -= this.spacing;
        this.childMaxWidth -= this.spacing;
        if (this.entries.Count != 0)
        {
          b = ((GUILayoutEntry) this.entries[0]).margin.left;
          right = num3;
        }
        else
        {
          right = 0;
          b = 0;
        }
      }
      float num5 = 0f;
      float num6 = 0f;
      if ((base.style != GUIStyle.none) || this.userSpecifiedWidth)
      {
        num5 = Mathf.Max(base.style.padding.left, b);
        num6 = Mathf.Max(base.style.padding.right, right);
      }
      else
      {
        this.m_Margin.left = b;
        this.m_Margin.right = right;
        horizontal = 0f;
        num6 = horizontal;
        num5 = horizontal;
      }
      base.minWidth = Mathf.Max(base.minWidth, (this.childMinWidth + num5) + num6);
      if (base.maxWidth == 0f)
      {
        base.stretchWidth += this.stretchableCountX + (!base.style.stretchWidth ? 0 : 1);
        base.maxWidth = (this.childMaxWidth + num5) + num6;
      }
      else
      {
        base.stretchWidth = 0;
      }
      base.maxWidth = Mathf.Max(base.maxWidth, base.minWidth);
      if (base.style.fixedWidth != 0f)
      {
        horizontal = base.style.fixedWidth;
        base.minWidth = horizontal;
        base.maxWidth = horizontal;
        base.stretchWidth = 0;
      }
    }
  }

  public Rect GetLast()
  {
    if (this.cursor == 0)
    {
      Debug.LogError("You cannot call GetLast immediately after beginning a group.");
      return GUILayoutEntry.kDummyRect;
    }
    if (this.cursor <= this.entries.Count)
    {
      GUILayoutEntry entry = (GUILayoutEntry) this.entries[this.cursor - 1];
      return entry.rect;
    }
    Debug.LogError(<span class="posthilit">string</span>.Concat(new object[] { "Getting control ", this.cursor, "'s position in a group with only ", this.entries.Count, " controls when doing ", Event.current.type }));
    return GUILayoutEntry.kDummyRect;
  }

  public GUILayoutEntry GetNext()
  {
    if (this.cursor < this.entries.Count)
    {
      GUILayoutEntry entry = (GUILayoutEntry) this.entries[this.cursor];
      this.cursor++;
      return entry;
    }
    object[] objArray1 = new object[] { "Getting control ", this.cursor, "'s position in a group with only ", this.entries.Count, " controls when doing ", Event.current.type, "\nAborting" };
    throw new ArgumentException(<span class="posthilit">string</span>.Concat(objArray1));
  }

  public void ResetCursor()
  {
    this.cursor = 0;
  }

  public override void SetHorizontal(float x, float width)
  {
    base.SetHorizontal(x, width);
    if (this.resetCoords)
    {
      x = 0f;
    }
    RectOffset padding = base.style.padding;
    if (this.isVertical)
    {
      if (base.style != GUIStyle.none)
      {
        foreach (GUILayoutEntry entry in this.entries)
        {
          float num = Mathf.Max(entry.margin.left, padding.left);
          float num2 = x + num;
          float num3 = (width - Mathf.Max(entry.margin.right, padding.right)) - num;
          if (entry.stretchWidth != 0)
          {
            entry.SetHorizontal(num2, num3);
          }
          else
          {
            entry.SetHorizontal(num2, Mathf.Clamp(num3, entry.minWidth, entry.maxWidth));
          }
        }
      }
      else
      {
        float num4 = x - this.margin.left;
        float num5 = width + this.margin.horizontal;
        foreach (GUILayoutEntry entry2 in this.entries)
        {
          if (entry2.stretchWidth != 0)
          {
            entry2.SetHorizontal(num4 + entry2.margin.left, num5 - entry2.margin.horizontal);
          }
          else
          {
            entry2.SetHorizontal(num4 + entry2.margin.left, Mathf.Clamp(num5 - entry2.margin.horizontal, entry2.minWidth, entry2.maxWidth));
          }
        }
      }
    }
    else
    {
      if (base.style != GUIStyle.none)
      {
        float left = padding.left;
        float right = padding.right;
        if (this.entries.Count != 0)
        {
          left = Mathf.Max(left, (float) ((GUILayoutEntry) this.entries[0]).margin.left);
          right = Mathf.Max(right, (float) ((GUILayoutEntry) this.entries[this.entries.Count - 1]).margin.right);
        }
        x += left;
        width -= right + left;
      }
      float num8 = width - (this.spacing * (this.entries.Count - 1));
      float t = 0f;
      if (this.childMinWidth != this.childMaxWidth)
      {
        t = Mathf.Clamp((float) ((num8 - this.childMinWidth) / (this.childMaxWidth - this.childMinWidth)), (float) 0f, (float) 1f);
      }
      float num10 = 0f;
      if ((num8 > this.childMaxWidth) && (this.stretchableCountX > 0))
      {
        num10 = (num8 - this.childMaxWidth) / ((float) this.stretchableCountX);
      }
      int num11 = 0;
      bool flag = true;
      foreach (GUILayoutEntry entry3 in this.entries)
      {
        float f = Mathf.Lerp(entry3.minWidth, entry3.maxWidth, t) + (num10 * entry3.stretchWidth);
        if (entry3.style != GUILayoutUtility.spaceStyle)
        {
          int num13 = entry3.margin.left;
          if (flag)
          {
            num13 = 0;
            flag = false;
          }
          int num14 = (num11 <= num13) ? num13 : num11;
          x += num14;
          num11 = entry3.margin.right;
        }
        entry3.SetHorizontal(Mathf.Round(x), Mathf.Round(f));
        x += f + this.spacing;
      }
    }
  }

  public override void SetVertical(float y, float height)
  {
    base.SetVertical(y, height);
    if (this.entries.Count != 0)
    {
      RectOffset padding = base.style.padding;
      if (this.resetCoords)
      {
        y = 0f;
      }
      if (this.isVertical)
      {
        if (base.style != GUIStyle.none)
        {
          float top = padding.top;
          float bottom = padding.bottom;
          if (this.entries.Count != 0)
          {
            top = Mathf.Max(top, (float) ((GUILayoutEntry) this.entries[0]).margin.top);
            bottom = Mathf.Max(bottom, (float) ((GUILayoutEntry) this.entries[this.entries.Count - 1]).margin.bottom);
          }
          y += top;
          height -= bottom + top;
        }
        float num3 = height - (this.spacing * (this.entries.Count - 1));
        float t = 0f;
        if (this.childMinHeight != this.childMaxHeight)
        {
          t = Mathf.Clamp((float) ((num3 - this.childMinHeight) / (this.childMaxHeight - this.childMinHeight)), (float) 0f, (float) 1f);
        }
        float num5 = 0f;
        if ((num3 > this.childMaxHeight) && (this.stretchableCountY > 0))
        {
          num5 = (num3 - this.childMaxHeight) / ((float) this.stretchableCountY);
        }
        int num6 = 0;
        bool flag = true;
        foreach (GUILayoutEntry entry in this.entries)
        {
          float f = Mathf.Lerp(entry.minHeight, entry.maxHeight, t) + (num5 * entry.stretchHeight);
          if (entry.style != GUILayoutUtility.spaceStyle)
          {
            int num8 = entry.margin.top;
            if (flag)
            {
              num8 = 0;
              flag = false;
            }
            int num9 = (num6 <= num8) ? num8 : num6;
            y += num9;
            num6 = entry.margin.bottom;
          }
          entry.SetVertical(Mathf.Round(y), Mathf.Round(f));
          y += f + this.spacing;
        }
      }
      else if (base.style != GUIStyle.none)
      {
        foreach (GUILayoutEntry entry2 in this.entries)
        {
          float num10 = Mathf.Max(entry2.margin.top, padding.top);
          float num11 = y + num10;
          float num12 = (height - Mathf.Max(entry2.margin.bottom, padding.bottom)) - num10;
          if (entry2.stretchHeight != 0)
          {
            entry2.SetVertical(num11, num12);
          }
          else
          {
            entry2.SetVertical(num11, Mathf.Clamp(num12, entry2.minHeight, entry2.maxHeight));
          }
        }
      }
      else
      {
        float num13 = y - this.margin.top;
        float num14 = height + this.margin.vertical;
        foreach (GUILayoutEntry entry3 in this.entries)
        {
          if (entry3.stretchHeight != 0)
          {
            entry3.SetVertical(num13 + entry3.margin.top, num14 - entry3.margin.vertical);
          }
          else
          {
            entry3.SetVertical(num13 + entry3.margin.top, Mathf.Clamp(num14 - entry3.margin.vertical, entry3.minHeight, entry3.maxHeight));
          }
        }
      }
    }
  }

  public override <span class="posthilit">string</span> ToString()
  {
    <span class="posthilit">string</span> str = "";
    <span class="posthilit">string</span> str2 = "";
    for (int i = 0; i < GUILayoutEntry.indent; i++)
    {
      str2 = str2 + " ";
    }
    str = str + <span class="posthilit">string</span>.Concat(new object[] { base.ToString(), " Margins: ", this.childMinHeight, " {\n" });
    GUILayoutEntry.indent += 4;
    foreach (GUILayoutEntry entry in this.entries)
    {
      str = str + (entry.ToString() + "\n");
    }
    str = str + (str2 + "}");
    GUILayoutEntry.indent -= 4;
    return str;
  }

  // Properties
  public override RectOffset margin
  {
    get
    {
      return this.m_Margin;
    }
  }
}
 
правильный вопрос - половина ответа. учитесь формулировать вопросы понятно.
Новости > _Telegram чат @unity3d_ru (11.6k/4.8k online) > _Telegram канал @unity_news (4.6k подписчиков) > Телеграм тема > "Спасибо"
Аватара пользователя
DbIMok
Адепт
 
Сообщения: 6372
Зарегистрирован: 31 июл 2009, 14:05

Re: Знаете ли вы что...

Сообщение DbIMok 20 апр 2010, 00:14

Синтаксис:
Используется csharp
public class GUIScrollGroup : GUILayoutGroup
{
  // Fields
  public bool allowHorizontalScroll = true;
  public float calcMaxHeight;
  public float calcMaxWidth;
  public float calcMinHeight;
  public float calcMinWidth;
  public float clientHeight;
  public float clientWidth;
  public float hmm;
  public GUIStyle horizontalScrollbar;
  public bool needsHorizontalScrollbar;
  public bool needsVerticalScrollbar;
  public GUIStyle verticalScrollbar;

  // Methods
  public override void CalcHeight()
  {
    float minHeight = base.minHeight;
    float maxHeight = base.maxHeight;
    base.minHeight = 0f;
    base.maxHeight = 0f;
    base.CalcHeight();
    this.calcMinHeight = base.minHeight;
    this.calcMaxHeight = base.maxHeight;
    if (this.needsHorizontalScrollbar)
    {
      float num3 = this.horizontalScrollbar.fixedHeight + this.horizontalScrollbar.margin.top;
      base.minHeight += num3;
      base.maxHeight += num3;
    }
    if (base.minHeight > 32f)
    {
      base.minHeight = 32f;
    }
    if (minHeight != 0f)
    {
      base.minHeight = minHeight;
    }
    if (maxHeight != 0f)
    {
      base.maxHeight = maxHeight;
      base.stretchHeight = 0;
    }
  }

  public override void CalcWidth()
  {
    float minWidth = base.minWidth;
    float maxWidth = base.maxWidth;
    if (this.allowHorizontalScroll)
    {
      base.minWidth = 0f;
      base.maxWidth = 0f;
    }
    base.CalcWidth();
    this.calcMinWidth = base.minWidth;
    this.calcMaxWidth = base.maxWidth;
    if (base.minWidth > 32f)
    {
      base.minWidth = 32f;
    }
    if (this.allowHorizontalScroll)
    {
      if (minWidth != 0f)
      {
        base.minWidth = minWidth;
      }
      if (maxWidth != 0f)
      {
        base.maxWidth = maxWidth;
        base.stretchWidth = 0;
      }
    }
  }

  public override void SetHorizontal(float x, float width)
  {
    float num = !this.needsVerticalScrollbar ? width : ((width - this.verticalScrollbar.fixedWidth) - this.verticalScrollbar.margin.left);
    if (this.allowHorizontalScroll && (num < this.calcMinWidth))
    {
      this.needsHorizontalScrollbar = true;
      base.minWidth = this.calcMinWidth;
      base.maxWidth = this.calcMaxWidth;
      base.SetHorizontal(x, this.calcMinWidth);
      this.rect.width = width;
      this.clientWidth = this.calcMinWidth;
    }
    else
    {
      this.needsHorizontalScrollbar = false;
      if (this.allowHorizontalScroll)
      {
        base.minWidth = this.calcMinWidth;
        base.maxWidth = this.calcMaxWidth;
      }
      base.SetHorizontal(x, num);
      this.rect.width = width;
      this.clientWidth = num;
    }
  }

  public override void SetVertical(float y, float height)
  {
    float num = height;
    if (this.needsHorizontalScrollbar)
    {
      num -= this.horizontalScrollbar.fixedHeight + this.horizontalScrollbar.margin.top;
    }
    if (num < this.calcMinHeight)
    {
      if (!this.needsHorizontalScrollbar && !this.needsVerticalScrollbar)
      {
        this.clientWidth = (this.rect.width - this.verticalScrollbar.fixedWidth) - this.verticalScrollbar.margin.left;
        if (this.clientWidth < this.calcMinWidth)
        {
          this.clientWidth = this.calcMinWidth;
        }
        float width = this.rect.width;
        this.SetHorizontal(this.rect.x, this.clientWidth);
        this.CalcHeight();
        this.rect.width = width;
      }
      float minHeight = base.minHeight;
      float maxHeight = base.maxHeight;
      base.minHeight = this.calcMinHeight;
      base.maxHeight = this.calcMaxHeight;
      base.SetVertical(y, this.calcMinHeight);
      base.minHeight = minHeight;
      base.maxHeight = maxHeight;
      this.rect.height = height;
      this.clientHeight = this.calcMinHeight;
    }
    else
    {
      base.minHeight = this.calcMinHeight;
      base.maxHeight = this.calcMaxHeight;
      base.SetVertical(y, num);
      this.rect.height = height;
      this.clientHeight = num;
    }
  }
}
 
правильный вопрос - половина ответа. учитесь формулировать вопросы понятно.
Новости > _Telegram чат @unity3d_ru (11.6k/4.8k online) > _Telegram канал @unity_news (4.6k подписчиков) > Телеграм тема > "Спасибо"
Аватара пользователя
DbIMok
Адепт
 
Сообщения: 6372
Зарегистрирован: 31 июл 2009, 14:05

Re: Знаете ли вы что...

Сообщение DbIMok 20 апр 2010, 00:25

Синтаксис:
Используется csharp
public class SendMouseEvents
{
  // Fields
  private static MouseOverPair[] m_OldMouseDrag = new MouseOverPair[] { new MouseOverPair(), new MouseOverPair() };
  private static MouseOverPair[] m_OldMouseOver = new MouseOverPair[] { new MouseOverPair(), new MouseOverPair() };

  // Methods
  private static void DoSendMouseEvents()
  {
    MouseOverPair[] pairArray = new MouseOverPair[] { new MouseOverPair(), new MouseOverPair() };
    Vector3 mousePosition = Input.mousePosition;
    Camera[] allCameras = Camera.allCameras;
    if (!GUIUtility.mouseUsed)
    {
      Camera[] cameraArray2 = allCameras;
      int length = cameraArray2.Length;
      for (int j = 0; j < length; j++)
      {
        Camera camera = cameraArray2[j];
        if (camera.pixelRect.Contains(mousePosition))
        {
          RaycastHit hit;
          GUILayer component = (GUILayer) camera.GetComponent(typeof(GUILayer));
          if (component != null)
          {
            GUIElement element = component.HitTest(mousePosition);
            if (element != null)
            {
              pairArray[0].target = element.gameObject;
              pairArray[0].camera = camera;
            }
          }
          if ((camera.farClipPlane > 0f) && Physics.Raycast(camera.ScreenPointToRay(mousePosition), out hit, camera.farClipPlane, camera.cullingMask & -5))
          {
            if (hit.rigidbody != null)
            {
              pairArray[1].target = hit.rigidbody.gameObject;
              pairArray[1].camera = camera;
            }
            else
            {
              pairArray[1].target = hit.collider.gameObject;
              pairArray[1].camera = camera;
            }
          }
          else if ((camera.clearFlags == CameraClearFlags.Skybox) || (camera.clearFlags == CameraClearFlags.Color))
          {
            pairArray[1].target = null;
            pairArray[1].camera = null;
          }
        }
      }
    }
    for (int i = 0; i < 2; i++)
    {
      MouseOverPair pair2;
      bool mouseButtonDown = Input.GetMouseButtonDown(0);
      bool mouseButton = Input.GetMouseButton(0);
      if (mouseButtonDown)
      {
        pair2 = pairArray[i];
      }
      else if (!mouseButton)
      {
        pair2 = new MouseOverPair();
      }
      else
      {
        pair2 = m_OldMouseDrag[i];
      }
      if (MouseOverPair.ComparePair(pair2, m_OldMouseDrag[i]))
      {
        if (pair2 != 0)
        {
          pair2.SendMessage("OnMouseDrag");
        }
      }
      else
      {
        if (m_OldMouseDrag[i] != 0)
        {
          m_OldMouseDrag[i].SendMessage("OnMouseUp");
        }
        if (pair2 != 0)
        {
          pair2.SendMessage("OnMouseDown");
          pair2.SendMessage("OnMouseDrag");
        }
      }
      m_OldMouseDrag[i] = pair2;
      MouseOverPair lhs = pairArray[i];
      if (MouseOverPair.ComparePair(lhs, m_OldMouseOver[i]))
      {
        if (lhs != 0)
        {
          lhs.SendMessage("OnMouseOver");
        }
      }
      else
      {
        if (m_OldMouseOver[i] != 0)
        {
          m_OldMouseOver[i].SendMessage("OnMouseExit");
        }
        if (lhs != 0)
        {
          lhs.SendMessage("OnMouseEnter");
          lhs.SendMessage("OnMouseOver");
        }
      }
      m_OldMouseOver[i] = lhs;
    }
  }

  // Nested Types
  [StructLayout(LayoutKind.Sequential)]
  private struct MouseOverPair
  {
    public GameObject target;
    public Camera camera;
    public void SendMessage(<span class="posthilit">string</span> name)
    {
      this.target.SendMessage(name, null, SendMessageOptions.DontRequireReceiver);
    }

    public static bool ComparePair(SendMouseEvents.MouseOverPair lhs, SendMouseEvents.MouseOverPair rhs)
    {
      return ((lhs.target == rhs.target) && (lhs.camera == rhs.camera));
    }

    public static implicit operator bool(SendMouseEvents.MouseOverPair exists)
    {
      return ((exists.target != null) && (exists.camera != null));
    }
  }
}
 
правильный вопрос - половина ответа. учитесь формулировать вопросы понятно.
Новости > _Telegram чат @unity3d_ru (11.6k/4.8k online) > _Telegram канал @unity_news (4.6k подписчиков) > Телеграм тема > "Спасибо"
Аватара пользователя
DbIMok
Адепт
 
Сообщения: 6372
Зарегистрирован: 31 июл 2009, 14:05

Re: Знаете ли вы что...

Сообщение DbIMok 20 апр 2010, 00:26

Синтаксис:
Используется csharp
public class SetupCoroutine
{
  // Methods
  public SetupCoroutine();
  public static object InvokeMember(object behaviour, <span class="posthilit">string</span> name, object variable);
  public static object InvokeStatic(Type klass, <span class="posthilit">string</span> name, object variable);
}
 
правильный вопрос - половина ответа. учитесь формулировать вопросы понятно.
Новости > _Telegram чат @unity3d_ru (11.6k/4.8k online) > _Telegram канал @unity_news (4.6k подписчиков) > Телеграм тема > "Спасибо"
Аватара пользователя
DbIMok
Адепт
 
Сообщения: 6372
Зарегистрирован: 31 июл 2009, 14:05

Re: Знаете ли вы что...

Сообщение DbIMok 20 апр 2010, 00:28

Синтаксис:
Используется csharp
public class StackTraceUtility
{
  // Fields
  private static <span class="posthilit">string</span> projectFolder = "";

  // Methods
  public static StringBuilder ExtractFormattedStackTrace(StackTrace stackTrace)
  {
    StringBuilder builder = new StringBuilder(0xff);
    ArrayList cleanedUpsplit = new ArrayList();
    for (int i = 0; i < stackTrace.FrameCount; i++)
    {
      builder.Remove(0, builder.Length);
      StackFrame frame = stackTrace.GetFrame(i);
      MethodBase method = frame.GetMethod();
      if (method != null)
      {
        Type declaringType = method.DeclaringType;
        if (declaringType != null)
        {
          <span class="posthilit">string</span> str = declaringType.Namespace;
          if ((str != null) && (str.Length != 0))
          {
            builder.Append(str);
            builder.Append(".");
          }
          builder.Append(declaringType.Name);
          builder.Append(":");
          builder.Append(method.Name);
          builder.Append("(");
          int index = 0;
          ParameterInfo[] parameters = method.GetParameters();
          bool flag = true;
          while (index < parameters.Length)
          {
            if (!flag)
            {
              builder.Append(", ");
            }
            else
            {
              flag = false;
            }
            builder.Append(parameters[index].ParameterType.Name);
            index++;
          }
          builder.Append(")");
          <span class="posthilit">string</span> fileName = frame.GetFileName();
          if (fileName != null)
          {
            builder.Append(" (at ");
            if (fileName.StartsWith(projectFolder))
            {
              fileName = fileName.Substring(projectFolder.Length, fileName.Length - projectFolder.Length);
            }
            builder.Append(fileName);
            builder.Append(":");
            builder.Append(frame.GetFileLineNumber().ToString());
            builder.Append(")");
          }
          cleanedUpsplit.Add(builder.ToString());
        }
      }
    }
    return ProcessSplitCleanup(cleanedUpsplit);
  }

  public static <span class="posthilit">string</span> ExtractStackTrace()
  {
    StackTrace stackTrace = new StackTrace(1, true);
    return ExtractFormattedStackTrace(stackTrace).ToString();
  }

  public static <span class="posthilit">string</span> ExtractStringFromException(Exception exception)
  {
    <span class="posthilit">string</span> message = "";
    <span class="posthilit">string</span> stackTrace = "";
    ExtractStringFromExceptionInternal(exception, out message, out stackTrace);
    return (message + "\n" + stackTrace);
  }

  internal static void ExtractStringFromExceptionInternal(Exception exception, out <span class="posthilit">string</span> message, out <span class="posthilit">string</span> stackTrace)
  {
    Exception innerException = exception;
    if (exception.InnerException != null)
    {
      exception = exception.InnerException;
    }
    message = exception.GetType().Name;
    if (exception.Message.Trim().Length != 0)
    {
      message = message + ": ";
      message = message + exception.Message;
    }
    StringBuilder builder = new StringBuilder(exception.StackTrace.Length * 2);
    if (exception.Message.IndexOf('\n') != -1)
    {
      builder.Append("\n");
    }
    <span class="posthilit">string</span> oldString = "";
    while (innerException != null)
    {
      if (oldString.Length == 0)
      {
        oldString = innerException.StackTrace;
      }
      else
      {
        oldString = oldString + innerException.StackTrace;
      }
      innerException = innerException.InnerException;
    }
    builder.Append(NicifyStacktrace(oldString));
    StackTrace trace = new StackTrace(1, true);
    StringBuilder builder2 = ExtractFormattedStackTrace(trace);
    builder.Append(builder2);
    stackTrace = builder.ToString();
  }

  private static bool IsSystemStacktraceType(object name)
  {
    <span class="posthilit">string</span> str = (<span class="posthilit">string</span>) name;
    return ((((str.StartsWith("UnityEditor.") || str.StartsWith("UnityEngine.")) || (str.StartsWith("System.") || str.StartsWith("UnityScript.Lang."))) || str.StartsWith("Boo.Lang.")) || str.StartsWith("UnityEngine.SetupCoroutine"));
  }

  public static StringBuilder NicifyStacktrace(<span class="posthilit">string</span> oldString)
  {
    char[] separator = new char[] { '\n' };
    <span class="posthilit">string</span>[] strArray = oldString.Split(separator);
    ArrayList cleanedUpsplit = new ArrayList();
    StringBuilder builder = new StringBuilder(oldString.Length);
    <span class="posthilit">string</span>[] strArray2 = strArray;
    int length = strArray2.Length;
    for (int i = 0; i < length; i++)
    {
      <span class="posthilit">string</span> str = strArray2[i];
      builder.Remove(0, builder.Length);
      if ((str.Length != 0) && (str[0] != '\n'))
      {
        <span class="posthilit">string</span> str2 = str;
        str2 = str2.Trim();
        if ((!str2.StartsWith("in (unmanaged)") && (str2.IndexOf("(wrapper managed-to-native)") == -1)) && ((str2.IndexOf("(wrapper delegate-invoke)") == -1) && (str2.IndexOf("at <0x00000> <unknown method>") == -1)))
        {
          if (str2.IndexOf("at ") != -1)
          {
            str2 = str2.Remove(0, 3);
          }
          int index = str2.IndexOf("[0x");
          int num4 = str2.IndexOf("]");
          if ((index != -1) && (num4 > index))
          {
            str2 = str2.Remove(index, (num4 - index) + 1);
          }
          str2 = str2.Replace(projectFolder, "");
          int startIndex = str2.LastIndexOf(" in ");
          if (startIndex != -1)
          {
            str2 = str2.Remove(startIndex, 4).Insert(startIndex, "  (at ");
            str2 = str2.Insert(str2.Length, ")");
          }
          builder.Append(str2);
          cleanedUpsplit.Add(builder.ToString());
        }
      }
    }
    return ProcessSplitCleanup(cleanedUpsplit);
  }

  public static StringBuilder ProcessSplitCleanup(ArrayList cleanedUpsplit)
  {
    StringBuilder builder = new StringBuilder(cleanedUpsplit.Count * 100);
    foreach (<span class="posthilit">string</span> str in cleanedUpsplit)
    {
      <span class="posthilit">string</span> str2 = str;
      if (!str2.Contains("UnityEngine.Debug:Internal_Log(Int32, <span class="posthilit">String</span>, Object)"))
      {
        if (str2.Contains("UnityEngine.Debug:Log"))
        {
          int index = str2.IndexOf(") (at");
          if (index != -1)
          {
            str2 = str2.Substring(0, index + 1);
          }
        }
        builder.Append(str2);
        builder.Append("\n");
      }
    }
    return builder;
  }

  public static void SetProjectFolder(<span class="posthilit">string</span> folder)
  {
    projectFolder = folder;
  }
}
 
правильный вопрос - половина ответа. учитесь формулировать вопросы понятно.
Новости > _Telegram чат @unity3d_ru (11.6k/4.8k online) > _Telegram канал @unity_news (4.6k подписчиков) > Телеграм тема > "Спасибо"
Аватара пользователя
DbIMok
Адепт
 
Сообщения: 6372
Зарегистрирован: 31 июл 2009, 14:05

Re: Знаете ли вы что...

Сообщение DbIMok 20 апр 2010, 00:30

Синтаксис:
Используется csharp
public class TextEditor : IKeyboardControl
{
  // Fields
  public GUIContent content = new GUIContent();
  public int controlID;
  public Vector2 graphicalCursorPos;
  public Vector2 graphicalSelectCursorPos;
  public bool hasHorizontalCursorPos;
  public bool isPasswordField;
  private bool m_bJustSelected;
  private int m_DblClickInitPos;
  private DblClickSnapping m_DblClickSnap;
  private int m_iAltCursorPos = -1;
  private bool m_MouseDragSelectsWholeWords;
  public bool multiline;
  private int oldPos;
  private int oldSelectPos;
  private <span class="posthilit">string</span> oldText;
  public int pos;
  public Rect position;
  private static Hashtable s_Keyactions;
  public Vector2 scrollOffset = Vector2.zero;
  public int selectPos;
  public GUIStyle style = GUIStyle.none;

  // Methods
  public bool Backspace()
  {
    if (this.hasSelection)
    {
      this.DeleteSelection();
      return true;
    }
    if (this.pos > 0)
    {
      this.content.text = this.content.text.Remove(this.pos - 1, 1);
      int num = this.pos - 1;
      this.pos = num;
      this.selectPos = num;
      this.ClearCursorPos();
      return true;
    }
    return false;
  }

  public bool CanPaste()
  {
    return (GUIUtility.systemCopyBuffer.Length != 0);
  }

  public void ClampPos()
  {
    if (this.pos < 0)
    {
      this.pos = 0;
    }
    else if (this.pos > this.content.text.Length)
    {
      this.pos = this.content.text.Length;
    }
    if (this.selectPos < 0)
    {
      this.selectPos = 0;
    }
    else if (this.selectPos > this.content.text.Length)
    {
      this.selectPos = this.content.text.Length;
    }
    if (this.m_iAltCursorPos > this.content.text.Length)
    {
      this.m_iAltCursorPos = this.content.text.Length;
    }
  }

  private CharacterType ClassifyChar(char c)
  {
    if (char.IsWhiteSpace(c))
    {
      return CharacterType.WhiteSpace;
    }
    if (!char.IsLetterOrDigit(c) && (c != '\''))
    {
      return CharacterType.Symbol;
    }
    return CharacterType.LetterLike;
  }

  private void ClearCursorPos()
  {
    this.hasHorizontalCursorPos = false;
    this.m_iAltCursorPos = -1;
  }

  public void Copy()
  {
    if ((this.selectPos != this.pos) && !this.isPasswordField)
    {
      <span class="posthilit">string</span> str;
      if (this.pos < this.selectPos)
      {
        str = this.content.text.Substring(this.pos, this.selectPos - this.pos);
      }
      else
      {
        str = this.content.text.Substring(this.selectPos, this.pos - this.selectPos);
      }
      GUIUtility.systemCopyBuffer = str;
    }
  }

  public bool Cut()
  {
    if (this.isPasswordField)
    {
      return false;
    }
    this.Copy();
    return this.DeleteSelection();
  }

  public void DblClickSnap(DblClickSnapping snapping)
  {
    this.m_DblClickSnap = snapping;
  }

  public bool Delete()
  {
    if (this.hasSelection)
    {
      this.DeleteSelection();
      return true;
    }
    if (this.pos < this.content.text.Length)
    {
      this.content.text = this.content.text.Remove(this.pos, 1);
      return true;
    }
    return false;
  }

  public bool DeleteSelection()
  {
    int length = this.content.text.Length;
    if (this.pos > length)
    {
      this.pos = length;
    }
    if (this.selectPos > length)
    {
      this.selectPos = length;
    }
    if (this.pos == this.selectPos)
    {
      return false;
    }
    if (this.pos < this.selectPos)
    {
      this.content.text = this.content.text.Substring(0, this.pos) + this.content.text.Substring(this.selectPos, this.content.text.Length - this.selectPos);
      this.selectPos = this.pos;
    }
    else
    {
      this.content.text = this.content.text.Substring(0, this.selectPos) + this.content.text.Substring(this.pos, this.content.text.Length - this.pos);
      this.pos = this.selectPos;
    }
    this.ClearCursorPos();
    return true;
  }

  public void DrawCursor(<span class="posthilit">string</span> text)
  {
    <span class="posthilit">string</span> str = this.content.text;
    this.content.text = text;
    Rect position = new Rect(0f, 0f, this.position.width, this.position.height);
    this.graphicalCursorPos = this.style.GetCursorPixelPosition(position, this.content, this.pos);
    Rect rect = this.style.padding.Remove(this.position);
    Vector2 vector = this.style.CalcSize(this.content);
    if (vector.x < rect.width)
    {
      this.scrollOffset.x = 0f;
    }
    else
    {
      if (this.graphicalCursorPos.x < this.scrollOffset.x)
      {
        this.scrollOffset.x = this.graphicalCursorPos.x;
      }
      else if (this.graphicalCursorPos.x > (this.scrollOffset.x + rect.width))
      {
        this.scrollOffset.x = (this.graphicalCursorPos.x - rect.width) + 1f;
      }
      if ((this.scrollOffset.x + rect.width) > vector.x)
      {
        this.scrollOffset.x = (vector.x - rect.width) + 1f;
      }
    }
    if (vector.y < rect.height)
    {
      this.scrollOffset.y = 0f;
    }
    else
    {
      if (this.graphicalCursorPos.y < this.scrollOffset.y)
      {
        this.scrollOffset.y = this.graphicalCursorPos.y + 1f;
      }
      else if (this.graphicalCursorPos.y >= ((this.scrollOffset.y + rect.height) - 3.0))
      {
        this.scrollOffset.y = this.graphicalCursorPos.y + 1f;
      }
      if ((this.scrollOffset.y + rect.height) > vector.y)
      {
        this.scrollOffset.y = (vector.y - rect.height) + 1f;
      }
    }
    this.scrollOffset.y = (this.scrollOffset.y >= 0f) ? this.scrollOffset.y : 0f;
    this.style.contentOffset = Vector2.op_UnaryNegation(this.scrollOffset);
    this.style.Internal_clipOffset = this.scrollOffset;
    this.style.DrawWithTextSelection(this.position, this.content, this.controlID, this.pos, this.selectPos);
    if (this.m_iAltCursorPos != -1)
    {
      this.style.DrawCursor(this.position, this.content, this.controlID, this.m_iAltCursorPos);
    }
    this.style.contentOffset = Vector2.zero;
    this.style.Internal_clipOffset = Vector2.zero;
    this.content.text = str;
  }

  public void ExpandSelectGraphicalLineEnd()
  {
    this.ClearCursorPos();
    if (this.pos > this.selectPos)
    {
      this.pos = this.GetGraphicalLineEnd(this.pos);
    }
    else
    {
      int pos = this.pos;
      this.pos = this.GetGraphicalLineEnd(this.selectPos);
      this.selectPos = pos;
    }
  }

  public void ExpandSelectGraphicalLineStart()
  {
    this.ClearCursorPos();
    if (this.pos < this.selectPos)
    {
      this.pos = this.GetGraphicalLineStart(this.pos);
    }
    else
    {
      int pos = this.pos;
      this.pos = this.GetGraphicalLineStart(this.selectPos);
      this.selectPos = pos;
    }
  }

  private int FindEndOfClassification(int p, int dir)
  {
    int length = this.content.text.Length;
    if (p >= length)
    {
      return p;
    }
    CharacterType type = this.ClassifyChar(this.content.text[p]);
    do
    {
      p += dir;
      if (p < 0)
      {
        return 0;
      }
      if (p >= length)
      {
        return length;
      }
    }
    while (this.ClassifyChar(this.content.text[p]) == type);
    if (dir == 1)
    {
      return p;
    }
    return (p + 1);
  }

  private int FindEndOfPreviousWord(int p)
  {
    if (p != 0)
    {
      p--;
      while ((p > 0) && (this.content.text[p] == ' '))
      {
        p--;
      }
      CharacterType type = this.ClassifyChar(this.content.text[p]);
      if (type == CharacterType.WhiteSpace)
      {
        return p;
      }
      while ((p > 0) && (this.ClassifyChar(this.content.text[p - 1]) == type))
      {
        p--;
      }
    }
    return p;
  }

  private int FindNextSeperator(int startPos)
  {
    int length = this.content.text.Length;
    while ((startPos < length) && !isLetterLikeChar(this.content.text[startPos]))
    {
      startPos++;
    }
    while ((startPos < length) && isLetterLikeChar(this.content.text[startPos]))
    {
      startPos++;
    }
    return startPos;
  }

  private int FindPrevSeperator(int startPos)
  {
    startPos--;
    while ((startPos > 0) && !isLetterLikeChar(this.content.text[startPos]))
    {
      startPos--;
    }
    while ((startPos >= 0) && isLetterLikeChar(this.content.text[startPos]))
    {
      startPos--;
    }
    return (startPos + 1);
  }

  public int FindStartOfNextWord(int p)
  {
    int length = this.content.text.Length;
    if (p != length)
    {
      char c = this.content.text[p];
      CharacterType type = this.ClassifyChar(c);
      if (type != CharacterType.WhiteSpace)
      {
        p++;
        while ((p < length) && (this.ClassifyChar(this.content.text[p]) == type))
        {
          p++;
        }
      }
      else
      {
        switch (c)
        {
          case '\t':
          case '\n':
            return (p + 1);
        }
      }
      if (p != length)
      {
        switch (this.content.text[p])
        {
          case ' ':
            while ((p < length) && char.IsWhiteSpace(this.content.text[p]))
            {
              p++;
            }
            return p;
        }
      }
    }
    return p;
  }

  private int GetGraphicalLineEnd(int p)
  {
    Vector2 cursorPixelPosition = this.style.GetCursorPixelPosition(this.position, this.content, p);
    cursorPixelPosition.x += 5000f;
    return this.style.GetCursorStringIndex(this.position, this.content, cursorPixelPosition);
  }

  private int GetGraphicalLineStart(int p)
  {
    Vector2 cursorPixelPosition = this.style.GetCursorPixelPosition(this.position, this.content, p);
    cursorPixelPosition.x = 0f;
    return this.style.GetCursorStringIndex(this.position, this.content, cursorPixelPosition);
  }

  private void GrabGraphicalCursorPos()
  {
    if (!this.hasHorizontalCursorPos)
    {
      this.graphicalCursorPos = this.style.GetCursorPixelPosition(this.position, this.content, this.pos);
      this.graphicalSelectCursorPos = this.style.GetCursorPixelPosition(this.position, this.content, this.selectPos);
      this.hasHorizontalCursorPos = false;
    }
  }

  public bool HandleKeyEvent(Event e)
  {
    this.InitKeyActions();
    Event.Modifiers modifiers = e.modifiers;
    e.modifiers &= ~Event.Modifiers.CapsLock;
    if (s_Keyactions.Contains(e))
    {
      TextEditOp operation = (TextEditOp) s_Keyactions[e];
      this.PerformOperation(operation);
      e.modifiers = modifiers;
      return true;
    }
    e.modifiers = modifiers;
    return false;
  }

  private void InitKeyActions()
  {
    if (s_Keyactions == null)
    {
      s_Keyactions = new Hashtable();
      MapKey("left", TextEditOp.MoveLeft);
      MapKey("right", TextEditOp.MoveRight);
      MapKey("up", TextEditOp.MoveUp);
      MapKey("down", TextEditOp.MoveDown);
      MapKey("#left", TextEditOp.SelectLeft);
      MapKey("#right", TextEditOp.SelectRight);
      MapKey("#up", TextEditOp.SelectUp);
      MapKey("#down", TextEditOp.SelectDown);
      MapKey("delete", TextEditOp.Delete);
      MapKey("backspace", TextEditOp.Backspace);
      MapKey("#backspace", TextEditOp.Backspace);
      if (((Application.platform != RuntimePlatform.WindowsPlayer) && (Application.platform != RuntimePlatform.WindowsWebPlayer)) && (Application.platform != RuntimePlatform.WindowsEditor))
      {
        MapKey("^left", TextEditOp.MoveGraphicalLineStart);
        MapKey("^right", TextEditOp.MoveGraphicalLineEnd);
        MapKey("&left", TextEditOp.MoveWordLeft);
        MapKey("&right", TextEditOp.MoveWordRight);
        MapKey("&up", TextEditOp.MoveParagraphBackward);
        MapKey("&down", TextEditOp.MoveParagraphForward);
        MapKey("%left", TextEditOp.MoveGraphicalLineStart);
        MapKey("%right", TextEditOp.MoveGraphicalLineEnd);
        MapKey("%up", TextEditOp.MoveTextStart);
        MapKey("%down", TextEditOp.MoveTextEnd);
        MapKey("#home", TextEditOp.SelectTextStart);
        MapKey("#end", TextEditOp.SelectTextEnd);
        MapKey("#^left", TextEditOp.ExpandSelectGraphicalLineStart);
        MapKey("#^right", TextEditOp.ExpandSelectGraphicalLineEnd);
        MapKey("#^up", TextEditOp.SelectParagraphBackward);
        MapKey("#^down", TextEditOp.SelectParagraphForward);
        MapKey("#&left", TextEditOp.SelectWordLeft);
        MapKey("#&right", TextEditOp.SelectWordRight);
        MapKey("#&up", TextEditOp.SelectParagraphBackward);
        MapKey("#&down", TextEditOp.SelectParagraphForward);
        MapKey("#%left", TextEditOp.ExpandSelectGraphicalLineStart);
        MapKey("#%right", TextEditOp.ExpandSelectGraphicalLineEnd);
        MapKey("#%up", TextEditOp.SelectTextStart);
        MapKey("#%down", TextEditOp.SelectTextEnd);
        MapKey("%a", TextEditOp.SelectAll);
        MapKey("%x", TextEditOp.Cut);
        MapKey("%c", TextEditOp.Copy);
        MapKey("%v", TextEditOp.Paste);
        MapKey("^d", TextEditOp.Delete);
        MapKey("^h", TextEditOp.Backspace);
        MapKey("^b", TextEditOp.MoveLeft);
        MapKey("^f", TextEditOp.MoveRight);
        MapKey("^a", TextEditOp.MoveLineStart);
        MapKey("^e", TextEditOp.MoveLineEnd);
      }
      else
      {
        MapKey("home", TextEditOp.MoveGraphicalLineStart);
        MapKey("end", TextEditOp.MoveGraphicalLineEnd);
        MapKey("%left", TextEditOp.MoveWordLeft);
        MapKey("%right", TextEditOp.MoveWordRight);
        MapKey("%up", TextEditOp.MoveParagraphBackward);
        MapKey("%down", TextEditOp.MoveParagraphForward);
        MapKey("^left", TextEditOp.MoveToEndOfPreviousWord);
        MapKey("^right", TextEditOp.MoveToStartOfNextWord);
        MapKey("^up", TextEditOp.MoveParagraphBackward);
        MapKey("^down", TextEditOp.MoveParagraphForward);
        MapKey("#^left", TextEditOp.SelectToEndOfPreviousWord);
        MapKey("#^right", TextEditOp.SelectToStartOfNextWord);
        MapKey("#^up", TextEditOp.SelectParagraphBackward);
        MapKey("#^down", TextEditOp.SelectParagraphForward);
        MapKey("#home", TextEditOp.SelectGraphicalLineStart);
        MapKey("#end", TextEditOp.SelectGraphicalLineEnd);
        MapKey("^a", TextEditOp.SelectAll);
        MapKey("^x", TextEditOp.Cut);
        MapKey("^c", TextEditOp.Copy);
        MapKey("^v", TextEditOp.Paste);
      }
    }
  }

  public void Insert(char c)
  {
    char[] chArray = new char[] { c };
    this.ReplaceSelection(new <span class="posthilit">string</span>(chArray));
  }

  private static bool isLetterLikeChar(char c)
  {
    return (char.IsLetterOrDigit(c) || (c == '\''));
  }

  public bool IsOverSelection(Vector2 cursorPosition)
  {
    int num = this.style.GetCursorStringIndex(this.position, this.content, cursorPosition + this.scrollOffset);
    return ((num < Mathf.Max(this.pos, this.selectPos)) && (num > Mathf.Min(this.pos, this.selectPos)));
  }

  private static void MapKey(<span class="posthilit">string</span> key, TextEditOp action)
  {
    s_Keyactions[Event.KeyboardEvent(key)] = action;
  }

  public void MouseDragSelectsWholeWords(bool on)
  {
    this.m_MouseDragSelectsWholeWords = on;
    this.m_DblClickInitPos = this.pos;
  }

  public void MoveAltCursorToPosition(Vector2 cursorPosition)
  {
    this.m_iAltCursorPos = this.style.GetCursorStringIndex(this.position, this.content, cursorPosition + this.scrollOffset);
    this.ClampPos();
  }

  public void MoveCursorToPosition(Vector2 cursorPosition)
  {
    this.selectPos = this.style.GetCursorStringIndex(this.position, this.content, cursorPosition + this.scrollOffset);
    if (!Event.current.shift)
    {
      this.pos = this.selectPos;
    }
    this.ClampPos();
  }

  public void MoveDown()
  {
    if (this.selectPos > this.pos)
    {
      this.selectPos = this.pos;
    }
    else
    {
      this.pos = this.selectPos;
    }
    this.GrabGraphicalCursorPos();
    this.graphicalCursorPos.y += this.style.lineHeight + 5f;
    int num = this.style.GetCursorStringIndex(this.position, this.content, this.graphicalCursorPos);
    this.selectPos = num;
    this.pos = num;
    if (this.pos == this.content.text.Length)
    {
      this.ClearCursorPos();
    }
  }

  public void MoveGraphicalLineEnd()
  {
    int graphicalLineEnd = this.GetGraphicalLineEnd((this.pos <= this.selectPos) ? this.selectPos : this.pos);
    this.selectPos = graphicalLineEnd;
    this.pos = graphicalLineEnd;
  }

  public void MoveGraphicalLineStart()
  {
    int graphicalLineStart = this.GetGraphicalLineStart((this.pos >= this.selectPos) ? this.selectPos : this.pos);
    this.selectPos = graphicalLineStart;
    this.pos = graphicalLineStart;
  }

  public void MoveLeft()
  {
    if (this.selectPos == this.pos)
    {
      this.pos--;
      if (this.pos < 0)
      {
        this.pos = 0;
      }
      this.selectPos = this.pos;
    }
    else if (this.selectPos > this.pos)
    {
      this.selectPos = this.pos;
    }
    else
    {
      this.pos = this.selectPos;
    }
    this.ClearCursorPos();
  }

  public void MoveLineEnd()
  {
    int num4;
    int num = (this.selectPos <= this.pos) ? this.pos : this.selectPos;
    int num2 = num;
    int length = this.content.text.Length;
    while (num2 < length)
    {
      if (this.content.text[num2] == '\n')
      {
        num4 = num2;
        this.pos = num4;
        this.selectPos = num4;
        return;
      }
      num2++;
    }
    num4 = length;
    this.pos = num4;
    this.selectPos = num4;
  }

  public void MoveLineStart()
  {
    int num = (this.selectPos >= this.pos) ? this.pos : this.selectPos;
    int num2 = num;
    while (num2-- != 0)
    {
      if (this.content.text[num2] == '\n')
      {
        int num3 = num2 + 1;
        this.pos = num3;
        this.selectPos = num3;
        return;
      }
    }
    this.pos = 0;
    this.selectPos = 0;
  }

  public void MoveParagraphBackward()
  {
    this.pos = (this.pos >= this.selectPos) ? this.selectPos : this.pos;
    if (this.pos > 1)
    {
      int num = this.content.text.LastIndexOf('\n', this.pos - 2) + 1;
      this.pos = num;
      this.selectPos = num;
    }
    else
    {
      this.pos = 0;
      this.selectPos = 0;
    }
  }

  public void MoveParagraphForward()
  {
    this.pos = (this.pos <= this.selectPos) ? this.selectPos : this.pos;
    if (this.pos < this.content.text.Length)
    {
      int index = this.content.text.IndexOf('\n', this.pos + 1);
      this.pos = index;
      this.selectPos = index;
      if (this.pos == -1)
      {
        index = this.content.text.Length;
        this.pos = index;
        this.selectPos = index;
      }
    }
  }

  public void MoveRight()
  {
    this.ClearCursorPos();
    if (this.selectPos == this.pos)
    {
      this.pos++;
      this.ClampPos();
      this.selectPos = this.pos;
    }
    else if (this.selectPos > this.pos)
    {
      this.pos = this.selectPos;
    }
    else
    {
      this.selectPos = this.pos;
    }
  }

  public void MoveSelectionToAltCursor()
  {
    if (this.m_iAltCursorPos != -1)
    {
      int iAltCursorPos = this.m_iAltCursorPos;
      <span class="posthilit">string</span> selectedText = this.SelectedText;
      this.content.text = this.content.text.Insert(iAltCursorPos, selectedText);
      if (iAltCursorPos < this.pos)
      {
        this.pos += selectedText.Length;
        this.selectPos += selectedText.Length;
      }
      this.DeleteSelection();
      int num2 = iAltCursorPos;
      this.pos = num2;
      this.selectPos = num2;
      this.ClearCursorPos();
    }
  }

  public void MoveTextEnd()
  {
    int length = this.content.text.Length;
    this.pos = length;
    this.selectPos = length;
  }

  public void MoveTextStart()
  {
    this.pos = 0;
    this.selectPos = 0;
  }

  public void MoveToEndOfPreviousWord()
  {
    this.ClearCursorPos();
    if (this.pos != this.selectPos)
    {
      this.MoveLeft();
    }
    else
    {
      int num = this.FindEndOfPreviousWord(this.pos);
      this.selectPos = num;
      this.pos = num;
    }
  }

  public void MoveToStartOfNextWord()
  {
    this.ClearCursorPos();
    if (this.pos != this.selectPos)
    {
      this.MoveRight();
    }
    else
    {
      int num = this.FindStartOfNextWord(this.pos);
      this.selectPos = num;
      this.pos = num;
    }
  }

  public void MoveUp()
  {
    if (this.selectPos < this.pos)
    {
      this.selectPos = this.pos;
    }
    else
    {
      this.pos = this.selectPos;
    }
    this.GrabGraphicalCursorPos();
    this.graphicalCursorPos.y--;
    int num = this.style.GetCursorStringIndex(this.position, this.content, this.graphicalCursorPos);
    this.selectPos = num;
    this.pos = num;
    if (this.pos <= 0)
    {
      this.ClearCursorPos();
    }
  }

  public void MoveWordLeft()
  {
    this.pos = (this.pos >= this.selectPos) ? this.selectPos : this.pos;
    this.pos = this.FindPrevSeperator(this.pos);
    this.selectPos = this.pos;
  }

  public void MoveWordRight()
  {
    this.pos = (this.pos <= this.selectPos) ? this.selectPos : this.pos;
    int num = this.FindNextSeperator(this.pos);
    this.selectPos = num;
    this.pos = num;
    this.ClearCursorPos();
  }

  public void OnFocus()
  {
    if (this.multiline)
    {
      this.selectPos = 0;
      this.pos = 0;
    }
    else
    {
      this.SelectAll();
    }
  }

  public virtual void OnLostFocus()
  {
    this.scrollOffset = Vector2.zero;
  }

  public bool Paste()
  {
    <span class="posthilit">string</span> systemCopyBuffer = GUIUtility.systemCopyBuffer;
    if (systemCopyBuffer != "")
    {
      this.ReplaceSelection(systemCopyBuffer);
      return true;
    }
    return false;
  }

  private bool PerformOperation(TextEditOp operation)
  {
    switch (operation)
    {
      case TextEditOp.MoveLeft:
        this.MoveLeft();
        break;

      case TextEditOp.MoveRight:
        this.MoveRight();
        break;

      case TextEditOp.MoveUp:
        this.MoveUp();
        break;

      case TextEditOp.MoveDown:
        this.MoveDown();
        break;

      case TextEditOp.MoveLineStart:
        this.MoveLineStart();
        break;

      case TextEditOp.MoveLineEnd:
        this.MoveLineEnd();
        break;

      case TextEditOp.MoveTextStart:
        this.MoveTextStart();
        break;

      case TextEditOp.MoveTextEnd:
        this.MoveTextEnd();
        break;

      case TextEditOp.MoveGraphicalLineStart:
        this.MoveGraphicalLineStart();
        break;

      case TextEditOp.MoveGraphicalLineEnd:
        this.MoveGraphicalLineEnd();
        break;

      case TextEditOp.MoveWordLeft:
        this.MoveWordLeft();
        break;

      case TextEditOp.MoveWordRight:
        this.MoveWordRight();
        break;

      case TextEditOp.MoveParagraphForward:
        this.MoveParagraphForward();
        break;

      case TextEditOp.MoveParagraphBackward:
        this.MoveParagraphBackward();
        break;

      case TextEditOp.MoveToStartOfNextWord:
        this.MoveToStartOfNextWord();
        break;

      case TextEditOp.MoveToEndOfPreviousWord:
        this.MoveToEndOfPreviousWord();
        break;

      case TextEditOp.SelectLeft:
        this.SelectLeft();
        break;

      case TextEditOp.SelectRight:
        this.SelectRight();
        break;

      case TextEditOp.SelectUp:
        this.SelectUp();
        break;

      case TextEditOp.SelectDown:
        this.SelectDown();
        break;

      case TextEditOp.SelectTextStart:
        this.SelectTextStart();
        break;

      case TextEditOp.SelectTextEnd:
        this.SelectTextEnd();
        break;

      case TextEditOp.ExpandSelectGraphicalLineStart:
        this.ExpandSelectGraphicalLineStart();
        break;

      case TextEditOp.ExpandSelectGraphicalLineEnd:
        this.ExpandSelectGraphicalLineEnd();
        break;

      case TextEditOp.SelectGraphicalLineStart:
        this.SelectGraphicalLineStart();
        break;

      case TextEditOp.SelectGraphicalLineEnd:
        this.SelectGraphicalLineEnd();
        break;

      case TextEditOp.SelectWordLeft:
        this.SelectWordLeft();
        break;

      case TextEditOp.SelectWordRight:
        this.SelectWordRight();
        break;

      case TextEditOp.SelectToEndOfPreviousWord:
        this.SelectToEndOfPreviousWord();
        break;

      case TextEditOp.SelectToStartOfNextWord:
        this.SelectToStartOfNextWord();
        break;

      case TextEditOp.SelectParagraphBackward:
        this.SelectParagraphBackward();
        break;

      case TextEditOp.SelectParagraphForward:
        this.SelectParagraphForward();
        break;

      case TextEditOp.Delete:
        return this.Delete();

      case TextEditOp.Backspace:
        return this.Backspace();

      case TextEditOp.Cut:
        return this.Cut();

      case TextEditOp.Copy:
        this.Copy();
        break;

      case TextEditOp.Paste:
        return this.Paste();

      case TextEditOp.SelectAll:
        this.SelectAll();
        break;

      case TextEditOp.SelectNone:
        this.SelectNone();
        break;

      default:
        Debug.Log("Unimplemented: " + operation);
        break;
    }
    return false;
  }

  public void ReplaceSelection(<span class="posthilit">string</span> replace)
  {
    this.DeleteSelection();
    this.content.text = this.content.text.Insert(this.pos, replace);
    int num = this.pos + replace.Length;
    this.pos = num;
    this.selectPos = num;
    this.ClearCursorPos();
  }

  public void SaveBackup()
  {
    this.oldText = this.content.text;
    this.oldPos = this.pos;
    this.oldSelectPos = this.selectPos;
  }

  public void SelectAll()
  {
    this.pos = 0;
    this.selectPos = this.content.text.Length;
    this.ClearCursorPos();
  }

  public void SelectCurrentParagraph()
  {
    this.ClearCursorPos();
    int length = this.content.text.Length;
    if (this.pos < length)
    {
      this.pos = this.content.text.IndexOf('\n', this.pos);
      if (this.pos == -1)
      {
        this.pos = this.content.text.Length;
      }
      else
      {
        this.pos++;
      }
    }
    if (this.selectPos != 0)
    {
      this.selectPos = this.content.text.LastIndexOf('\n', this.selectPos - 1) + 1;
    }
  }

  public void SelectCurrentWord()
  {
    this.ClearCursorPos();
    int length = this.content.text.Length;
    this.selectPos = this.pos;
    if (length != 0)
    {
      if (this.pos >= length)
      {
        this.pos = length - 1;
      }
      if (this.selectPos >= length)
      {
        this.selectPos--;
      }
      if (this.pos < this.selectPos)
      {
        this.pos = this.FindEndOfClassification(this.pos, -1);
        this.selectPos = this.FindEndOfClassification(this.selectPos, 1);
      }
      else
      {
        this.pos = this.FindEndOfClassification(this.pos, 1);
        this.selectPos = this.FindEndOfClassification(this.selectPos, -1);
      }
      this.m_bJustSelected = true;
    }
  }

  public void SelectDown()
  {
    this.GrabGraphicalCursorPos();
    this.graphicalCursorPos.y += this.style.lineHeight + 5f;
    this.pos = this.style.GetCursorStringIndex(this.position, this.content, this.graphicalCursorPos);
  }

  public void SelectGraphicalLineEnd()
  {
    this.ClearCursorPos();
    this.pos = this.GetGraphicalLineEnd(this.pos);
  }

  public void SelectGraphicalLineStart()
  {
    this.ClearCursorPos();
    this.pos = this.GetGraphicalLineStart(this.pos);
  }

  public void SelectLeft()
  {
    if (this.m_bJustSelected && (this.pos > this.selectPos))
    {
      int pos = this.pos;
      this.pos = this.selectPos;
      this.selectPos = pos;
    }
    this.m_bJustSelected = false;
    this.pos--;
    if (this.pos < 0)
    {
      this.pos = 0;
    }
  }

  public void SelectNone()
  {
    this.selectPos = this.pos;
    this.ClearCursorPos();
  }

  public void SelectParagraphBackward()
  {
    this.ClearCursorPos();
    bool flag = this.pos > this.selectPos;
    if (this.pos > 1)
    {
      this.pos = this.content.text.LastIndexOf('\n', this.pos - 2) + 1;
      if (flag && (this.pos < this.selectPos))
      {
        this.pos = this.selectPos;
      }
    }
    else
    {
      this.pos = 0;
      this.selectPos = 0;
    }
  }

  public void SelectParagraphForward()
  {
    this.ClearCursorPos();
    bool flag = this.pos < this.selectPos;
    if (this.pos < this.content.text.Length)
    {
      this.pos = this.content.text.IndexOf('\n', this.pos + 1);
      if (this.pos == -1)
      {
        this.pos = this.content.text.Length;
      }
      if (flag && (this.pos > this.selectPos))
      {
        this.pos = this.selectPos;
      }
    }
  }

  public void SelectRight()
  {
    if (this.m_bJustSelected && (this.pos < this.selectPos))
    {
      int pos = this.pos;
      this.pos = this.selectPos;
      this.selectPos = pos;
    }
    this.m_bJustSelected = false;
    this.pos++;
    int length = this.content.text.Length;
    if (this.pos > length)
    {
      this.pos = length;
    }
  }

  public void SelectTextEnd()
  {
    this.pos = this.content.text.Length;
  }

  public void SelectTextStart()
  {
    this.pos = 0;
  }

  public void SelectToEndOfPreviousWord()
  {
    this.ClearCursorPos();
    this.pos = this.FindEndOfPreviousWord(this.pos);
  }

  public void SelectToPosition(Vector2 cursorPosition)
  {
    if (!this.m_MouseDragSelectsWholeWords)
    {
      this.pos = this.style.GetCursorStringIndex(this.position, this.content, cursorPosition + this.scrollOffset);
    }
    else
    {
      int p = this.style.GetCursorStringIndex(this.position, this.content, cursorPosition + this.scrollOffset);
      if (this.m_DblClickSnap == DblClickSnapping.WORDS)
      {
        if (p < this.m_DblClickInitPos)
        {
          this.pos = this.FindEndOfClassification(p, -1);
          this.selectPos = this.FindEndOfClassification(this.m_DblClickInitPos, 1);
        }
        else
        {
          if (p >= this.content.text.Length)
          {
            p = this.content.text.Length - 1;
          }
          this.pos = this.FindEndOfClassification(p, 1);
          this.selectPos = this.FindEndOfClassification(this.m_DblClickInitPos - 1, -1);
        }
      }
      else if (p < this.m_DblClickInitPos)
      {
        if (p > 0)
        {
          this.pos = this.content.text.LastIndexOf('\n', p - 2) + 1;
        }
        else
        {
          this.pos = 0;
        }
        this.selectPos = this.content.text.LastIndexOf('\n', this.m_DblClickInitPos);
      }
      else
      {
        if (p < this.content.text.Length)
        {
          this.pos = this.content.text.IndexOf('\n', p + 1) + 1;
          if (this.pos <= 0)
          {
            this.pos = this.content.text.Length;
          }
        }
        else
        {
          this.pos = this.content.text.Length;
        }
        this.selectPos = this.content.text.LastIndexOf('\n', this.m_DblClickInitPos - 2) + 1;
      }
    }
  }

  public void SelectToStartOfNextWord()
  {
    this.ClearCursorPos();
    this.pos = this.FindStartOfNextWord(this.pos);
  }

  public void SelectUp()
  {
    this.GrabGraphicalCursorPos();
    this.graphicalCursorPos.y--;
    this.pos = this.style.GetCursorStringIndex(this.position, this.content, this.graphicalCursorPos);
  }

  public void SelectWordLeft()
  {
    this.ClearCursorPos();
    int selectPos = this.selectPos;
    if (this.pos > this.selectPos)
    {
      this.selectPos = this.pos;
      this.MoveWordLeft();
      this.selectPos = selectPos;
      this.pos = (this.pos <= this.selectPos) ? this.selectPos : this.pos;
    }
    else
    {
      this.selectPos = this.pos;
      this.MoveWordLeft();
      this.selectPos = selectPos;
    }
  }

  public void SelectWordRight()
  {
    this.ClearCursorPos();
    int selectPos = this.selectPos;
    if (this.pos < this.selectPos)
    {
      this.selectPos = this.pos;
      this.MoveWordRight();
      this.selectPos = selectPos;
      this.pos = (this.pos >= this.selectPos) ? this.selectPos : this.pos;
    }
    else
    {
      this.selectPos = this.pos;
      this.MoveWordRight();
      this.selectPos = selectPos;
    }
  }

  public void Undo()
  {
    this.content.text = this.oldText;
    this.pos = this.oldPos;
    this.selectPos = this.oldSelectPos;
  }

  // Properties
  public bool hasSelection
  {
    get
    {
      return (this.pos != this.selectPos);
    }
  }

  public <span class="posthilit">string</span> SelectedText
  {
    get
    {
      int length = this.content.text.Length;
      if (this.pos > length)
      {
        this.pos = length;
      }
      if (this.selectPos > length)
      {
        this.selectPos = length;
      }
      if (this.pos == this.selectPos)
      {
        return "";
      }
      if (this.pos < this.selectPos)
      {
        return this.content.text.Substring(this.pos, this.selectPos - this.pos);
      }
      return this.content.text.Substring(this.selectPos, this.pos - this.selectPos);
    }
  }

  // Nested Types
  private enum CharacterType
  {
    LetterLike,
    Symbol,
    Symbol2,
    WhiteSpace
  }

  public enum DblClickSnapping : byte
  {
    PARAGRAPHS = 1,
    WORDS = 0
  }

  private enum TextEditOp
  {
    MoveLeft,
    MoveRight,
    MoveUp,
    MoveDown,
    MoveLineStart,
    MoveLineEnd,
    MoveTextStart,
    MoveTextEnd,
    MovePageUp,
    MovePageDown,
    MoveGraphicalLineStart,
    MoveGraphicalLineEnd,
    MoveWordLeft,
    MoveWordRight,
    MoveParagraphForward,
    MoveParagraphBackward,
    MoveToStartOfNextWord,
    MoveToEndOfPreviousWord,
    SelectLeft,
    SelectRight,
    SelectUp,
    SelectDown,
    SelectTextStart,
    SelectTextEnd,
    SelectPageUp,
    SelectPageDown,
    ExpandSelectGraphicalLineStart,
    ExpandSelectGraphicalLineEnd,
    SelectGraphicalLineStart,
    SelectGraphicalLineEnd,
    SelectWordLeft,
    SelectWordRight,
    SelectToEndOfPreviousWord,
    SelectToStartOfNextWord,
    SelectParagraphBackward,
    SelectParagraphForward,
    Delete,
    Backspace,
    DeleteWordBack,
    Cut,
    Copy,
    Paste,
    SelectAll,
    SelectNone,
    ScrollStart,
    ScrollEnd,
    ScrollPageUp,
    ScrollPageDown
  }
}
правильный вопрос - половина ответа. учитесь формулировать вопросы понятно.
Новости > _Telegram чат @unity3d_ru (11.6k/4.8k online) > _Telegram канал @unity_news (4.6k подписчиков) > Телеграм тема > "Спасибо"
Аватара пользователя
DbIMok
Адепт
 
Сообщения: 6372
Зарегистрирован: 31 июл 2009, 14:05

Re: Знаете ли вы что...

Сообщение DbIMok 20 апр 2010, 00:35

Синтаксис:
Используется csharp
public class UnityScriptCompiler
{
  // Fields
  protected BooCompiler _compiler;
  protected UnityScriptCompilerParameters _parameters;

  // Methods
  public UnityScriptCompiler();
  public CompilerContext Run();

  // Properties
  public UnityScriptCompilerParameters Parameters { get; }

  // Nested Types
  [Serializable]
  public class Pipelines
  {
    // Methods
    public Pipelines();
    public static CompilerPipeline AdjustBooPipeline(CompilerPipeline pipeline);
    public static CompilerPipeline CompileToBoo();
    public static CompilerPipeline CompileToFile();
    public static CompilerPipeline CompileToFileAndVerify();
    public static CompilerPipeline CompileToMemory();
  }
}
 
правильный вопрос - половина ответа. учитесь формулировать вопросы понятно.
Новости > _Telegram чат @unity3d_ru (11.6k/4.8k online) > _Telegram канал @unity_news (4.6k подписчиков) > Телеграм тема > "Спасибо"
Аватара пользователя
DbIMok
Адепт
 
Сообщения: 6372
Зарегистрирован: 31 июл 2009, 14:05

Re: Знаете ли вы что...

Сообщение Neodrop 20 апр 2010, 09:38

Дымок, хорошо бы хоть две строчки коментов. :-?
Добавить neodrop в Skype
Изображение
"Спасибо!" нашему порталу, вы сможете сказать ЗДЕСЬ.
Если проблема не решается честно, нужно её обмануть! || Per stupiditas at Astra!
Страх порождает слабость. Бесстрашных поражают пули.
Протратившись на блядях байтах, на битах не экономят.
Аватара пользователя
Neodrop
Админ
 
Сообщения: 8480
Зарегистрирован: 08 окт 2008, 15:42
Откуда: Питер
Skype: neodrop
  • Сайт

Re: Знаете ли вы что...

Сообщение DbIMok 03 сен 2010, 23:51

... обращение к элементу, допустим, массива на (js) генерирует код:
Синтаксис:
Используется csharp
this.tstblt[RuntimeServices.NormalizeArrayIndex(this.tstblt, this.i)] = this.i;

где RuntimeServices.NormalizeArrayIndex это:
Синтаксис:
Используется csharp
public static int NormalizeIndex(int len, int index)
{
  if (index < 0)
  {
    index += len;
    if (index < 0)
    {
      return 0;
    }
  }
  if (index > len)
  {
    return len;
  }
  return index;
}
 

в отличии от кода, генерируемого (c#):
Синтаксис:
Используется csharp
this.tstBlt[this.i] = this.i;

в этом "виновата" реализация (js) через boo. в boo это можно обойти через оптимизирующую директиву rawarrayindex: но в (js), насколько я понимаю, мы ей воспользоваться не сможем. по этой причине работа с массивами и подобными им структурами в (js) будет всегда медленнее, чем в (c#).
правильный вопрос - половина ответа. учитесь формулировать вопросы понятно.
Новости > _Telegram чат @unity3d_ru (11.6k/4.8k online) > _Telegram канал @unity_news (4.6k подписчиков) > Телеграм тема > "Спасибо"
Аватара пользователя
DbIMok
Адепт
 
Сообщения: 6372
Зарегистрирован: 31 июл 2009, 14:05

Re: Знаете ли вы что...

Сообщение Paul Siberdt 03 сен 2010, 23:58

...Тихо сам с собою я веду беседу...
А Пушкин Александр Сергеевич был как-то ближе к народу
Аватара пользователя
Paul Siberdt
Адепт
 
Сообщения: 5317
Зарегистрирован: 20 июн 2009, 21:24
Откуда: Moscow, Russia
Skype: siberdt
  • Сайт

Re: Знаете ли вы что...

Сообщение Zavhoz 01 ноя 2010, 05:36

позвольте поинтересоваться, какими средствами были извлечены эти данные. на данный момент мне интересен класс Vector3 из 3й версии, с его новыми функциями.
заранее спасибо.
FUNNY BLOX
Аватара пользователя
Zavhoz
UNITрон
 
Сообщения: 197
Зарегистрирован: 10 фев 2009, 07:23
Откуда: Караганда KZ
  • ICQ

Re: Знаете ли вы что...

Сообщение Zaicheg 01 ноя 2010, 09:52

Zavhoz писал(а):позвольте поинтересоваться, какими средствами были извлечены эти данные. на данный момент мне интересен класс Vector3 из 3й версии, с его новыми функциями.
заранее спасибо.

http://ru.wikipedia.org/wiki/.NET_Reflector
C:\Program Files\Unity\Editor\Data\Managed\******.dll
Дьяченко Роман
e-mail: _zaicheg.reg@gmail.com
skype: zaicheg12
vkontakte: _vk.com/zaichegq
Работа: _wie3.com _www.sanviz.com
Аватара пользователя
Zaicheg
Адепт
 
Сообщения: 3024
Зарегистрирован: 19 июн 2009, 15:12
Откуда: Череповец

Re: Знаете ли вы что...

Сообщение Zavhoz 01 ноя 2010, 12:50

вот спасибо! подглядел рефлектором, всё замечательно выдернулось.
FUNNY BLOX
Аватара пользователя
Zavhoz
UNITрон
 
Сообщения: 197
Зарегистрирован: 10 фев 2009, 07:23
Откуда: Караганда KZ
  • ICQ

Пред.

Вернуться в Tips & Tricks

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2