コード例 #1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();
            DrawMaskInteractions();

//			maskInteraction = (MaskInteraction)EditorGUILayout.EnumPopup("Mask Interaction", maskInteraction);
            serializedObject.ApplyModifiedProperties();

            /*
             * EditorGUI.indentLevel++;
             * var l = EditorGUIUtility.labelWidth;
             * EditorGUIUtility.labelWidth = 60;
             * using (new EditorGUILayout.HorizontalScope())
             * {
             *      EditorGUILayout.ObjectField("Mask 0", null, typeof(Mask), false);
             *      EditorGUILayout.EnumPopup (MaskIntr.None);
             * }
             * EditorGUIUtility.labelWidth = l;
             * EditorGUI.indentLevel--;
             *
             * var spMaskInteraction = serializedObject.FindProperty ("m_MaskInteraction");
             * MaskIntr intr0 = (MaskIntr)((spMaskInteraction.intValue >> 0) & 0x3);
             * MaskIntr intr1 = (MaskIntr)((spMaskInteraction.intValue >> 2) & 0x3);
             * MaskIntr intr2 = (MaskIntr)((spMaskInteraction.intValue >> 4) & 0x3);
             * MaskIntr intr3 = (MaskIntr)((spMaskInteraction.intValue >> 6) & 0x3);
             *
             * using (var ccs = new EditorGUI.ChangeCheckScope ()) {
             *
             *      intr0 = (MaskIntr)EditorGUILayout.EnumPopup ("Layer 0", intr0);
             *      intr1 = (MaskIntr)EditorGUILayout.EnumPopup ("Layer 1", intr1);
             *      intr2 = (MaskIntr)EditorGUILayout.EnumPopup ("Layer 2", intr2);
             *      intr3 = (MaskIntr)EditorGUILayout.EnumPopup ("Layer 3", intr3);
             *
             *      if (ccs.changed) {
             *              current.SetMaskInteractions (intr0,intr1,intr2,intr3);
             *      }
             * }
             */

//			spMaskInteraction.intValue = (intr0 << 0) | (intr1 << 2) | (intr2 << 4) | (intr3 << 6);
//
//			serializedObject.ApplyModifiedProperties ();



            var current = target as SoftMaskable;

            current.GetComponentsInChildren <Graphic> (true, s_Graphics);
            var fixTargets = s_Graphics.Where(x => x.gameObject != current.gameObject && !x.GetComponent <SoftMaskable> () && (!x.GetComponent <Mask> () || x.GetComponent <Mask> ().showMaskGraphic)).ToList();

            if (0 < fixTargets.Count)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.HelpBox("There are child Graphics that does not have a SoftMaskable component.\nAdd SoftMaskable component to them.", MessageType.Warning);
                GUILayout.BeginVertical();
                if (GUILayout.Button("Fix"))
                {
                    foreach (var p in fixTargets)
                    {
                        p.gameObject.AddComponent <SoftMaskable> ();
                    }
                }
                if (GUILayout.Button("Ping"))
                {
                    EditorGUIUtility.PingObject(fixTargets [0]);
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }

            if (s_TypeTMPro != null)
            {
                ShowTMProWarning(_shader, _mobileShader, _spriteShader, m => { });
                var textMeshPro = current.GetComponent(s_TypeTMPro);
                if (textMeshPro != null)
                {
                    Material [] fontSharedMaterials = s_PiFontSharedMaterials.GetValue(textMeshPro, new object [0]) as Material [];
                    ShowMaterialEditors(fontSharedMaterials, 1, fontSharedMaterials.Length - 1);
                }
            }

            if (!DetectMask(current.transform.parent))
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.HelpBox("This is unnecessary SoftMaskable.\nCan't find any SoftMask components above.", MessageType.Warning);
                if (GUILayout.Button("Remove", GUILayout.Height(40)))
                {
                    DestroyImmediate(current);

                    Utils.MarkPrefabDirty();
                }
                GUILayout.EndHorizontal();
            }
        }