Exemple #1
0
        public static void SetUpCollectionNavigation(
            string collectionLabel,
            SceneExplorerState state,
            ReferenceChain refChain,
            ReferenceChain oldRefChain,
            int collectionSize,
            out uint arrayStart,
            out uint arrayEnd)
        {
            GUILayout.BeginHorizontal();
            SceneExplorerCommon.InsertIndent(refChain.Indentation);

            GUILayout.Label($"{collectionLabel} size: {collectionSize}");

            if (!state.SelectedArrayStartIndices.TryGetValue(refChain.UniqueId, out arrayStart))
            {
                state.SelectedArrayStartIndices.Add(refChain.UniqueId, 0);
            }

            if (!state.SelectedArrayEndIndices.TryGetValue(refChain.UniqueId, out arrayEnd))
            {
                state.SelectedArrayEndIndices.Add(refChain.UniqueId, 32);
                arrayEnd = 32;
            }

            arrayStart = GUIControls.NumericValueField($"{oldRefChain}.arrayStart", "Start index", arrayStart);
            arrayEnd   = GUIControls.NumericValueField($"{oldRefChain}.arrayEnd", "End index", arrayEnd);
            GUILayout.Label("(32 items max)");
            var pageSize = (uint)Mathf.Clamp(arrayEnd - arrayStart + 1, 1, Mathf.Min(32, collectionSize - arrayStart, arrayEnd + 1));

            if (GUILayout.Button("◄", GUILayout.ExpandWidth(false)))
            {
                arrayStart -= pageSize;
                arrayEnd   -= pageSize;
            }

            if (GUILayout.Button("►", GUILayout.ExpandWidth(false)))
            {
                arrayStart += pageSize;
                arrayEnd   += pageSize;
            }

            arrayStart = (uint)Mathf.Clamp(arrayStart, 0, collectionSize - pageSize);
            arrayEnd   = (uint)Mathf.Max(0, Mathf.Clamp(arrayEnd, pageSize - 1, collectionSize - 1));
            if (arrayStart > arrayEnd)
            {
                arrayEnd = arrayStart;
            }

            if (arrayEnd - arrayStart > 32)
            {
                arrayEnd = arrayStart + 32;
                arrayEnd = (uint)Mathf.Max(0, Mathf.Clamp(arrayEnd, 32, collectionSize - 1));
            }

            state.SelectedArrayStartIndices[refChain.UniqueId] = arrayStart;
            state.SelectedArrayEndIndices[refChain.UniqueId]   = arrayEnd;
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
Exemple #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            FieldTypes   type   = (FieldTypes)Enum.GetValues(typeof(FieldTypes)).GetValue(cmbFieldType.SelectedIndex);
            FieldFormats format = (FieldFormats)Enum.GetValues(typeof(FieldFormats)).GetValue(cmbFieldFormat.SelectedIndex);
            GUIControls  gui    = (GUIControls)Enum.GetValues(typeof(GUIControls)).GetValue(cmbGuiControl.SelectedIndex);

            newColumn = new DMSNewColumn(txtFieldName.Text, int.Parse(txtVersionNumber.Text), int.Parse(txtFieldLength.Text), int.Parse(txtDecPos.Text), (UseEditFlags)int.Parse(txtUseEdit.Text), type, format, gui);

            defaultValue = txtDefaultValue.Text;

            this.Hide();
        }
Exemple #3
0
    public void OnGUI()
    {
        GUI.skin = gskin;

        GUILayout.BeginArea(new Rect(5, 5, 100 + baseTex.width * zoom, baseTex.height * zoom), "", "Box");
        GUILayout.BeginArea(new Rect(0, 0, 100, baseTex.height * zoom));
        tool2 = GUILayout.Toolbar(tool2, toolimgs, "Tool");
        tool  = (Tool)tool2;// System.Enum.Parse(Tool, tool2.ToString());
        GUILayout.Label("Drawing Options");
        GUILayout.Space(10);
        switch (tool)
        {
        case Tool.Line:
            GUILayout.Label("Size " + Mathf.Round(lineTool.width * 10) / 10);
            lineTool.width = GUILayout.HorizontalSlider(lineTool.width, 0, 40);
            col            = GUIControls.RGBCircle(col, "", colorCircle);
            break;

        case Tool.Brush:
            GUILayout.Label("Size " + Mathf.Round(brush.width * 10) / 10);
            brush.width = GUILayout.HorizontalSlider(brush.width, 0, 40);
            GUILayout.Label("Hardness " + Mathf.Round(brush.hardness * 10) / 10);
            brush.hardness = GUILayout.HorizontalSlider(brush.hardness, 0.1f, 50);
            col            = GUIControls.RGBCircle(col, "", colorCircle);
            break;

        case Tool.Eraser:
            GUILayout.Label("Size " + Mathf.Round(eraser.width * 10) / 10);
            eraser.width = GUILayout.HorizontalSlider(eraser.width, 0, 50);
            GUILayout.Label("Hardness " + Mathf.Round(eraser.hardness * 10) / 10);
            eraser.hardness = GUILayout.HorizontalSlider(eraser.hardness, 1, 50);
            break;
            break;
        }

        if (tool == Tool.Line)
        {
            stroke.enabled = GUILayout.Toggle(stroke.enabled, "Stroke");
            GUILayout.Label("Stroke Width " + Mathf.Round(stroke.width * 10) / 10);
            stroke.width = GUILayout.HorizontalSlider(stroke.width, 0, lineWidth);
            GUILayout.Label("Secondary Color");
            col2 = GUIControls.RGBCircle(col2, "", colorCircle);
        }

        GUILayout.EndArea();
        GUI.DrawTexture(new Rect(100, 0, baseTex.width * zoom, baseTex.height * zoom), backTex);
        Color colPreviousGUIColor = GUI.color;

        GUI.color = new Color(colPreviousGUIColor.r, colPreviousGUIColor.g, colPreviousGUIColor.b, alpha);
        GUI.DrawTexture(new Rect(100, 0, baseTex.width * zoom, baseTex.height * zoom), baseTex);
        GUI.color = colPreviousGUIColor;
        GUILayout.EndArea();
    }
