private void LoadContents() { MonoBehaviour parser = Editor.Parser; LoadAdditionalMembers(-1, 0); if (parser.m_GameObject.instance != null) { editTextBoxMonoBehaviourGameObject.Text = parser.m_GameObject.instance.m_Name; } else { editTextBoxMonoBehaviourGameObject.Enabled = false; } editTextBoxMonoBehaviourName.Text = parser.m_Name; MonoScript monoS = AssetCabinet.LoadMonoScript(parser); if (monoS != null) { editTextBoxMonoScriptName.Text = monoS.m_Name; editTextBoxMonoScriptExecutionOrder.Text = monoS.m_ExecutionOrder.ToString(); checkBoxMonoScriptIsEditorScript.Checked = monoS.m_IsEditorScript; if (monoS.m_PropertiesHash is uint) { editTextBoxMonoScriptPropertiesHash.Text = ((uint)monoS.m_PropertiesHash).ToString("X"); } else { StringBuilder sb = new StringBuilder(33); for (int i = 0; i < 16; i++) { sb.Append(((Hash128)monoS.m_PropertiesHash).bytes[i].ToString("X2")); } editTextBoxMonoScriptPropertiesHash.Text = sb.ToString(); } editTextBoxMonoScriptClassName.Text = monoS.m_ClassName; editTextBoxMonoScriptNamespace.Text = monoS.m_Namespace; editTextBoxMonoScriptAssembly.Text = monoS.m_AssemblyName; } }
public void SetMonoScriptAttributes(string name, int executionOrder, bool isEditorScript, string propertiesHash, string className, string nameSpace, string assembly) { MonoScript monoS = AssetCabinet.LoadMonoScript(Parser); bool localChanged = false; if (monoS.m_Name != name) { monoS.m_Name = name; if (monoS.file.Bundle != null) { monoS.file.Bundle.RenameLeadingComponent(monoS); } localChanged = true; } if (monoS.m_ExecutionOrder != executionOrder) { monoS.m_ExecutionOrder = executionOrder; localChanged = true; } if (monoS.m_IsEditorScript != isEditorScript) { monoS.m_IsEditorScript = isEditorScript; localChanged = true; } if (monoS.file.VersionNumber >= AssetCabinet.VERSION_5_0_0) { using (BinaryWriter writer = new BinaryWriter(new MemoryStream(16))) { for (int i = 0; i < 16; i++) { writer.Write(byte.Parse(propertiesHash.Substring(i << 1, 2), System.Globalization.NumberStyles.AllowHexSpecifier)); } writer.BaseStream.Position = 0; Hash128 hashArg = new Hash128(writer.BaseStream); if (!((Hash128)monoS.m_PropertiesHash).Equals(hashArg)) { monoS.m_PropertiesHash = hashArg; localChanged = true; } } } else { uint hashArg = uint.Parse(propertiesHash, System.Globalization.NumberStyles.AllowHexSpecifier); if ((uint)monoS.m_PropertiesHash != hashArg) { monoS.m_PropertiesHash = hashArg; localChanged = true; } } if (monoS.m_ClassName != className) { monoS.m_ClassName = className; localChanged = true; } if (monoS.m_Namespace != nameSpace) { monoS.m_Namespace = nameSpace; localChanged = true; } if (monoS.m_AssemblyName != assembly) { monoS.m_AssemblyName = assembly; localChanged = true; } if (localChanged) { UnityParser parser = null; if (Parser.file != monoS.file) { parser = Parser.file.Parser; Parser.file.Parser = monoS.file.Parser; } Changed = true; if (Parser.file != monoS.file) { Parser.file.Parser = parser; } } }