Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Please help, error: Unexpected symbol `private'

Discussion in 'Scripting' started by arthurmpaula, Oct 6, 2023 at 1:24 AM.

  1. arthurmpaula

    arthurmpaula

    Joined:
    Sep 17, 2023
    Posts:
    1
    I am getting this error, please help "Assets/Plugins/Assembly-CSharp-firstpass/UILabel.cs(787,47): error CS1525: Unexpected symbol `private'"

    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [ExecuteInEditMode]
    6. [AddComponentMenu("NGUI/UI/NGUI Label")]
    7. public class UILabel : UIWidget
    8. {
    9.     public enum Effect
    10.     {
    11.         None = 0,
    12.         Shadow = 1,
    13.         Outline = 2
    14.     }
    15.  
    16.     public enum Overflow
    17.     {
    18.         ShrinkContent = 0,
    19.         ClampContent = 1,
    20.         ResizeFreely = 2,
    21.         ResizeHeight = 3
    22.     }
    23.  
    24.     public enum Crispness
    25.     {
    26.         Never = 0,
    27.         OnDesktop = 1,
    28.         Always = 2
    29.     }
    30.  
    31.     public Crispness keepCrispWhenShrunk = Crispness.OnDesktop;
    32.  
    33.     [SerializeField]
    34.     [HideInInspector]
    35.     private Font mTrueTypeFont;
    36.  
    37.     [SerializeField]
    38.     [HideInInspector]
    39.     private UIFont mFont;
    40.  
    41.     [SerializeField]
    42.     [Multiline(6)]
    43.     [HideInInspector]
    44.     private string mText = string.Empty;
    45.  
    46.     [SerializeField]
    47.     [HideInInspector]
    48.     private int mFontSize = 16;
    49.  
    50.     [SerializeField]
    51.     [HideInInspector]
    52.     private FontStyle mFontStyle;
    53.  
    54.     [HideInInspector]
    55.     [SerializeField]
    56.     private NGUIText.Alignment mAlignment;
    57.  
    58.     [HideInInspector]
    59.     [SerializeField]
    60.     private bool mEncoding = true;
    61.  
    62.     [HideInInspector]
    63.     [SerializeField]
    64.     private int mMaxLineCount;
    65.  
    66.     [SerializeField]
    67.     [HideInInspector]
    68.     private Effect mEffectStyle;
    69.  
    70.     [HideInInspector]
    71.     [SerializeField]
    72.     private Color mEffectColor = Color.black;
    73.  
    74.     [SerializeField]
    75.     [HideInInspector]
    76.     private NGUIText.SymbolStyle mSymbols = NGUIText.SymbolStyle.Normal;
    77.  
    78.     [HideInInspector]
    79.     [SerializeField]
    80.     private Vector2 mEffectDistance = Vector2.one;
    81.  
    82.     [SerializeField]
    83.     [HideInInspector]
    84.     private Overflow mOverflow;
    85.  
    86.     [HideInInspector]
    87.     [SerializeField]
    88.     private Material mMaterial;
    89.  
    90.     [SerializeField]
    91.     [HideInInspector]
    92.     private bool mApplyGradient;
    93.  
    94.     [SerializeField]
    95.     [HideInInspector]
    96.     private Color mGradientTop = Color.white;
    97.  
    98.     [HideInInspector]
    99.     [SerializeField]
    100.     private Color mGradientBottom = new Color(0.7f, 0.7f, 0.7f);
    101.  
    102.     [SerializeField]
    103.     [HideInInspector]
    104.     private int mSpacingX;
    105.  
    106.     [SerializeField]
    107.     [HideInInspector]
    108.     private int mSpacingY;
    109.  
    110.     [SerializeField]
    111.     [HideInInspector]
    112.     private bool mShrinkToFit;
    113.  
    114.     [HideInInspector]
    115.     [SerializeField]
    116.     private int mMaxLineWidth;
    117.  
    118.     [HideInInspector]
    119.     [SerializeField]
    120.     private int mMaxLineHeight;
    121.  
    122.     [SerializeField]
    123.     [HideInInspector]
    124.     private float mLineWidth;
    125.  
    126.     [SerializeField]
    127.     [HideInInspector]
    128.     private bool mMultiline = true;
    129.  
    130.     [NonSerialized]
    131.     private Font mActiveTTF;
    132.  
    133.     private float mDensity = 1f;
    134.  
    135.     private bool mShouldBeProcessed = true;
    136.  
    137.     private string mProcessedText;
    138.  
    139.     private bool mPremultiply;
    140.  
    141.     private Vector2 mCalculatedSize = Vector2.zero;
    142.  
    143.     private float mScale = 1f;
    144.  
    145.     private int mPrintedSize;
    146.  
    147.     private int mLastWidth;
    148.  
    149.     private int mLastHeight;
    150.  
    151.     private static BetterList<UILabel> mList = new BetterList<UILabel>();
    152.  
    153.     private static Dictionary<Font, int> mFontUsage = new Dictionary<Font, int>();
    154.  
    155.     private static BetterList<Vector3> mTempVerts = new BetterList<Vector3>();
    156.  
    157.     private static BetterList<int> mTempIndices = new BetterList<int>();
    158.  
    159.     private bool shouldBeProcessed
    160.     {
    161.         get
    162.         {
    163.             return mShouldBeProcessed;
    164.         }
    165.         set
    166.         {
    167.             if (value)
    168.             {
    169.                 mChanged = true;
    170.                 mShouldBeProcessed = true;
    171.             }
    172.             else
    173.             {
    174.                 mShouldBeProcessed = false;
    175.             }
    176.         }
    177.     }
    178.  
    179.     public override bool isAnchoredHorizontally
    180.     {
    181.         get
    182.         {
    183.             return base.isAnchoredHorizontally || mOverflow == Overflow.ResizeFreely;
    184.         }
    185.     }
    186.  
    187.     public override bool isAnchoredVertically
    188.     {
    189.         get
    190.         {
    191.             return base.isAnchoredVertically || mOverflow == Overflow.ResizeFreely || mOverflow == Overflow.ResizeHeight;
    192.         }
    193.     }
    194.  
    195.     public override Material material
    196.     {
    197.         get
    198.         {
    199.             if (mMaterial != null)
    200.             {
    201.                 return mMaterial;
    202.             }
    203.             if (mFont != null)
    204.             {
    205.                 return mFont.material;
    206.             }
    207.             if (mTrueTypeFont != null)
    208.             {
    209.                 return mTrueTypeFont.material;
    210.             }
    211.             return null;
    212.         }
    213.         set
    214.         {
    215.             if (mMaterial != value)
    216.             {
    217.                 MarkAsChanged();
    218.                 mMaterial = value;
    219.                 MarkAsChanged();
    220.             }
    221.         }
    222.     }
    223.  
    224.     [Obsolete("Use UILabel.bitmapFont instead")]
    225.     public UIFont font
    226.     {
    227.         get
    228.         {
    229.             return bitmapFont;
    230.         }
    231.         set
    232.         {
    233.             bitmapFont = value;
    234.         }
    235.     }
    236.  
    237.     public UIFont bitmapFont
    238.     {
    239.         get
    240.         {
    241.             return mFont;
    242.         }
    243.         set
    244.         {
    245.             if (mFont != value)
    246.             {
    247.                 RemoveFromPanel();
    248.                 mFont = value;
    249.                 mTrueTypeFont = null;
    250.                 MarkAsChanged();
    251.             }
    252.         }
    253.     }
    254.  
    255.     public Font trueTypeFont
    256.     {
    257.         get
    258.         {
    259.             if (mTrueTypeFont != null)
    260.             {
    261.                 return mTrueTypeFont;
    262.             }
    263.             return (!(mFont != null)) ? null : mFont.dynamicFont;
    264.         }
    265.         set
    266.         {
    267.             if (mTrueTypeFont != value)
    268.             {
    269.                 SetActiveFont(null);
    270.                 RemoveFromPanel();
    271.                 mTrueTypeFont = value;
    272.                 shouldBeProcessed = true;
    273.                 mFont = null;
    274.                 SetActiveFont(value);
    275.                 ProcessAndRequest();
    276.                 if (mActiveTTF != null)
    277.                 {
    278.                     base.MarkAsChanged();
    279.                 }
    280.             }
    281.         }
    282.     }
    283.  
    284.     public UnityEngine.Object ambigiousFont
    285.     {
    286.         get
    287.         {
    288.             return (!(mFont != null)) ? ((UnityEngine.Object)mTrueTypeFont) : ((UnityEngine.Object)mFont);
    289.         }
    290.         set
    291.         {
    292.             UIFont uIFont = value as UIFont;
    293.             if (uIFont != null)
    294.             {
    295.                 bitmapFont = uIFont;
    296.             }
    297.             else
    298.             {
    299.                 trueTypeFont = value as Font;
    300.             }
    301.         }
    302.     }
    303.  
    304.     public string text
    305.     {
    306.         get
    307.         {
    308.             return mText;
    309.         }
    310.         set
    311.         {
    312.             if (mText == value)
    313.             {
    314.                 return;
    315.             }
    316.             if (string.IsNullOrEmpty(value))
    317.             {
    318.                 if (!string.IsNullOrEmpty(mText))
    319.                 {
    320.                     mText = string.Empty;
    321.                     shouldBeProcessed = true;
    322.                     ProcessAndRequest();
    323.                 }
    324.             }
    325.             else if (mText != value)
    326.             {
    327.                 mText = value;
    328.                 shouldBeProcessed = true;
    329.                 ProcessAndRequest();
    330.             }
    331.             if (autoResizeBoxCollider)
    332.             {
    333.                 ResizeCollider();
    334.             }
    335.         }
    336.     }
    337.  
    338.     public int defaultFontSize
    339.     {
    340.         get
    341.         {
    342.             return (trueTypeFont != null) ? mFontSize : ((!(mFont != null)) ? 16 : mFont.defaultSize);
    343.         }
    344.     }
    345.  
    346.     public int fontSize
    347.     {
    348.         get
    349.         {
    350.             return mFontSize;
    351.         }
    352.         set
    353.         {
    354.             value = Mathf.Clamp(value, 0, 256);
    355.             if (mFontSize != value)
    356.             {
    357.                 mFontSize = value;
    358.                 shouldBeProcessed = true;
    359.                 ProcessAndRequest();
    360.             }
    361.         }
    362.     }
    363.  
    364.     public FontStyle fontStyle
    365.     {
    366.         get
    367.         {
    368.             return mFontStyle;
    369.         }
    370.         set
    371.         {
    372.             if (mFontStyle != value)
    373.             {
    374.                 mFontStyle = value;
    375.                 shouldBeProcessed = true;
    376.                 ProcessAndRequest();
    377.             }
    378.         }
    379.     }
    380.  
    381.     public NGUIText.Alignment alignment
    382.     {
    383.         get
    384.         {
    385.             return mAlignment;
    386.         }
    387.         set
    388.         {
    389.             if (mAlignment != value)
    390.             {
    391.                 mAlignment = value;
    392.                 shouldBeProcessed = true;
    393.                 ProcessAndRequest();
    394.             }
    395.         }
    396.     }
    397.  
    398.     public bool applyGradient
    399.     {
    400.         get
    401.         {
    402.             return mApplyGradient;
    403.         }
    404.         set
    405.         {
    406.             if (mApplyGradient != value)
    407.             {
    408.                 mApplyGradient = value;
    409.                 MarkAsChanged();
    410.             }
    411.         }
    412.     }
    413.  
    414.     public Color gradientTop
    415.     {
    416.         get
    417.         {
    418.             return mGradientTop;
    419.         }
    420.         set
    421.         {
    422.             if (mGradientTop != value)
    423.             {
    424.                 mGradientTop = value;
    425.                 if (mApplyGradient)
    426.                 {
    427.                     MarkAsChanged();
    428.                 }
    429.             }
    430.         }
    431.     }
    432.  
    433.     public Color gradientBottom
    434.     {
    435.         get
    436.         {
    437.             return mGradientBottom;
    438.         }
    439.         set
    440.         {
    441.             if (mGradientBottom != value)
    442.             {
    443.                 mGradientBottom = value;
    444.                 if (mApplyGradient)
    445.                 {
    446.                     MarkAsChanged();
    447.                 }
    448.             }
    449.         }
    450.     }
    451.  
    452.     public int spacingX
    453.     {
    454.         get
    455.         {
    456.             return mSpacingX;
    457.         }
    458.         set
    459.         {
    460.             if (mSpacingX != value)
    461.             {
    462.                 mSpacingX = value;
    463.                 MarkAsChanged();
    464.             }
    465.         }
    466.     }
    467.  
    468.     public int spacingY
    469.     {
    470.         get
    471.         {
    472.             return mSpacingY;
    473.         }
    474.         set
    475.         {
    476.             if (mSpacingY != value)
    477.             {
    478.                 mSpacingY = value;
    479.                 MarkAsChanged();
    480.             }
    481.         }
    482.     }
    483.  
    484.     private bool keepCrisp
    485.     {
    486.         get
    487.         {
    488.             if (trueTypeFont != null && keepCrispWhenShrunk != 0)
    489.             {
    490.                 return keepCrispWhenShrunk == Crispness.Always;
    491.             }
    492.             return false;
    493.         }
    494.     }
    495.  
    496.     public bool supportEncoding
    497.     {
    498.         get
    499.         {
    500.             return mEncoding;
    501.         }
    502.         set
    503.         {
    504.             if (mEncoding != value)
    505.             {
    506.                 mEncoding = value;
    507.                 shouldBeProcessed = true;
    508.             }
    509.         }
    510.     }
    511.  
    512.     public NGUIText.SymbolStyle symbolStyle
    513.     {
    514.         get
    515.         {
    516.             return mSymbols;
    517.         }
    518.         set
    519.         {
    520.             if (mSymbols != value)
    521.             {
    522.                 mSymbols = value;
    523.                 shouldBeProcessed = true;
    524.             }
    525.         }
    526.     }
    527.  
    528.     public Overflow overflowMethod
    529.     {
    530.         get
    531.         {
    532.             return mOverflow;
    533.         }
    534.         set
    535.         {
    536.             if (mOverflow != value)
    537.             {
    538.                 mOverflow = value;
    539.                 shouldBeProcessed = true;
    540.             }
    541.         }
    542.     }
    543.  
    544.     [Obsolete("Use 'width' instead")]
    545.     public int lineWidth
    546.     {
    547.         get
    548.         {
    549.             return base.width;
    550.         }
    551.         set
    552.         {
    553.             base.width = value;
    554.         }
    555.     }
    556.  
    557.     [Obsolete("Use 'height' instead")]
    558.     public int lineHeight
    559.     {
    560.         get
    561.         {
    562.             return base.height;
    563.         }
    564.         set
    565.         {
    566.             base.height = value;
    567.         }
    568.     }
    569.  
    570.     public bool multiLine
    571.     {
    572.         get
    573.         {
    574.             return mMaxLineCount != 1;
    575.         }
    576.         set
    577.         {
    578.             if (mMaxLineCount != 1 != value)
    579.             {
    580.                 mMaxLineCount = ((!value) ? 1 : 0);
    581.                 shouldBeProcessed = true;
    582.             }
    583.         }
    584.     }
    585.  
    586.     public override Vector3[] localCorners
    587.     {
    588.         get
    589.         {
    590.             if (shouldBeProcessed)
    591.             {
    592.                 ProcessText();
    593.             }
    594.             return base.localCorners;
    595.         }
    596.     }
    597.  
    598.     public override Vector3[] worldCorners
    599.     {
    600.         get
    601.         {
    602.             if (shouldBeProcessed)
    603.             {
    604.                 ProcessText();
    605.             }
    606.             return base.worldCorners;
    607.         }
    608.     }
    609.  
    610.     public override Vector4 drawingDimensions
    611.     {
    612.         get
    613.         {
    614.             if (shouldBeProcessed)
    615.             {
    616.                 ProcessText();
    617.             }
    618.             return base.drawingDimensions;
    619.         }
    620.     }
    621.  
    622.     public int maxLineCount
    623.     {
    624.         get
    625.         {
    626.             return mMaxLineCount;
    627.         }
    628.         set
    629.         {
    630.             if (mMaxLineCount != value)
    631.             {
    632.                 mMaxLineCount = Mathf.Max(value, 0);
    633.                 shouldBeProcessed = true;
    634.                 if (overflowMethod == Overflow.ShrinkContent)
    635.                 {
    636.                     MakePixelPerfect();
    637.                 }
    638.             }
    639.         }
    640.     }
    641.  
    642.     public Effect effectStyle
    643.     {
    644.         get
    645.         {
    646.             return mEffectStyle;
    647.         }
    648.         set
    649.         {
    650.             if (mEffectStyle != value)
    651.             {
    652.                 mEffectStyle = value;
    653.                 shouldBeProcessed = true;
    654.             }
    655.         }
    656.     }
    657.  
    658.     public Color effectColor
    659.     {
    660.         get
    661.         {
    662.             return mEffectColor;
    663.         }
    664.         set
    665.         {
    666.             if (mEffectColor != value)
    667.             {
    668.                 mEffectColor = value;
    669.                 if (mEffectStyle != 0)
    670.                 {
    671.                     shouldBeProcessed = true;
    672.                 }
    673.             }
    674.         }
    675.     }
    676.  
    677.     public Vector2 effectDistance
    678.     {
    679.         get
    680.         {
    681.             return mEffectDistance;
    682.         }
    683.         set
    684.         {
    685.             if (mEffectDistance != value)
    686.             {
    687.                 mEffectDistance = value;
    688.                 shouldBeProcessed = true;
    689.             }
    690.         }
    691.     }
    692.  
    693.     [Obsolete("Use 'overflowMethod == UILabel.Overflow.ShrinkContent' instead")]
    694.     public bool shrinkToFit
    695.     {
    696.         get
    697.         {
    698.             return mOverflow == Overflow.ShrinkContent;
    699.         }
    700.         set
    701.         {
    702.             if (value)
    703.             {
    704.                 overflowMethod = Overflow.ShrinkContent;
    705.             }
    706.         }
    707.     }
    708.  
    709.     public string processedText
    710.     {
    711.         get
    712.         {
    713.             if (mLastWidth != mWidth || mLastHeight != mHeight)
    714.             {
    715.                 mLastWidth = mWidth;
    716.                 mLastHeight = mHeight;
    717.                 mShouldBeProcessed = true;
    718.             }
    719.             if (shouldBeProcessed)
    720.             {
    721.                 ProcessText();
    722.             }
    723.             return mProcessedText;
    724.         }
    725.     }
    726.  
    727.     public Vector2 printedSize
    728.     {
    729.         get
    730.         {
    731.             if (shouldBeProcessed)
    732.             {
    733.                 ProcessText();
    734.             }
    735.             return mCalculatedSize;
    736.         }
    737.     }
    738.  
    739.     public override Vector2 localSize
    740.     {
    741.         get
    742.         {
    743.             if (shouldBeProcessed)
    744.             {
    745.                 ProcessText();
    746.             }
    747.             return base.localSize;
    748.         }
    749.     }
    750.  
    751.     private bool isValid
    752.     {
    753.         get
    754.         {
    755.             return mFont != null || mTrueTypeFont != null;
    756.         }
    757.     }
    758.  
    759.     protected override void OnInit()
    760.     {
    761.         base.OnInit();
    762.         mList.Add(this);
    763.         SetActiveFont(trueTypeFont);
    764.     }
    765.  
    766.     protected override void OnDisable()
    767.     {
    768.         SetActiveFont(null);
    769.         mList.Remove(this);
    770.         base.OnDisable();
    771.     }
    772.  
    773.     protected void SetActiveFont(Font fnt)
    774.     {
    775.         if (!(mActiveTTF != fnt))
    776.         {
    777.             return;
    778.         }
    779.         if (mActiveTTF != null)
    780.         {
    781.             int value;
    782.             if (mFontUsage.TryGetValue(mActiveTTF, out value))
    783.             {
    784.                 value = Mathf.Max(0, --value);
    785.                 if (value == 0)
    786.                 {
    787.                     private void OnFontTextureChanged(Font changedFont)
    788.                     mFontUsage.Remove(mActiveTTF);
    789.                 }
    790.                 else
    791.                 {
    792.                     mFontUsage[mActiveTTF] = value;
    793.                 }
    794.             }
    795.             else
    796.             {
    797.                 mActiveTTF.textureRebuiltCallback = null;
    798.             }
    799.         }
    800.         mActiveTTF = fnt;
    801.         if (mActiveTTF != null)
    802.         {
    803.             int value2 = 0;
    804.             if (!mFontUsage.TryGetValue(mActiveTTF, out value2))
    805.             {
    806.                 mActiveTTF.textureRebuiltCallback = OnFontTextureChanged;
    807.             }
    808.             value2 = (mFontUsage[mActiveTTF] = value2 + 1);
    809.         }
    810.     }
    811.  
    812.     private static void OnFontTextureChanged()
    813.     {
    814.         for (int i = 0; i < mList.size; i++)
    815.         {
    816.             UILabel uILabel = mList[i];
    817.             if (uILabel != null)
    818.             {
    819.                 Font font = uILabel.trueTypeFont;
    820.                 if (font != null)
    821.                 {
    822.                     font.RequestCharactersInTexture(uILabel.mText, uILabel.mPrintedSize, uILabel.mFontStyle);
    823.                     uILabel.MarkAsChanged();
    824.                 }
    825.             }
    826.         }
    827.     }
    828.  
    829.     public override Vector3[] GetSides(Transform relativeTo)
    830.     {
    831.         if (shouldBeProcessed)
    832.         {
    833.             ProcessText();
    834.         }
    835.         return base.GetSides(relativeTo);
    836.     }
    837.  
    838.     protected override void UpgradeFrom265()
    839.     {
    840.         ProcessText(true, true);
    841.         if (mShrinkToFit)
    842.         {
    843.             overflowMethod = Overflow.ShrinkContent;
    844.             mMaxLineCount = 0;
    845.         }
    846.         if (mMaxLineWidth != 0)
    847.         {
    848.             base.width = mMaxLineWidth;
    849.             overflowMethod = ((mMaxLineCount > 0) ? Overflow.ResizeHeight : Overflow.ShrinkContent);
    850.         }
    851.         else
    852.         {
    853.             overflowMethod = Overflow.ResizeFreely;
    854.         }
    855.         if (mMaxLineHeight != 0)
    856.         {
    857.             base.height = mMaxLineHeight;
    858.         }
    859.         if (mFont != null)
    860.         {
    861.             int defaultSize = mFont.defaultSize;
    862.             if (base.height < defaultSize)
    863.             {
    864.                 base.height = defaultSize;
    865.             }
    866.         }
    867.         mMaxLineWidth = 0;
    868.         mMaxLineHeight = 0;
    869.         mShrinkToFit = false;
    870.         if (GetComponent<BoxCollider>() != null)
    871.         {
    872.             NGUITools.AddWidgetCollider(base.gameObject, true);
    873.         }
    874.     }
    875.  
    876.     protected override void OnAnchor()
    877.     {
    878.         if (mOverflow == Overflow.ResizeFreely)
    879.         {
    880.             if (base.isFullyAnchored)
    881.             {
    882.                 mOverflow = Overflow.ShrinkContent;
    883.             }
    884.         }
    885.         else if (mOverflow == Overflow.ResizeHeight && topAnchor.target != null && bottomAnchor.target != null)
    886.         {
    887.             mOverflow = Overflow.ShrinkContent;
    888.         }
    889.         base.OnAnchor();
    890.     }
    891.  
    892.     private void ProcessAndRequest()
    893.     {
    894.         if (ambigiousFont != null)
    895.         {
    896.             ProcessText();
    897.         }
    898.     }
    899.  
    900.     protected override void OnStart()
    901.     {
    902.         base.OnStart();
    903.         if (mLineWidth > 0f)
    904.         {
    905.             mMaxLineWidth = Mathf.RoundToInt(mLineWidth);
    906.             mLineWidth = 0f;
    907.         }
    908.         if (!mMultiline)
    909.         {
    910.             mMaxLineCount = 1;
    911.             mMultiline = true;
    912.         }
    913.         mPremultiply = material != null && material.shader != null && material.shader.name.Contains("Premultiplied");
    914.         ProcessAndRequest();
    915.     }
    916.  
    917.     public override void MarkAsChanged()
    918.     {
    919.         shouldBeProcessed = true;
    920.         base.MarkAsChanged();
    921.     }
    922.  
    923.     private void ProcessText()
    924.     {
    925.         ProcessText(false, true);
    926.     }
    927.  
    928.     private void ProcessText(bool legacyMode, bool full)
    929.     {
    930.         if (!isValid)
    931.         {
    932.             return;
    933.         }
    934.         mChanged = true;
    935.         shouldBeProcessed = false;
    936.         NGUIText.rectWidth = ((!legacyMode) ? base.width : ((mMaxLineWidth == 0) ? 1000000 : mMaxLineWidth));
    937.         NGUIText.rectHeight = ((!legacyMode) ? base.height : ((mMaxLineHeight == 0) ? 1000000 : mMaxLineHeight));
    938.         mPrintedSize = Mathf.Abs((!legacyMode) ? defaultFontSize : Mathf.RoundToInt(base.cachedTransform.localScale.x));
    939.         mScale = 1f;
    940.         if (NGUIText.rectWidth < 1 || NGUIText.rectHeight < 0)
    941.         {
    942.             mProcessedText = string.Empty;
    943.             return;
    944.         }
    945.         bool flag = trueTypeFont != null;
    946.         if (flag && keepCrisp)
    947.         {
    948.             UIRoot uIRoot = base.root;
    949.             if (uIRoot != null)
    950.             {
    951.                 mDensity = ((!(uIRoot != null)) ? 1f : uIRoot.pixelSizeAdjustment);
    952.             }
    953.         }
    954.         else
    955.         {
    956.             mDensity = 1f;
    957.         }
    958.         if (full)
    959.         {
    960.             UpdateNGUIText();
    961.         }
    962.         if (mOverflow == Overflow.ResizeFreely)
    963.         {
    964.             NGUIText.rectWidth = 1000000;
    965.         }
    966.         if (mOverflow == Overflow.ResizeFreely || mOverflow == Overflow.ResizeHeight)
    967.         {
    968.             NGUIText.rectHeight = 1000000;
    969.         }
    970.         if (mPrintedSize > 0)
    971.         {
    972.             bool flag2 = keepCrisp;
    973.             int num = mPrintedSize;
    974.             while (num > 0)
    975.             {
    976.                 if (flag2)
    977.                 {
    978.                     mPrintedSize = num;
    979.                     NGUIText.fontSize = mPrintedSize;
    980.                 }
    981.                 else
    982.                 {
    983.                     mScale = (float)num / (float)mPrintedSize;
    984.                     NGUIText.fontScale = ((!flag) ? ((float)mFontSize / (float)mFont.defaultSize * mScale) : mScale);
    985.                 }
    986.                 NGUIText.Update(false);
    987.                 bool flag3 = NGUIText.WrapText(mText, out mProcessedText, true);
    988.                 if (mOverflow == Overflow.ShrinkContent && !flag3)
    989.                 {
    990.                     if (--num <= 1)
    991.                     {
    992.                         break;
    993.                     }
    994.                     num--;
    995.                     continue;
    996.                 }
    997.                 if (mOverflow == Overflow.ResizeFreely)
    998.                 {
    999.                     mCalculatedSize = NGUIText.CalculatePrintedSize(mProcessedText);
    1000.                     mWidth = Mathf.Max(minWidth, Mathf.RoundToInt(mCalculatedSize.x));
    1001.                     mHeight = Mathf.Max(minHeight, Mathf.RoundToInt(mCalculatedSize.y));
    1002.                     if ((mWidth & 1) == 1)
    1003.                     {
    1004.                         mWidth++;
    1005.                     }
    1006.                     if ((mHeight & 1) == 1)
    1007.                     {
    1008.                         mHeight++;
    1009.                     }
    1010.                 }
    1011.                 else if (mOverflow == Overflow.ResizeHeight)
    1012.                 {
    1013.                     mCalculatedSize = NGUIText.CalculatePrintedSize(mProcessedText);
    1014.                     mHeight = Mathf.Max(minHeight, Mathf.RoundToInt(mCalculatedSize.y));
    1015.                     if ((mHeight & 1) == 1)
    1016.                     {
    1017.                         mHeight++;
    1018.                     }
    1019.                 }
    1020.                 else
    1021.                 {
    1022.                     mCalculatedSize = NGUIText.CalculatePrintedSize(mProcessedText);
    1023.                 }
    1024.                 if (legacyMode)
    1025.                 {
    1026.                     base.width = Mathf.RoundToInt(mCalculatedSize.x);
    1027.                     base.height = Mathf.RoundToInt(mCalculatedSize.y);
    1028.                     base.cachedTransform.localScale = Vector3.one;
    1029.                 }
    1030.                 break;
    1031.             }
    1032.         }
    1033.         else
    1034.         {
    1035.             base.cachedTransform.localScale = Vector3.one;
    1036.             mProcessedText = string.Empty;
    1037.             mScale = 1f;
    1038.         }
    1039.     }
    1040.  
    1041.     public override void MakePixelPerfect()
    1042.     {
    1043.         if (ambigiousFont != null)
    1044.         {
    1045.             Vector3 localPosition = base.cachedTransform.localPosition;
    1046.             localPosition.x = Mathf.RoundToInt(localPosition.x);
    1047.             localPosition.y = Mathf.RoundToInt(localPosition.y);
    1048.             localPosition.z = Mathf.RoundToInt(localPosition.z);
    1049.             base.cachedTransform.localPosition = localPosition;
    1050.             base.cachedTransform.localScale = Vector3.one;
    1051.             if (mOverflow == Overflow.ResizeFreely)
    1052.             {
    1053.                 AssumeNaturalSize();
    1054.                 return;
    1055.             }
    1056.             int a = base.width;
    1057.             int a2 = base.height;
    1058.             Overflow overflow = mOverflow;
    1059.             if (overflow != Overflow.ResizeHeight)
    1060.             {
    1061.                 mWidth = 100000;
    1062.             }
    1063.             mHeight = 100000;
    1064.             mOverflow = Overflow.ShrinkContent;
    1065.             ProcessText(false, true);
    1066.             mOverflow = overflow;
    1067.             int a3 = Mathf.RoundToInt(mCalculatedSize.x);
    1068.             int a4 = Mathf.RoundToInt(mCalculatedSize.y);
    1069.             a3 = Mathf.Max(a3, base.minWidth);
    1070.             a4 = Mathf.Max(a4, base.minHeight);
    1071.             mWidth = Mathf.Max(a, a3);
    1072.             mHeight = Mathf.Max(a2, a4);
    1073.             MarkAsChanged();
    1074.         }
    1075.         else
    1076.         {
    1077.             base.MakePixelPerfect();
    1078.         }
    1079.     }
    1080.  
    1081.     public void AssumeNaturalSize()
    1082.     {
    1083.         if (ambigiousFont != null)
    1084.         {
    1085.             mWidth = 100000;
    1086.             mHeight = 100000;
    1087.             ProcessText(false, true);
    1088.             mWidth = Mathf.RoundToInt(mCalculatedSize.x);
    1089.             mHeight = Mathf.RoundToInt(mCalculatedSize.y);
    1090.             if ((mWidth & 1) == 1)
    1091.             {
    1092.                 mWidth++;
    1093.             }
    1094.             if ((mHeight & 1) == 1)
    1095.             {
    1096.                 mHeight++;
    1097.             }
    1098.             MarkAsChanged();
    1099.         }
    1100.     }
    1101.  
    1102.     [Obsolete("Use UILabel.GetCharacterAtPosition instead")]
    1103.     public int GetCharacterIndex(Vector3 worldPos)
    1104.     {
    1105.         return GetCharacterIndexAtPosition(worldPos);
    1106.     }
    1107.  
    1108.     [Obsolete("Use UILabel.GetCharacterAtPosition instead")]
    1109.     public int GetCharacterIndex(Vector2 localPos)
    1110.     {
    1111.         return GetCharacterIndexAtPosition(localPos);
    1112.     }
    1113.  
    1114.     public int GetCharacterIndexAtPosition(Vector3 worldPos)
    1115.     {
    1116.         Vector2 localPos = base.cachedTransform.InverseTransformPoint(worldPos);
    1117.         return GetCharacterIndexAtPosition(localPos);
    1118.     }
    1119.  
    1120.     public int GetCharacterIndexAtPosition(Vector2 localPos)
    1121.     {
    1122.         if (isValid)
    1123.         {
    1124.             string value = processedText;
    1125.             if (string.IsNullOrEmpty(value))
    1126.             {
    1127.                 return 0;
    1128.             }
    1129.             UpdateNGUIText();
    1130.             NGUIText.PrintCharacterPositions(value, mTempVerts, mTempIndices);
    1131.             if (mTempVerts.size > 0)
    1132.             {
    1133.                 ApplyOffset(mTempVerts, 0);
    1134.                 int closestCharacter = NGUIText.GetClosestCharacter(mTempVerts, localPos);
    1135.                 closestCharacter = mTempIndices[closestCharacter];
    1136.                 mTempVerts.Clear();
    1137.                 mTempIndices.Clear();
    1138.                 return closestCharacter;
    1139.             }
    1140.         }
    1141.         return 0;
    1142.     }
    1143.  
    1144.     public string GetWordAtPosition(Vector3 worldPos)
    1145.     {
    1146.         return GetWordAtCharacterIndex(GetCharacterIndexAtPosition(worldPos));
    1147.     }
    1148.  
    1149.     public string GetWordAtPosition(Vector2 localPos)
    1150.     {
    1151.         return GetWordAtCharacterIndex(GetCharacterIndexAtPosition(localPos));
    1152.     }
    1153.  
    1154.     public string GetWordAtCharacterIndex(int characterIndex)
    1155.     {
    1156.         if (characterIndex != -1 && characterIndex < mText.Length)
    1157.         {
    1158.             int num = mText.LastIndexOf(' ', characterIndex) + 1;
    1159.             int num2 = mText.IndexOf(' ', characterIndex);
    1160.             if (num2 == -1)
    1161.             {
    1162.                 num2 = mText.Length;
    1163.             }
    1164.             if (num != num2)
    1165.             {
    1166.                 int num3 = num2 - num;
    1167.                 if (num3 > 0)
    1168.                 {
    1169.                     string text = mText.Substring(num, num3);
    1170.                     return NGUIText.StripSymbols(text);
    1171.                 }
    1172.             }
    1173.         }
    1174.         return null;
    1175.     }
    1176.  
    1177.     public string GetUrlAtPosition(Vector3 worldPos)
    1178.     {
    1179.         return GetUrlAtCharacterIndex(GetCharacterIndexAtPosition(worldPos));
    1180.     }
    1181.  
    1182.     public string GetUrlAtPosition(Vector2 localPos)
    1183.     {
    1184.         return GetUrlAtCharacterIndex(GetCharacterIndexAtPosition(localPos));
    1185.     }
    1186.  
    1187.     public string GetUrlAtCharacterIndex(int characterIndex)
    1188.     {
    1189.         if (characterIndex != -1 && characterIndex < mText.Length)
    1190.         {
    1191.             int num = mText.LastIndexOf("[url=", characterIndex);
    1192.             if (num != -1)
    1193.             {
    1194.                 num += 5;
    1195.                 int num2 = mText.IndexOf("]", num);
    1196.                 if (num2 != -1)
    1197.                 {
    1198.                     int num3 = mText.IndexOf("[/url]", num2);
    1199.                     if (num3 == -1 || num3 >= characterIndex)
    1200.                     {
    1201.                         return mText.Substring(num, num2 - num);
    1202.                     }
    1203.                 }
    1204.             }
    1205.         }
    1206.         return null;
    1207.     }
    1208.  
    1209.     public int GetCharacterIndex(int currentIndex, KeyCode key)
    1210.     {
    1211.         if (isValid)
    1212.         {
    1213.             string text = processedText;
    1214.             if (string.IsNullOrEmpty(text))
    1215.             {
    1216.                 return 0;
    1217.             }
    1218.             int num = defaultFontSize;
    1219.             UpdateNGUIText();
    1220.             NGUIText.PrintCharacterPositions(text, mTempVerts, mTempIndices);
    1221.             if (mTempVerts.size > 0)
    1222.             {
    1223.                 ApplyOffset(mTempVerts, 0);
    1224.                 for (int i = 0; i < mTempIndices.size; i++)
    1225.                 {
    1226.                     if (mTempIndices[i] == currentIndex)
    1227.                     {
    1228.                         Vector2 pos = mTempVerts[i];
    1229.                         switch (key)
    1230.                         {
    1231.                         case KeyCode.UpArrow:
    1232.                             pos.y += num + spacingY;
    1233.                             break;
    1234.                         case KeyCode.DownArrow:
    1235.                             pos.y -= num + spacingY;
    1236.                             break;
    1237.                         case KeyCode.Home:
    1238.                             pos.x -= 1000f;
    1239.                             break;
    1240.                         case KeyCode.End:
    1241.                             pos.x += 1000f;
    1242.                             break;
    1243.                         }
    1244.                         int closestCharacter = NGUIText.GetClosestCharacter(mTempVerts, pos);
    1245.                         closestCharacter = mTempIndices[closestCharacter];
    1246.                         if (closestCharacter == currentIndex)
    1247.                         {
    1248.                             break;
    1249.                         }
    1250.                         mTempVerts.Clear();
    1251.                         mTempIndices.Clear();
    1252.                         return closestCharacter;
    1253.                     }
    1254.                 }
    1255.                 mTempVerts.Clear();
    1256.                 mTempIndices.Clear();
    1257.             }
    1258.             switch (key)
    1259.             {
    1260.             case KeyCode.UpArrow:
    1261.             case KeyCode.Home:
    1262.                 return 0;
    1263.             case KeyCode.DownArrow:
    1264.             case KeyCode.End:
    1265.                 return text.Length;
    1266.             }
    1267.         }
    1268.         return currentIndex;
    1269.     }
    1270.  
    1271.     public void PrintOverlay(int start, int end, UIGeometry caret, UIGeometry highlight, Color caretColor, Color highlightColor)
    1272.     {
    1273.         if (caret != null)
    1274.         {
    1275.             caret.Clear();
    1276.         }
    1277.         if (highlight != null)
    1278.         {
    1279.             highlight.Clear();
    1280.         }
    1281.         if (!isValid)
    1282.         {
    1283.             return;
    1284.         }
    1285.         string text = processedText;
    1286.         UpdateNGUIText();
    1287.         int size = caret.verts.size;
    1288.         Vector2 item = new Vector2(0.5f, 0.5f);
    1289.         float num = finalAlpha;
    1290.         if (highlight != null && start != end)
    1291.         {
    1292.             int size2 = highlight.verts.size;
    1293.             NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, highlight.verts);
    1294.             if (highlight.verts.size > size2)
    1295.             {
    1296.                 ApplyOffset(highlight.verts, size2);
    1297.                 Color32 item2 = new Color(highlightColor.r, highlightColor.g, highlightColor.b, highlightColor.a * num);
    1298.                 for (int i = size2; i < highlight.verts.size; i++)
    1299.                 {
    1300.                     highlight.uvs.Add(item);
    1301.                     highlight.cols.Add(item2);
    1302.                 }
    1303.             }
    1304.         }
    1305.         else
    1306.         {
    1307.             NGUIText.PrintCaretAndSelection(text, start, end, caret.verts, null);
    1308.         }
    1309.         ApplyOffset(caret.verts, size);
    1310.         Color32 item3 = new Color(caretColor.r, caretColor.g, caretColor.b, caretColor.a * num);
    1311.         for (int j = size; j < caret.verts.size; j++)
    1312.         {
    1313.             caret.uvs.Add(item);
    1314.             caret.cols.Add(item3);
    1315.         }
    1316.     }
    1317.  
    1318.     public override void OnFill(BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols)
    1319.     {
    1320.         if (!isValid)
    1321.         {
    1322.             return;
    1323.         }
    1324.         int size = verts.size;
    1325.         Color color = base.color;
    1326.         color.a = finalAlpha;
    1327.         if (mFont != null && mFont.premultipliedAlphaShader)
    1328.         {
    1329.             color = NGUITools.ApplyPMA(color);
    1330.         }
    1331.         string text = processedText;
    1332.         int size2 = verts.size;
    1333.         UpdateNGUIText();
    1334.         NGUIText.tint = color;
    1335.         NGUIText.Print(text, verts, uvs, cols);
    1336.         Vector2 vector = ApplyOffset(verts, size2);
    1337.         if ((!(mFont != null) || !mFont.packedFontShader) && effectStyle != 0)
    1338.         {
    1339.             int size3 = verts.size;
    1340.             vector.x = mEffectDistance.x;
    1341.             vector.y = mEffectDistance.y;
    1342.             ApplyShadow(verts, uvs, cols, size, size3, vector.x, 0f - vector.y);
    1343.             if (effectStyle == Effect.Outline)
    1344.             {
    1345.                 size = size3;
    1346.                 size3 = verts.size;
    1347.                 ApplyShadow(verts, uvs, cols, size, size3, 0f - vector.x, vector.y);
    1348.                 size = size3;
    1349.                 size3 = verts.size;
    1350.                 ApplyShadow(verts, uvs, cols, size, size3, vector.x, vector.y);
    1351.                 size = size3;
    1352.                 size3 = verts.size;
    1353.                 ApplyShadow(verts, uvs, cols, size, size3, 0f - vector.x, 0f - vector.y);
    1354.             }
    1355.         }
    1356.     }
    1357.  
    1358.     protected Vector2 ApplyOffset(BetterList<Vector3> verts, int start)
    1359.     {
    1360.         Vector2 vector = base.pivotOffset;
    1361.         float f = Mathf.Lerp(0f, -mWidth, vector.x);
    1362.         float f2 = Mathf.Lerp(mHeight, 0f, vector.y) + Mathf.Lerp(mCalculatedSize.y - (float)mHeight, 0f, vector.y);
    1363.         f = Mathf.Round(f);
    1364.         f2 = Mathf.Round(f2);
    1365.         for (int i = start; i < verts.size; i++)
    1366.         {
    1367.             verts.buffer[i].x += f;
    1368.             verts.buffer[i].y += f2;
    1369.         }
    1370.         return new Vector2(f, f2);
    1371.     }
    1372.  
    1373.     private void ApplyShadow(BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols, int start, int end, float x, float y)
    1374.     {
    1375.         Color color = mEffectColor;
    1376.         color.a *= finalAlpha;
    1377.         Color32 color2 = ((!(bitmapFont != null) || !bitmapFont.premultipliedAlphaShader) ? color : NGUITools.ApplyPMA(color));
    1378.         for (int i = start; i < end; i++)
    1379.         {
    1380.             verts.Add(verts.buffer[i]);
    1381.             uvs.Add(uvs.buffer[i]);
    1382.             cols.Add(cols.buffer[i]);
    1383.             Vector3 vector = verts.buffer[i];
    1384.             vector.x += x;
    1385.             vector.y += y;
    1386.             verts.buffer[i] = vector;
    1387.             cols.buffer[i] = color2;
    1388.         }
    1389.     }
    1390.  
    1391.     public int CalculateOffsetToFit(string text)
    1392.     {
    1393.         UpdateNGUIText();
    1394.         NGUIText.encoding = false;
    1395.         NGUIText.symbolStyle = NGUIText.SymbolStyle.None;
    1396.         return NGUIText.CalculateOffsetToFit(text);
    1397.     }
    1398.  
    1399.     public void SetCurrentProgress()
    1400.     {
    1401.         if (UIProgressBar.current != null)
    1402.         {
    1403.             text = UIProgressBar.current.value.ToString("F");
    1404.         }
    1405.     }
    1406.  
    1407.     public void SetCurrentPercent()
    1408.     {
    1409.         if (UIProgressBar.current != null)
    1410.         {
    1411.             text = Mathf.RoundToInt(UIProgressBar.current.value * 100f) + "%";
    1412.         }
    1413.     }
    1414.  
    1415.     public void SetCurrentSelection()
    1416.     {
    1417.         if (UIPopupList.current != null)
    1418.         {
    1419.             text = ((!UIPopupList.current.isLocalized) ? UIPopupList.current.value : Localization.Get(UIPopupList.current.value));
    1420.         }
    1421.     }
    1422.  
    1423.     public bool Wrap(string text, out string final)
    1424.     {
    1425.         return Wrap(text, out final, 1000000);
    1426.     }
    1427.  
    1428.     public bool Wrap(string text, out string final, int height)
    1429.     {
    1430.         UpdateNGUIText();
    1431.         return NGUIText.WrapText(text, out final);
    1432.     }
    1433.  
    1434.     public void UpdateNGUIText()
    1435.     {
    1436.         Font font = trueTypeFont;
    1437.         bool flag = font != null;
    1438.         NGUIText.fontSize = mPrintedSize;
    1439.         NGUIText.fontStyle = mFontStyle;
    1440.         NGUIText.rectWidth = mWidth;
    1441.         NGUIText.rectHeight = mHeight;
    1442.         NGUIText.gradient = mApplyGradient && (mFont == null || !mFont.packedFontShader);
    1443.         NGUIText.gradientTop = mGradientTop;
    1444.         NGUIText.gradientBottom = mGradientBottom;
    1445.         NGUIText.encoding = mEncoding;
    1446.         NGUIText.premultiply = mPremultiply;
    1447.         NGUIText.symbolStyle = mSymbols;
    1448.         NGUIText.maxLines = mMaxLineCount;
    1449.         NGUIText.spacingX = mSpacingX;
    1450.         NGUIText.spacingY = mSpacingY;
    1451.         NGUIText.fontScale = ((!flag) ? ((float)mFontSize / (float)mFont.defaultSize * mScale) : mScale);
    1452.         if (mFont != null)
    1453.         {
    1454.             NGUIText.bitmapFont = mFont;
    1455.             while (true)
    1456.             {
    1457.                 UIFont replacement = NGUIText.bitmapFont.replacement;
    1458.                 if (replacement == null)
    1459.                 {
    1460.                     break;
    1461.                 }
    1462.                 NGUIText.bitmapFont = replacement;
    1463.             }
    1464.             if (NGUIText.bitmapFont.isDynamic)
    1465.             {
    1466.                 NGUIText.dynamicFont = NGUIText.bitmapFont.dynamicFont;
    1467.                 NGUIText.bitmapFont = null;
    1468.             }
    1469.             else
    1470.             {
    1471.                 NGUIText.dynamicFont = null;
    1472.             }
    1473.         }
    1474.         else
    1475.         {
    1476.             NGUIText.dynamicFont = font;
    1477.             NGUIText.bitmapFont = null;
    1478.         }
    1479.         if (flag && keepCrisp)
    1480.         {
    1481.             UIRoot uIRoot = base.root;
    1482.             if (uIRoot != null)
    1483.             {
    1484.                 NGUIText.pixelDensity = ((!(uIRoot != null)) ? 1f : uIRoot.pixelSizeAdjustment);
    1485.             }
    1486.         }
    1487.         else
    1488.         {
    1489.             NGUIText.pixelDensity = 1f;
    1490.         }
    1491.         if (mDensity != NGUIText.pixelDensity)
    1492.         {
    1493.             ProcessText(false, false);
    1494.             NGUIText.rectWidth = mWidth;
    1495.             NGUIText.rectHeight = mHeight;
    1496.         }
    1497.         if (alignment == NGUIText.Alignment.Automatic)
    1498.         {
    1499.             switch (base.pivot)
    1500.             {
    1501.             case Pivot.TopLeft:
    1502.             case Pivot.Left:
    1503.             case Pivot.BottomLeft:
    1504.                 NGUIText.alignment = NGUIText.Alignment.Left;
    1505.                 break;
    1506.             case Pivot.TopRight:
    1507.             case Pivot.Right:
    1508.             case Pivot.BottomRight:
    1509.                 NGUIText.alignment = NGUIText.Alignment.Right;
    1510.                 break;
    1511.             default:
    1512.                 NGUIText.alignment = NGUIText.Alignment.Center;
    1513.                 break;
    1514.             }
    1515.         }
    1516.         else
    1517.         {
    1518.             NGUIText.alignment = alignment;
    1519.         }
    1520.         NGUIText.Update();
    1521.     }
    1522. }
    1523.  
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,283
    You can fix your own typing mistakes. Here's how:

    Remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

    The complete error message contains everything you need to know to fix the error yourself.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    Look in the documentation. Every API you attempt to use is probably documented somewhere. Are you using it correctly? Are you spelling it correctly? Are you structuring the syntax correctly? Look for examples!

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.



    Tutorials and example code are great, but keep this in mind to maximize your success and minimize your frustration:

    How to do tutorials properly, two (2) simple steps to success:

    Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That's how software engineering works. Every step must be taken, every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly, literally NOTHING can be omitted or skipped.

    Fortunately this is the easiest part to get right: Be a robot. Don't make any mistakes.
    BE PERFECT IN EVERYTHING YOU DO HERE!!


    If you get any errors, learn how to read the error code and fix your error. Google is your friend here. Do NOT continue until you fix your error. Your error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

    Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

    Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost. If you want to learn, you MUST do Step 2.

    Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there's an error, you will NEVER be the first guy to find it.

    Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!

    Finally, when you have errors, don't post here... just go fix your errors! See the top of this post.
     
    Bunny83 and arthurmpaula like this.
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,264
    So that error is indicating that you have an error on line 787, column 47. In this case you have some sort of private declaration on line 787. I can't tell you how to fix it because the code on that line just makes no sense. I have no idea what you meant to put in there.
     
    arthurmpaula and Bunny83 like this.
  4. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,402
    You cannot put a method like that inside an if statement. The fix is easy: if you want to invoke a method inside an if statement, just put it's neme followed by ();
    You should follow the basic coding tutorials in Unity Learn too; your script is far too long to be manageable. :)
     
    Last edited: Oct 6, 2023 at 6:07 AM
    arthurmpaula likes this.