Exemple #4
0
 public DMSNewColumn(string fieldName, int version, int length, int decPositions, UseEditFlags useEdit,
                     FieldTypes type, FieldFormats format, GUIControls gui = GUIControls.DEFAULT)
 {
     FieldName         = fieldName;
     VersionNumber     = version;
     FieldLength       = length;
     DecimalPositions  = decPositions;
     UseEditMask       = useEdit;
     FieldType         = type;
     FieldFormat       = format;
     DefaultGUIControl = gui;
 }
        public static void SetUpCollectionNavigation(string collectionLabel, SceneExplorerState state, ReferenceChain refChain, ReferenceChain oldRefChain, int collectionSize, out int arrayStart,
                                                     out int arrayEnd)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * refChain.Ident);
            GUILayout.Label($"{collectionLabel} size: {collectionSize}");

            if (!state.selectedArrayStartIndices.ContainsKey(refChain))
            {
                state.selectedArrayStartIndices.Add(refChain, 0);
            }

            if (!state.selectedArrayEndIndices.ContainsKey(refChain))
            {
                state.selectedArrayEndIndices.Add(refChain, 32);
            }

            arrayStart = state.selectedArrayStartIndices[refChain];
            arrayEnd   = state.selectedArrayEndIndices[refChain];
            GUIControls.IntField($"{oldRefChain}.arrayStart", "Start index", ref arrayStart, 0.0f, true, true);
            GUIControls.IntField($"{oldRefChain}.arrayEnd", "End index", ref arrayEnd, 0.0f, true, true);
            GUILayout.Label("(32 items max)");
            var pageSize = Mathf.Clamp(arrayEnd - arrayStart + 1, 1, Mathf.Min(32, collectionSize - arrayStart, arrayEnd + 1));

            if (GUILayout.Button("◄", GUILayout.ExpandWidth(false)))
            {
                arrayStart -= pageSize;
                arrayEnd   -= pageSize;
            }
            if (GUILayout.Button("►", GUILayout.ExpandWidth(false)))
            {
                arrayStart += pageSize;
                arrayEnd   += pageSize;
            }
            arrayStart = Mathf.Clamp(arrayStart, 0, collectionSize - pageSize);
            arrayEnd   = Mathf.Clamp(arrayEnd, pageSize - 1, collectionSize - 1);
            if (arrayStart > arrayEnd)
            {
                arrayEnd = arrayStart;
            }

            if (arrayEnd - arrayStart > 32)
            {
                arrayEnd = arrayStart + 32;
                arrayEnd = Mathf.Clamp(arrayEnd, 32, collectionSize - 1);
            }
            state.selectedArrayStartIndices[refChain] = arrayStart;
            state.selectedArrayEndIndices[refChain]   = arrayEnd;
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
Exemple #6
0
        private static void OnSceneTreeReflectUnityEngineVector3(ReferenceChain refChain, string name, ref Vector3 vec)
        {
            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            vec = GUIControls.CustomValueField(
                refChain.UniqueId,
                name,
                GUIControls.PresentVector3,
                vec,
                MainWindow.Instance.Config.TreeIdentSpacing * refChain.Indentation);
        }
Exemple #7
0
        private static void OnSceneTreeReflectUnityEngineVector3 <T>(ReferenceChain refChain, T obj, string name, ref UnityEngine.Vector3 vec)
        {
            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            GUIControls.Vector3Field(refChain.ToString(), name, ref vec, ModTools.Instance.config.sceneExplorerTreeIdentSpacing * refChain.Ident, () =>
            {
                try
                {
                    ModTools.Instance.watches.AddWatch(refChain);
                }
                catch (Exception ex)
                {
                    Log.Error("Exception in ModTools:OnSceneTreeReflectUnityEngineVector3 - " + ex.Message);
                }
            });
        }
Exemple #8
0
        public DMSRecordFieldMetadata(DMSNewColumn newColumn, DMSTable table)
        {
            FieldName        = newColumn.FieldName;
            RecordName       = table.Name;
            Unknown1         = 0;
            VersionNumber    = newColumn.VersionNumber;
            DecimalPositions = newColumn.DecimalPositions;

            UseEditMask = newColumn.UseEditMask;

            Unknown2 = 0;

            FieldType         = newColumn.FieldType;
            FieldFormat       = newColumn.FieldFormat;
            FieldLength       = newColumn.FieldLength;
            DefaultGUIControl = newColumn.DefaultGUIControl;

            Unknown5 = 0;
            Unknown6 = 0;
        }
Exemple #9
0
        public DMSRecordFieldMetadata(byte[] data, bool littleEndian)
        {
            using (MemoryStream ms = new MemoryStream(data))
            {
                using (EndianBinaryReader br = new EndianBinaryReader(ms, littleEndian))
                {
                    FieldName  = br.ReadFromUnicode(38);
                    RecordName = br.ReadFromUnicode(32);
                    Unknown1   = br.ReadInt32();
                    if (Unknown1 != 0)
                    {
                        Debugger.Break();
                    }

                    VersionNumber    = br.ReadInt32();
                    DecimalPositions = br.ReadInt32();

                    UseEditMask = (UseEditFlags)br.ReadInt32();

                    Unknown2 = br.ReadInt16();
                    if (Unknown2 != 0)
                    {
                        Debugger.Break();
                    }

                    FieldType         = (FieldTypes)br.ReadInt16();
                    FieldFormat       = (FieldFormats)br.ReadInt16();
                    FieldLength       = br.ReadInt32();
                    DefaultGUIControl = (GUIControls)br.ReadInt32();

                    Unknown5 = br.ReadInt32();
                    Unknown6 = br.ReadInt16();
                    if (Unknown5 != 0 || Unknown6 != 0)
                    {
                        Debugger.Break();
                    }
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// Remove the field and recalculate the playlist
        /// </summary>
        /// <param name="controlID"></param>
        private void cleanAndReset(GUIControls controlID)
        {
            // Shuffle up the custom fields
              if (controlID == GUIControls.FieldButton1)
              {
            fieldSelected1 = fieldSelected2;
            customSearchStr1 = customSearchStr2;

            fieldSelected2 = fieldSelected3;
            customSearchStr2 = customSearchStr3;

            fieldSelected3 = fieldSelected4;
            customSearchStr3 = customSearchStr4;

            fieldSelected4 = fieldSelected5;
            customSearchStr4 = customSearchStr5;

            fieldSelected5 = fieldSelected6;
            customSearchStr5 = customSearchStr6;

              }
              else if (controlID == GUIControls.FieldButton2)
              {
            fieldSelected2 = fieldSelected3;
            customSearchStr2 = customSearchStr3;
            fieldSelected3 = fieldSelected4;
            customSearchStr3 = customSearchStr4;
            fieldSelected4 = fieldSelected5;
            customSearchStr4 = customSearchStr5;
            fieldSelected5 = fieldSelected6;
            customSearchStr5 = customSearchStr6;
              }
              else if (controlID == GUIControls.FieldButton3)
              {
            fieldSelected3 = fieldSelected4;
            customSearchStr3 = customSearchStr4;
            fieldSelected4 = fieldSelected5;
            customSearchStr4 = customSearchStr5;
            fieldSelected5 = fieldSelected6;
            customSearchStr5 = customSearchStr6;
              }
              else if (controlID == GUIControls.FieldButton4)
              {
            fieldSelected4 = fieldSelected5;
            customSearchStr4 = customSearchStr5;
            fieldSelected5 = fieldSelected6;
            customSearchStr5 = customSearchStr6;
              }
              else if (controlID == GUIControls.FieldButton5)
              {
            fieldSelected5 = fieldSelected6;
            customSearchStr5 = customSearchStr6;
              }
              else if (controlID == GUIControls.FieldButton6)
              {
            fieldSelected5 = string.Empty;
            customSearchStr5 = string.Empty;
              }

              // Reset the enabled stauts of the controls
              if (fieldSelected2 == string.Empty)
              {
            GUIControl.DisableControl(windowID, (int)GUIControls.FieldButton2);
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton2, Localization.SelFilter);
              }
              if (fieldSelected3 == string.Empty)
              {
            GUIControl.DisableControl(windowID, (int)GUIControls.FieldButton3);
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton3,Localization.SelFilter);
              }
              if (fieldSelected4 == string.Empty)
              {
            GUIControl.DisableControl(windowID, (int)GUIControls.FieldButton4);
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton4,Localization.SelFilter);
              }
              if (fieldSelected5 == string.Empty)
              {
            GUIControl.DisableControl(windowID, (int)GUIControls.FieldButton5);
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton5,Localization.SelFilter);
              }
              if (fieldSelected6 == string.Empty)
              {
            GUIControl.DisableControl(windowID, (int)GUIControls.FieldButton6);
            GUIControl.SetControlLabel(windowID, (int)GUIControls.FieldButton6,Localization.SelFilter);
              }
              // Reload the playlist
              reCalculatePlaylist();
        }
        public static void OnSceneReflectUnityEngineMaterial(SceneExplorerState state, ReferenceChain refChain, Material material)
        {
            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            if (material == null)
            {
                SceneExplorerCommon.OnSceneTreeMessage(refChain, "null");
                return;
            }

            ReferenceChain oldRefChain = refChain;

            foreach (var prop in textureProps)
            {
                if (!material.HasProperty(prop))
                {
                    continue;
                }

                var value = material.GetTexture(prop);
                if (value == null)
                {
                    continue;
                }

                refChain = oldRefChain.Add(prop);

                var type = value.GetType();

                GUILayout.BeginHorizontal();
                GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1));

                GUIExpander.ExpanderControls(state, refChain, type);

                GUI.contentColor = ModTools.Instance.config.typeColor;

                GUILayout.Label(type.ToString() + " ");

                GUI.contentColor = ModTools.Instance.config.nameColor;

                GUILayout.Label(prop);

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");

                GUI.contentColor = ModTools.Instance.config.valueColor;
                GUILayout.Label(value.ToString());
                GUI.contentColor = Color.white;

                GUILayout.FlexibleSpace();
                GUIButtons.SetupButtons(type, value, refChain);
                object paste;
                var    doPaste = GUIButtons.SetupPasteButon(type, out paste);
                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain))
                {
                    GUIReflect.OnSceneTreeReflect(state, refChain, value);
                }

                if (doPaste)
                {
                    material.SetTexture(prop, (Texture)paste);
                }
            }

            foreach (string prop in colorProps)
            {
                if (!material.HasProperty(prop))
                {
                    continue;
                }

                Color value = material.GetColor(prop);
                refChain = oldRefChain.Add(prop);

                var type = value.GetType();

                GUILayout.BeginHorizontal();
                GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1));

                GUIExpander.ExpanderControls(state, refChain, type);

                GUI.contentColor = ModTools.Instance.config.typeColor;

                GUILayout.Label(type.ToString() + " ");

                GUI.contentColor = ModTools.Instance.config.nameColor;

                GUILayout.Label(prop);

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");
                var f = value;

                GUI.contentColor = ModTools.Instance.config.valueColor;

                var propertyCopy = prop;
                GUIControls.ColorField(refChain.ToString(), "", ref f, 0.0f, null, true, true, color => { material.SetColor(propertyCopy, color); });
                if (f != value)
                {
                    material.SetColor(prop, f);
                }

                GUI.contentColor = Color.white;
                GUILayout.FlexibleSpace();
                GUIButtons.SetupButtons(type, value, refChain);
                object paste;
                var    doPaste = GUIButtons.SetupPasteButon(type, out paste);
                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain))
                {
                    GUIReflect.OnSceneTreeReflect(state, refChain, value);
                }
                if (doPaste)
                {
                    material.SetColor(prop, (Color)paste);
                }
            }

            GUIReflect.OnSceneTreeReflect(state, refChain, material, true);
        }
Exemple #12
0
 private void Awake()
 {
     instance = this;
 }
        public static void OnSceneTreeReflectProperty(SceneExplorerState state, ReferenceChain refChain, object obj, PropertyInfo property, TypeUtil.SmartType smartType = TypeUtil.SmartType.Undefined, int nameHighlightFrom = -1, int nameHighlightLength = 0)
        {
            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            if (obj == null || property == null)
            {
                SceneExplorerCommon.OnSceneTreeMessage(refChain, "null");
                return;
            }

            GUILayout.BeginHorizontal(GUIWindow.HighlightStyle);
            SceneExplorerCommon.InsertIndent(refChain.Indentation);

            object value = null;

            Exception exceptionOnGetting = null;

            if (property.CanRead && MainWindow.Instance.Config.EvaluateProperties || state.EvaluatedProperties.Contains(refChain.UniqueId))
            {
                try
                {
                    value = property.GetValue(obj, null);
                }
                catch (Exception e)
                {
                    exceptionOnGetting = e;
                }

                if (value != null && exceptionOnGetting == null)
                {
                    GUIExpander.ExpanderControls(state, refChain, property.PropertyType, obj);
                }
            }

            GUI.contentColor = Color.white;

            if (!property.CanWrite)
            {
                GUI.enabled = false;
            }

            if (MainWindow.Instance.Config.ShowModifiers)
            {
                GUI.contentColor = MainWindow.Instance.Config.MemberTypeColor;
                GUILayout.Label("property ");

                if (!property.CanWrite)
                {
                    GUI.contentColor = MainWindow.Instance.Config.KeywordColor;
                    GUILayout.Label("const ");
                }
            }

            GUI.contentColor = MainWindow.Instance.Config.TypeColor;

            GUILayout.Label(property.PropertyType.ToString() + " ");

            GUI.contentColor = MainWindow.Instance.Config.NameColor;

            GUIMemberName.MemberName(property, nameHighlightFrom, nameHighlightLength);

            GUI.contentColor = Color.white;
            GUILayout.Label(" = ");
            GUI.contentColor = MainWindow.Instance.Config.ValueColor;
            if (exceptionOnGetting != null)
            {
                GUI.contentColor = Color.red;
                GUILayout.Label("Exception happened when getting property value");
                GUI.contentColor = Color.white;
                GUI.enabled      = true;
                if (exceptionOnGetting.InnerException != null)
                {
                    GUIStackTrace.StackTraceButton(new StackTrace(exceptionOnGetting.InnerException, true), exceptionOnGetting.InnerException.Message);
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                return;
            }

            if (!MainWindow.Instance.Config.EvaluateProperties && !state.EvaluatedProperties.Contains(refChain.UniqueId))
            {
                GUI.enabled = true;

                if (GUILayout.Button("Evaluate"))
                {
                    state.EvaluatedProperties.Add(refChain.UniqueId);
                }
            }
            else if (value == null || !TypeUtil.IsSpecialType(property.PropertyType))
            {
                if (property.CanRead)
                {
                    GUILayout.Label(value == null ? "null" : value.ToString());
                }
                else
                {
                    GUILayout.Label("(no get method)");
                }

                GUI.contentColor = Color.white;
            }
            else
            {
                try
                {
                    var newValue = GUIControls.EditorValueField(refChain.UniqueId, property.PropertyType, value);
                    if (newValue != value)
                    {
                        property.SetValue(obj, newValue, null);
                    }
                }
                catch (Exception)
                {
                    if (property.CanRead)
                    {
                        GUILayout.Label(value == null ? "null" : value.ToString());
                    }
                    else
                    {
                        GUILayout.Label("(no get method)");
                    }

                    GUI.contentColor = Color.white;
                }
            }

            GUI.enabled      = true;
            GUI.contentColor = Color.white;

            GUILayout.FlexibleSpace();

            GUIButtons.SetupCommonButtons(refChain, value, valueIndex: 0, smartType);
            object paste   = null;
            var    doPaste = property.CanWrite;

            if (doPaste)
            {
                doPaste = GUIButtons.SetupPasteButon(property.PropertyType, value, out paste);
            }

            if (value != null)
            {
                GUIButtons.SetupJumpButton(value, refChain);
            }

            GUILayout.EndHorizontal();

            if (value != null && state.ExpandedObjects.Contains(refChain.UniqueId))
            {
                GUIReflect.OnSceneTreeReflect(state, refChain, value, false);
            }

            if (doPaste)
            {
                try
                {
                    property.SetValue(obj, paste, null);
                }
                catch (Exception e)
                {
                    Logger.Warning(e.Message);
                }
            }
        }
Exemple #14
0
        public static void OnSceneTreeReflectProperty(SceneExplorerState state, ReferenceChain refChain, System.Object obj, PropertyInfo property)
        {
            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            if (obj == null || property == null)
            {
                SceneExplorerCommon.OnSceneTreeMessage(refChain, "null");
                return;
            }

            var hash = refChain.GetHashCode().ToString();

            GUILayout.BeginHorizontal();
            GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * refChain.Ident);

            bool   propertyWasEvaluated = false;
            object value = null;

            Exception exceptionOnGetting = null;

            if (property.CanRead && ModTools.Instance.config.sceneExplorerEvaluatePropertiesAutomatically || state.evaluatedProperties.ContainsKey(refChain))
            {
                try
                {
                    value = property.GetValue(obj, null);
                    propertyWasEvaluated = true;
                }
                catch (Exception e)
                {
                    exceptionOnGetting = e;
                }

                if (value != null && exceptionOnGetting == null)
                {
                    GUIExpander.ExpanderControls(state, refChain, property.PropertyType, obj);
                }
            }

            GUI.contentColor = Color.white;

            if (!property.CanWrite)
            {
                GUI.enabled = false;
            }

            if (ModTools.Instance.config.sceneExplorerShowModifiers)
            {
                GUI.contentColor = ModTools.Instance.config.memberTypeColor;
                GUILayout.Label("property ");

                if (!property.CanWrite)
                {
                    GUI.contentColor = ModTools.Instance.config.keywordColor;
                    GUILayout.Label("const ");
                }
            }

            GUI.contentColor = ModTools.Instance.config.typeColor;

            GUILayout.Label(property.PropertyType.ToString() + " ");

            GUI.contentColor = ModTools.Instance.config.nameColor;

            GUILayout.Label(property.Name);

            GUI.contentColor = Color.white;
            GUILayout.Label(" = ");
            GUI.contentColor = ModTools.Instance.config.valueColor;

            if (!ModTools.Instance.config.sceneExplorerEvaluatePropertiesAutomatically && !state.evaluatedProperties.ContainsKey(refChain))
            {
                GUI.enabled = true;

                if (GUILayout.Button("Evaluate"))
                {
                    state.evaluatedProperties.Add(refChain, true);
                }
            }
            else
            {
                if (!propertyWasEvaluated && property.CanRead)
                {
                    try
                    {
                        value = property.GetValue(obj, null);
                        propertyWasEvaluated = true;
                    }
                    catch (Exception e)
                    {
                        exceptionOnGetting = e;
                    }
                }
                if (exceptionOnGetting != null)
                {
                    GUI.contentColor = Color.red;
                    GUILayout.Label("Exception happened when getting property value");
                    GUI.contentColor = Color.white;
                    GUI.enabled      = true;
                    GUIStackTrace.StackTraceButton(new StackTrace(exceptionOnGetting, true));

                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                    return;
                }


                if (value == null || !TypeUtil.IsSpecialType(property.PropertyType))
                {
                    if (property.CanRead)
                    {
                        GUILayout.Label(value == null ? "null" : value.ToString());
                    }
                    else
                    {
                        GUILayout.Label("(no get method)");
                    }

                    GUI.contentColor = Color.white;
                }
                else
                {
                    try
                    {
                        var newValue = GUIControls.EditorValueField(refChain, hash, property.PropertyType, value);
                        if (newValue != value)
                        {
                            property.SetValue(obj, newValue, null);
                        }
                    }
                    catch (Exception)
                    {
                        if (property.CanRead)
                        {
                            GUILayout.Label(value == null ? "null" : value.ToString());
                        }
                        else
                        {
                            GUILayout.Label("(no get method)");
                        }

                        GUI.contentColor = Color.white;
                    }
                }
            }

            GUI.enabled      = true;
            GUI.contentColor = Color.white;

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Watch"))
            {
                ModTools.Instance.watches.AddWatch(refChain);
            }
            GUIButtons.SetupButtons(property.PropertyType, value, refChain);
            object paste   = null;
            var    doPaste = property.CanWrite;

            if (doPaste)
            {
                doPaste = GUIButtons.SetupPasteButon(property.PropertyType, out paste);
            }
            GUILayout.EndHorizontal();

            if (value != null && state.expandedObjects.ContainsKey(refChain))
            {
                if (value is GameObject)
                {
                    var go = value as GameObject;
                    foreach (var component in go.GetComponents <Component>())
                    {
                        GUIComponent.OnSceneTreeComponent(state, refChain, component);
                    }
                }
                else if (value is Transform)
                {
                    GUITransform.OnSceneTreeReflectUnityEngineTransform(refChain, (Transform)value);
                }
                else
                {
                    GUIReflect.OnSceneTreeReflect(state, refChain, value);
                }
            }
            if (doPaste)
            {
                try
                {
                    property.SetValue(obj, paste, null);
                }
                catch (Exception e)
                {
                    Log.Warning(e.Message);
                }
            }
        }
        public static void OnSceneReflectUnityEngineMaterial(
            SceneExplorerState state, ReferenceChain refChain, Material material)
        {
            Debug.Log($"OnSceneReflectUnityEngineMaterial(): " + System.Environment.StackTrace);

            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            if (material == null)
            {
                SceneExplorerCommon.OnSceneTreeMessage(refChain, "null");
                return;
            }

            GUILayout.BeginHorizontal();
            GUI.contentColor = Color.white;
            GUILayout.Label("Special Properties:");
            GUILayout.EndHorizontal();

            foreach (var prop in ShaderUtil.GetTextureProperties())
            {
                if (!material.HasProperty(prop))
                {
                    continue;
                }

                var value = material.GetTexture(prop);
                if (value == null)
                {
                    continue;
                }

                var newRefChain = refChain.Add(prop);

                var type = value.GetType();

                GUILayout.BeginHorizontal(GUIWindow.HighlightStyle);
                SceneExplorerCommon.InsertIndent(newRefChain.Indentation + 1);

                GUIExpander.ExpanderControls(state, newRefChain, type);

                GUI.contentColor = MainWindow.Instance.Config.TypeColor;

                GUILayout.Label(type.ToString() + " ");

                GUI.contentColor = MainWindow.Instance.Config.NameColor;

                GUILayout.Label(prop);

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");

                GUI.contentColor = MainWindow.Instance.Config.ValueColor;
                GUILayout.Label(value.ToString());
                GUI.contentColor = Color.white;

                GUILayout.FlexibleSpace();
                GUIButtons.SetupCommonButtons(newRefChain, value, valueIndex: 0);
                var doPaste = GUIButtons.SetupPasteButon(type, value, out var paste);
                if (value != null)
                {
                    GUIButtons.SetupJumpButton(value, newRefChain);
                }

                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.ExpandedObjects.Contains(newRefChain.UniqueId))
                {
                    GUIReflect.OnSceneTreeReflect(state, newRefChain, value, false);
                }

                if (doPaste)
                {
                    material.SetTexture(prop, (Texture)paste);
                }
            }

            foreach (var prop in ShaderUtil.GetColorProperties())
            {
                if (!material.HasProperty(prop))
                {
                    continue;
                }

                var value       = material.GetColor(prop);
                var newRefChain = refChain.Add(prop);

                var type = value.GetType();

                GUILayout.BeginHorizontal();
                SceneExplorerCommon.InsertIndent(newRefChain.Indentation + 1);

                GUIExpander.ExpanderControls(state, newRefChain, type);

                GUI.contentColor = MainWindow.Instance.Config.TypeColor;

                GUILayout.Label(type.ToString() + " ");

                GUI.contentColor = MainWindow.Instance.Config.NameColor;

                GUILayout.Label(prop);

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");

                GUI.contentColor = MainWindow.Instance.Config.ValueColor;

                var newColor = GUIControls.CustomValueField(newRefChain.UniqueId, string.Empty, GUIControls.PresentColor, value);
                if (newColor != value)
                {
                    material.SetColor(prop, newColor);
                }

                GUI.contentColor = Color.white;
                GUILayout.FlexibleSpace();
                GUIButtons.SetupCommonButtons(newRefChain, value, valueIndex: 0);
                var doPaste = GUIButtons.SetupPasteButon(type, value, out var paste);

                GUIButtons.SetupJumpButton(value, newRefChain);

                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.ExpandedObjects.Contains(newRefChain.UniqueId))
                {
                    GUIReflect.OnSceneTreeReflect(state, newRefChain, value, false);
                }

                if (doPaste)
                {
                    material.SetColor(prop, (Color)paste);
                }
            }

            foreach (var prop in ShaderUtil.GetFloatProperties())
            {
                if (!material.HasProperty(prop))
                {
                    continue;
                }

                var value       = material.GetFloat(prop);
                var newRefChain = refChain.Add(prop);

                var type = value.GetType();

                GUILayout.BeginHorizontal();
                SceneExplorerCommon.InsertIndent(newRefChain.Indentation + 1);

                GUIExpander.ExpanderControls(state, newRefChain, type);

                GUI.contentColor = MainWindow.Instance.Config.TypeColor;

                GUILayout.Label(type.ToString() + " ");

                GUI.contentColor = MainWindow.Instance.Config.NameColor;

                GUILayout.Label(prop);

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");

                GUI.contentColor = MainWindow.Instance.Config.ValueColor;

                var newValue = GUIControls.NumericValueField(newRefChain.UniqueId, string.Empty, value);
                if (newValue != value)
                {
                    material.SetFloat(prop, newValue);
                }

                GUI.contentColor = Color.white;
                GUILayout.FlexibleSpace();
                GUIButtons.SetupCommonButtons(newRefChain, value, 0);
                var doPaste = GUIButtons.SetupPasteButon(type, value, out var paste);
                GUIButtons.SetupJumpButton(value, newRefChain);

                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.ExpandedObjects.Contains(newRefChain.UniqueId))
                {
                    GUIReflect.OnSceneTreeReflect(state, newRefChain, value, false);
                }

                if (doPaste)
                {
                    material.SetColor(prop, (Color)paste);
                }
            }

            foreach (var prop in ShaderUtil.GetVectorProperties())
            {
                if (!material.HasProperty(prop))
                {
                    continue;
                }

                var value       = material.GetVector(prop);
                var newRefChain = refChain.Add(prop);

                var type = value.GetType();

                GUILayout.BeginHorizontal();
                SceneExplorerCommon.InsertIndent(newRefChain.Indentation + 1);

                GUIExpander.ExpanderControls(state, newRefChain, type);

                GUI.contentColor = MainWindow.Instance.Config.TypeColor;

                GUILayout.Label(type.ToString() + " ");

                GUI.contentColor = MainWindow.Instance.Config.NameColor;

                GUILayout.Label(prop);

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");

                GUI.contentColor = MainWindow.Instance.Config.ValueColor;

                var newValue = GUIControls.PresentVector4(newRefChain.UniqueId, value);
                if (newValue != value)
                {
                    material.SetVector(prop, newValue);
                }

                GUI.contentColor = Color.white;
                GUILayout.FlexibleSpace();
                GUIButtons.SetupCommonButtons(newRefChain, value, valueIndex: 0);
                var doPaste = GUIButtons.SetupPasteButon(type, value, out var paste);

                GUIButtons.SetupJumpButton(value, newRefChain);

                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.ExpandedObjects.Contains(newRefChain.UniqueId))
                {
                    GUIReflect.OnSceneTreeReflect(state, newRefChain, value, false);
                }

                if (doPaste)
                {
                    material.SetColor(prop, (Color)paste);
                }
            }

            var shaderKeywords = material.shaderKeywords;

            if (shaderKeywords != null && shaderKeywords.Length > 0)
            {
                var valueTyoe = shaderKeywords.GetType();

                GUILayout.BeginHorizontal();
                SceneExplorerCommon.InsertIndent(refChain.Indentation + 2);

                GUI.contentColor = MainWindow.Instance.Config.TypeColor;
                GUILayout.Label(valueTyoe.ToString() + " ");

                GUI.contentColor = MainWindow.Instance.Config.NameColor;
                GUILayout.Label("Shader keywords ");

                GUI.contentColor = Color.white;
                GUILayout.Label(" = ");

                GUI.contentColor = MainWindow.Instance.Config.ValueColor;
                GUILayout.Label(string.Join(", ", shaderKeywords));

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }

            GUIReflect.OnSceneTreeReflect(state, refChain, material, true);
        }
Exemple #16
0
    void DoMyWindow(int windowId)
    {
//		GUILayout.BeginArea(new Rect(20,20,300,Screen.height - 40));
//		GUILayout.BeginVertical("Box");

//		if( GUILayout.Button("anime: "+isAnime.ToString()) ){
//			isAnime = !isAnime;
//			if(isAnime){
//				RandomEffect();
//			}
//		}
        if (GUILayout.Button("RandomEffect"))
        {
            RandomEffect();
        }
        if (GUILayout.Button("Clear"))
        {
            ClearEffect();
        }
        GUIControls.HR();

        displacement.enabled = GUILayout.Toggle(displacement.enabled, "displacementMap");
        if (displacement.enabled)
        {
            DrawSlider(ref displacement.vx, "vx", -0.2f, 0.2f);
            DrawSlider(ref displacement.vy, "vy", -0.2f, 0.2f);
            DrawSlider(ref displacement.scale, "scale", 0.0f, 2.0f);
        }

        shaker.enabled = GUILayout.Toggle(shaker.enabled, "shaker");
        if (shaker.enabled)
        {
            DrawSlider(ref shaker.blur_vec_x, "vx", -0.5f, 0.5f);
            DrawSlider(ref shaker.blur_vec_y, "vy", -0.5f, 0.5f);
        }

        glow.enabled = GUILayout.Toggle(glow.enabled, "glow");

        dotScreen.enabled = GUILayout.Toggle(dotScreen.enabled, "dotScreen");
        if (dotScreen.enabled)
        {
            DrawSlider(ref dotScreen.scale, "scale", 0.5f, 4.0f);
        }

        slitscan.enabled = GUILayout.Toggle(slitscan.enabled, "slitscan");
        if (slitscan.enabled)
        {
            DrawSlider(ref slitscan.val3, "val", 0.01f, 0.1f);
        }

        dotMatrix.enabled = GUILayout.Toggle(dotMatrix.enabled, "dotMatrix");
        if (dotMatrix.enabled)
        {
            DrawSlider(ref dotMatrix.spacing, "spacing", 1, 20);
            DrawSlider(ref dotMatrix.size, "size", 1, 50);
            DrawSlider(ref dotMatrix.blur, "blur", 1, 20);
        }

        twist.enabled = GUILayout.Toggle(twist.enabled, "twist");
        if (twist.enabled)
        {
            DrawSlider(ref twist.timer, "timer", 0, 1);
            DrawSlider(ref twist.val2, "val2", 0.1f, 1);
            DrawSlider(ref twist.val3, "val3", 0.0f, 0.1f);
        }

        film.enabled = GUILayout.Toggle(film.enabled, "film");
        if (film.enabled)
        {
            DrawSlider(ref film.nIntensity, "nIntensity", 0, 1);
            DrawSlider(ref film.sIntensity, "sIntensity", 0, 1);
        }

        rgbShift.enabled = GUILayout.Toggle(rgbShift.enabled, "rgbShift");
        if (rgbShift.enabled)
        {
            DrawSlider(ref rgbShift.amount, "amount", 0, 0.02f);
            DrawSlider(ref rgbShift.angle, "angle", 0, Mathf.PI * 2);
        }

        kaleidoscope.enabled = GUILayout.Toggle(kaleidoscope.enabled, "kaleidoscope");
        if (kaleidoscope.enabled)
        {
            DrawSliderInt(ref kaleidoscope.sides, "num", 3, 12);
            DrawSlider(ref kaleidoscope.angle, "angle", 0, 360);
        }

        colorControl.enabled = GUILayout.Toggle(colorControl.enabled, "colorControl");
        if (colorControl.enabled)
        {
            DrawSlider(ref colorControl.riseR, "r", -0.5f, 0.5f);
            DrawSlider(ref colorControl.riseG, "g", -0.5f, 0.5f);
            DrawSlider(ref colorControl.riseB, "b", -0.5f, 0.5f);
        }

        outlineMod.enabled = GUILayout.Toggle(outlineMod.enabled, "outlineMod");

//		GUILayout.EndVertical();
//		GUILayout.EndArea();

        GUI.DragWindow();
    }
        public static void OnSceneTreeReflectField(SceneExplorerState state, ReferenceChain refChain, object obj, FieldInfo field, TypeUtil.SmartType smartType = TypeUtil.SmartType.Undefined, int nameHighlightFrom = -1, int nameHighlightLength = 0)
        {
            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            if (obj == null || field == null)
            {
                SceneExplorerCommon.OnSceneTreeMessage(refChain, "null");
                return;
            }

            GUILayout.BeginHorizontal(GUIWindow.HighlightStyle);
            SceneExplorerCommon.InsertIndent(refChain.Indentation);

            GUI.contentColor = Color.white;

            object value = null;

            try
            {
                value = field.GetValue(obj);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            if (value != null)
            {
                GUIExpander.ExpanderControls(state, refChain, field.FieldType);
            }

            if (field.IsInitOnly)
            {
                GUI.enabled = false;
            }

            if (MainWindow.Instance.Config.ShowModifiers)
            {
                GUI.contentColor = MainWindow.Instance.Config.ModifierColor;

                if (field.IsPublic)
                {
                    GUILayout.Label("public ");
                }
                else if (field.IsPrivate)
                {
                    GUILayout.Label("private ");
                }

                GUI.contentColor = MainWindow.Instance.Config.MemberTypeColor;

                GUILayout.Label("field ");

                if (field.IsStatic)
                {
                    GUI.contentColor = MainWindow.Instance.Config.KeywordColor;
                    GUILayout.Label("static ");
                }

                if (field.IsInitOnly)
                {
                    GUI.contentColor = MainWindow.Instance.Config.KeywordColor;
                    GUILayout.Label("const ");
                }
            }

            GUI.contentColor = MainWindow.Instance.Config.TypeColor;
            GUILayout.Label(field.FieldType + " ");

            GUIMemberName.MemberName(field, nameHighlightFrom, nameHighlightLength);

            GUI.contentColor = Color.white;
            GUILayout.Label(" = ");
            GUI.contentColor = MainWindow.Instance.Config.ValueColor;

            if (value == null || !TypeUtil.IsSpecialType(field.FieldType))
            {
                GUILayout.Label(value?.ToString() ?? "null");
            }
            else
            {
                try
                {
                    var newValue = GUIControls.EditorValueField(refChain.UniqueId, field.FieldType, value);
                    if (!newValue.Equals(value))
                    {
                        field.SetValue(obj, newValue);
                    }
                }
                catch (Exception)
                {
                    GUILayout.Label(value.ToString());
                }
            }

            GUI.enabled      = true;
            GUI.contentColor = Color.white;

            GUILayout.FlexibleSpace();

            GUIButtons.SetupCommonButtons(refChain, value, valueIndex: 0, smartType);
            object paste   = null;
            var    doPaste = !field.IsLiteral && !field.IsInitOnly;

            if (doPaste)
            {
                doPaste = GUIButtons.SetupPasteButon(field.FieldType, value, out paste);
            }

            if (value != null)
            {
                GUIButtons.SetupJumpButton(value, refChain);
            }

            GUILayout.EndHorizontal();
            if (value != null && !TypeUtil.IsSpecialType(field.FieldType) && state.ExpandedObjects.Contains(refChain.UniqueId))
            {
                GUIReflect.OnSceneTreeReflect(state, refChain, value, false, smartType);
            }

            if (doPaste)
            {
                try
                {
                    field.SetValue(obj, paste);
                }
                catch (Exception e)
                {
                    Logger.Warning(e.Message);
                }
            }
        }
Exemple #18
0
        public static void OnSceneTreeReflectIList(SceneExplorerState state,
                                                   ReferenceChain refChain, System.Object myProperty)
        {
            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            var list = myProperty as IList;

            if (list == null)
            {
                return;
            }

            var oldRefChain    = refChain;
            var collectionSize = list.Count;

            if (collectionSize == 0)
            {
                GUILayout.BeginHorizontal();
                GUI.contentColor = Color.yellow;
                GUILayout.Label("List is empty!");
                GUI.contentColor = Color.white;
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                return;
            }

            int arrayStart;
            int arrayEnd;

            GUICollectionNavigation.SetUpCollectionNavigation("List", state, refChain, oldRefChain, collectionSize, out arrayStart, out arrayEnd);
            for (int i = arrayStart; i <= arrayEnd; i++)
            {
                refChain = oldRefChain.Add(i);
                if (list[i] == null)
                {
                    continue;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * refChain.Ident);


                GUI.contentColor = Color.white;
                var type = list[i] == null ? null : list[i].GetType();
                GUIExpander.ExpanderControls(state, refChain, type);

                GUI.contentColor = ModTools.Instance.config.typeColor;

                GUILayout.Label($"{type} ");

                GUI.contentColor = ModTools.Instance.config.nameColor;

                GUILayout.Label($"{oldRefChain.LastItemName}.[{i}]");

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");

                GUI.contentColor = ModTools.Instance.config.valueColor;

                if (list[i] == null || !TypeUtil.IsSpecialType(list[i].GetType()))
                {
                    GUILayout.Label(list[i] == null ? "null" : list[i].ToString());
                }
                else
                {
                    try
                    {
                        var newValue = GUIControls.EditorValueField(refChain, refChain.ToString(), list[i].GetType(), list[i]);
                        if (newValue != list[i])
                        {
                            list[i] = newValue;
                        }
                    }
                    catch (Exception)
                    {
                        GUILayout.Label(list[i] == null ? "null" : list[i].ToString());
                    }
                }

                GUI.contentColor = Color.white;

                GUILayout.FlexibleSpace();
                GUIButtons.SetupButtons(type, list[i], refChain);
                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain))
                {
                    if (list[i] is GameObject)
                    {
                        var go = list[i] as GameObject;
                        foreach (var component in go.GetComponents <Component>())
                        {
                            GUIComponent.OnSceneTreeComponent(state, refChain, component);
                        }
                    }
                    else if (list[i] is Transform)
                    {
                        GUITransform.OnSceneTreeReflectUnityEngineTransform(refChain, (Transform)list[i]);
                    }
                    else
                    {
                        GUIReflect.OnSceneTreeReflect(state, refChain, list[i]);
                    }
                }
            }
        }
Exemple #19
0
        /// <summary>
        /// Get the search field and search value
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="searchValue"></param>
        /// <param name="controlID"></param>
        private FieldSetup getFieldAndSearchValue(ref string fieldName, ref string searchValue, GUIControls controlID)
        {
            SearchField thisField = SearchField.None;

              if (string.IsNullOrEmpty(fieldName))
              {
            fieldName = setFilterField();
            GUIControl.SetControlLabel(windowID, (int)controlID, Localization.Field + ": " + fieldName);
              }
              searchValue = filterValue(fieldName, out thisField);
              if (searchValue.Equals("None", StringComparison.OrdinalIgnoreCase))
              {
            fieldName = string.Empty;
            searchValue = string.Empty;
            return FieldSetup.Clear;
              }

              GUIControl.SetControlLabel(windowID, (int)controlID, string.Format("{0}: {1} ({2})", Localization.Field, fieldName, searchValue));
              genFilterPlaylist(thisField, searchValue);
              return FieldSetup.Success;
        }
Exemple #20
0
        public static void OnSceneTreeReflectField(SceneExplorerState state, ReferenceChain refChain, object obj, FieldInfo field)
        {
            var hash = refChain.GetHashCode().ToString();

            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            if (obj == null || field == null)
            {
                SceneExplorerCommon.OnSceneTreeMessage(refChain, "null");
                return;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * refChain.Ident);

            GUI.contentColor = Color.white;

            object value = null;

            try
            {
                value = field.GetValue(obj);
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
            }

            if (value != null)
            {
                GUIExpander.ExpanderControls(state, refChain, field.FieldType);
            }

            if (field.IsInitOnly)
            {
                GUI.enabled = false;
            }

            if (ModTools.Instance.config.sceneExplorerShowModifiers)
            {
                GUI.contentColor = ModTools.Instance.config.modifierColor;

                if (field.IsPublic)
                {
                    GUILayout.Label("public ");
                }
                else if (field.IsPrivate)
                {
                    GUILayout.Label("private ");
                }

                GUI.contentColor = ModTools.Instance.config.memberTypeColor;

                GUILayout.Label("field ");

                if (field.IsStatic)
                {
                    GUI.contentColor = ModTools.Instance.config.keywordColor;
                    GUILayout.Label("static ");
                }

                if (field.IsInitOnly)
                {
                    GUI.contentColor = ModTools.Instance.config.keywordColor;
                    GUILayout.Label("const ");
                }
            }

            GUI.contentColor = ModTools.Instance.config.typeColor;
            GUILayout.Label(field.FieldType + " ");

            GUI.contentColor = ModTools.Instance.config.nameColor;

            GUILayout.Label(field.Name);

            GUI.contentColor = Color.white;
            GUI.contentColor = Color.white;
            GUILayout.Label(" = ");
            GUI.contentColor = ModTools.Instance.config.valueColor;

            if (value == null || !TypeUtil.IsSpecialType(field.FieldType))
            {
                GUILayout.Label(value?.ToString() ?? "null");
            }
            else
            {
                try
                {
                    var newValue = GUIControls.EditorValueField(refChain, hash, field.FieldType, value);
                    if (newValue != value)
                    {
                        field.SetValue(obj, newValue);
                    }
                }
                catch (Exception)
                {
                    GUILayout.Label(value.ToString());
                }
            }

            GUI.enabled      = true;
            GUI.contentColor = Color.white;

            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Watch"))
            {
                ModTools.Instance.watches.AddWatch(refChain);
            }
            GUIButtons.SetupButtons(field.FieldType, value, refChain);
            object paste   = null;
            var    doPaste = !field.IsLiteral && !field.IsInitOnly;

            if (doPaste)
            {
                doPaste = GUIButtons.SetupPasteButon(field.FieldType, out paste);
            }
            GUILayout.EndHorizontal();
            if (value != null && !TypeUtil.IsSpecialType(field.FieldType) && state.expandedObjects.ContainsKey(refChain))
            {
                if (value is GameObject)
                {
                    var go = value as GameObject;
                    foreach (var component in go.GetComponents <Component>())
                    {
                        GUIComponent.OnSceneTreeComponent(state, refChain, component);
                    }
                }
                else if (value is Transform)
                {
                    GUITransform.OnSceneTreeReflectUnityEngineTransform(refChain, (Transform)value);
                }
                else
                {
                    GUIReflect.OnSceneTreeReflect(state, refChain, value);
                }
            }
            if (doPaste)
            {
                try
                {
                    field.SetValue(obj, paste);
                }
                catch (Exception e)
                {
                    Log.Warning(e.Message);
                }
            }
        }
        private void DrawExpandedHeader()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Log message format:", GUILayout.ExpandWidth(false));
            Config.ConsoleFormatString = GUILayout.TextField(Config.ConsoleFormatString, GUILayout.ExpandWidth(true));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Max items in history:", GUILayout.ExpandWidth(false));
            Config.ConsoleMaxHistoryLength = GUIControls.NumericValueField("ConsoleMaxItemsInHistory", string.Empty, Config.ConsoleMaxHistoryLength);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Show console on:", GUILayout.ExpandWidth(false));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Message", GUILayout.ExpandWidth(false));
            Config.ShowConsoleOnMessage = GUILayout.Toggle(Config.ShowConsoleOnMessage, string.Empty, GUILayout.ExpandWidth(false));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Warning", GUILayout.ExpandWidth(false));
            Config.ShowConsoleOnWarning = GUILayout.Toggle(Config.ShowConsoleOnWarning, string.Empty, GUILayout.ExpandWidth(false));
            GUILayout.FlexibleSpace();
            GUILayout.Label("Error", GUILayout.ExpandWidth(false));
            Config.ShowConsoleOnError = GUILayout.Toggle(Config.ShowConsoleOnError, string.Empty, GUILayout.ExpandWidth(false));

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Auto-scroll on new messages:");
            Config.ConsoleAutoScrollToBottom = GUILayout.Toggle(Config.ConsoleAutoScrollToBottom, string.Empty);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("▲", GUILayout.ExpandWidth(false)))
            {
                headerExpanded = false;
                RecalculateAreas();
            }

            GUILayout.Label("Hide console configuration");

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Save"))
            {
                MainWindow.Instance.SaveConfig();
            }

            if (GUILayout.Button("Reset"))
            {
                var template = new ModConfiguration();
                Config.ConsoleMaxHistoryLength = template.ConsoleMaxHistoryLength;
                Config.ConsoleFormatString     = template.ConsoleFormatString;
                Config.ShowConsoleOnMessage    = template.ShowConsoleOnMessage;
                Config.ShowConsoleOnWarning    = template.ShowConsoleOnWarning;
                Config.ShowConsoleOnError      = template.ShowConsoleOnError;

                MainWindow.Instance.SaveConfig();
            }

            if (GUILayout.Button("Clear", GUILayout.ExpandWidth(false)))
            {
                lock (historyLock)
                {
                    history.Clear();
                }
            }

            GUILayout.EndHorizontal();
        }
Exemple #22
0
        protected override void DrawWindow()
        {
            watchesScroll = GUILayout.BeginScrollView(watchesScroll);

            foreach (var watch in watches.ToArray())
            {
                if (watch == null)
                {
                    continue;
                }

                GUILayout.BeginHorizontal();
                try
                {
                    var type = GetWatchType(watch);

                    GUI.contentColor = Config.TypeColor;
                    GUILayout.Label(type.ToString());
                    GUI.contentColor = Config.NameColor;
                    GUILayout.Label(watch.ToString());
                    GUI.contentColor = Color.white;
                    GUILayout.Label(" = ");

                    GUI.enabled = false;

                    var value = watch.Evaluate();
                    GUI.contentColor = Config.ValueColor;

                    if (value == null || !TypeUtil.IsSpecialType(type))
                    {
                        GUILayout.Label(value == null ? "null" : value.ToString());
                    }
                    else
                    {
                        try
                        {
                            GUIControls.EditorValueField("watch." + watch, type, value);
                        }
                        catch
                        {
                            GUILayout.Label(value.ToString());
                        }
                    }

                    GUI.contentColor = Color.white;

                    GUI.enabled = true;

                    GUILayout.FlexibleSpace();

                    if (value != null)
                    {
                        var smartType = TypeUtil.OverrideSmartType(TypeUtil.DetectSmartType(watch.LastItemName, value.GetType()), watch.LastItemName, watch.SubChain(watch.Length - 1).Evaluate());
                        GUIButtons.SetupSmartShowButtons(value, smartType); // TODO: get from cache
                    }

                    if (GUILayout.Button("^"))
                    {
                        var sceneExplorer = FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(watch.SubChain(watch.Length - 1));
                    }

                    if (value != null)
                    {
                        GUIButtons.SetupJumpButton(value, watch);
                    }

                    if (GUILayout.Button("x", GUILayout.Width(24)))
                    {
                        RemoveWatch(watch);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
        }
        public static void OnSceneReflectUnityEngineMaterial(SceneExplorerState state, ReferenceChain refChain, Material material)
        {
            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            if (material == null)
            {
                SceneExplorerCommon.OnSceneTreeMessage(refChain, "null");
                return;
            }

            ReferenceChain oldRefChain = refChain;

            foreach (var prop in textureProps)
            {
                if (!material.HasProperty(prop))
                {
                    continue;
                }

                var value = material.GetTexture(prop);
                if (value == null)
                {
                    continue;
                }

                refChain = oldRefChain.Add(prop);

                var type = value.GetType();

                GUILayout.BeginHorizontal();
                GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1));

                GUIExpander.ExpanderControls(state, refChain, type);

                GUI.contentColor = ModTools.Instance.config.typeColor;

                GUILayout.Label(type.ToString() + " ");

                GUI.contentColor = ModTools.Instance.config.nameColor;

                GUILayout.Label(prop);

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");

                GUI.contentColor = ModTools.Instance.config.valueColor;
                GUILayout.Label(value.ToString());
                GUI.contentColor = Color.white;

                GUILayout.FlexibleSpace();
                GUIButtons.SetupButtons(type, value, refChain);
                object paste;
                var    doPaste = GUIButtons.SetupPasteButon(type, out paste);
                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain))
                {
                    GUIReflect.OnSceneTreeReflect(state, refChain, value);
                }

                if (doPaste)
                {
                    material.SetTexture(prop, (Texture)paste);
                }
            }

            foreach (string prop in colorProps)
            {
                if (!material.HasProperty(prop))
                {
                    continue;
                }

                Color value = material.GetColor(prop);
                refChain = oldRefChain.Add(prop);

                var type = value.GetType();

                GUILayout.BeginHorizontal();
                GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1));

                GUIExpander.ExpanderControls(state, refChain, type);

                GUI.contentColor = ModTools.Instance.config.typeColor;

                GUILayout.Label(type.ToString() + " ");

                GUI.contentColor = ModTools.Instance.config.nameColor;

                GUILayout.Label(prop);

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");
                var f = value;

                GUI.contentColor = ModTools.Instance.config.valueColor;

                var propertyCopy = prop;
                GUIControls.ColorField(refChain.ToString(), "", ref f, 0.0f, null, true, true, color => { material.SetColor(propertyCopy, color); });
                if (f != value)
                {
                    material.SetColor(prop, f);
                }

                GUI.contentColor = Color.white;
                GUILayout.FlexibleSpace();
                GUIButtons.SetupButtons(type, value, refChain);
                object paste;
                var    doPaste = GUIButtons.SetupPasteButon(type, out paste);
                GUILayout.EndHorizontal();

                if (!TypeUtil.IsSpecialType(type) && state.expandedObjects.ContainsKey(refChain))
                {
                    GUIReflect.OnSceneTreeReflect(state, refChain, value);
                }
                if (doPaste)
                {
                    material.SetColor(prop, (Color)paste);
                }
            }
//            GUILayout.BeginHorizontal();
//            GUILayout.Space(ModTools.Instance.config.sceneExplorerTreeIdentSpacing * (refChain.Ident + 1));
//            GUI.contentColor = ModTools.Instance.config.typeColor;
//
//            GUILayout.Label("Shader:");
//
//            GUI.contentColor = ModTools.Instance.config.nameColor;
//
//            var shaders = Resources.FindObjectsOfTypeAll<Shader>();
//            Array.Sort(shaders, (a, b) => string.Compare(a.name, b.name, StringComparison.Ordinal));
//            var availableShaders = shaders.Select(s => s.name).ToArray();
//            var currentShader = material.shader;
//            var selectedShader = Array.IndexOf(shaders, currentShader);
//
//            var newSelectedShader = GUIComboBox.Box(selectedShader, availableShaders, "SceneExplorerShadersComboBox");
//            if (newSelectedShader != selectedShader)
//            {
//                material.shader = shaders[newSelectedShader];
//            }
//            GUILayout.FlexibleSpace();
//            GUILayout.EndHorizontal();

            GUIReflect.OnSceneTreeReflect(state, refChain, material, true);
        }