コード例 #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawMeshDecalElements
        /// # Draw all mesh decal elements
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        public static Material DrawMeshDecalElements(GenericMeshDecal decal, bool comeFromEditor, Rect position, ConfigSaver configSaver)
        {
            if (decal)
            {
                EditorBasicFunctions.DrawEditorBox("Insert mesh decals: Options", Color.white, position);

                if ((configSaver != null) && !configSaver.parameters.hideBasicHelp)
                {
                    EditorBasicFunctions.DrawEditorBox(GetInsertModeHelpString() + " mesh decals", Color.yellow, position);
                }

                EditorGUILayout.Separator();

                bool showConfigOptions = true;

                if (configSaver != null)
                {
                    configSaver.parameters.showMeshDecalsConfigOptions = EditorGUILayout.Foldout(configSaver.parameters.showMeshDecalsConfigOptions, new GUIContent("Show mesh decals configuration options", "Show mesh decals configuration options"));

                    showConfigOptions = configSaver.parameters.showMeshDecalsConfigOptions;
                }

                if (!showConfigOptions)
                {
                }
                else
                {
                    EditorBasicFunctions.DrawEditorBox("Configuration", Color.yellow, position);

                    EditorGUILayout.Separator();

                    decal.attachToCollisionObject = EditorGUILayout.Toggle(new GUIContent("Attach to father", "Attach created decal to hit object"), decal.attachToCollisionObject);

                    if (comeFromEditor)
                    {
                        decal.futureTimeLockableShape = EditorGUILayout.Toggle(new GUIContent("Future time lockable shape", "It this is checked you can use the button called 'Lock all future time lockable decals' in advance options to lock all 'futureTimeLockableShape' checked on decals, Use with caution"), decal.futureTimeLockableShape);
                        decal.addCollider             = EditorGUILayout.Toggle(new GUIContent("Add collider", "Add a collider to be detected for the next decals, Use with caution"), decal.addCollider);
                        planarMeshDecals = EditorGUILayout.Toggle(new GUIContent("Simple planar", "Do the decal to be a simple plane, it's performance friendly"), planarMeshDecals);
                        EditorGUILayout.Separator();

                        decal.scaleRange   = EditorGUILayout.Vector2Field(new GUIContent("Scale range", "Randomize decal scale between 2 values"), decal.scaleRange, new GUILayoutOption[] { GUILayout.Width(0.5f * position.width) });
                        decal.scaleRange.x = Mathf.Clamp(decal.scaleRange.x, 0.01f, 10);
                        decal.scaleRange.y = Mathf.Clamp(decal.scaleRange.y, 0.01f, 10);

                        EditorGUILayout.Separator();

                        decal.rotationRange   = EditorGUILayout.Vector2Field(new GUIContent("Rotation range", "Randomize decal rotation between 2 values"), decal.rotationRange, new GUILayoutOption[] { GUILayout.Width(0.5f * position.width) });
                        decal.rotationRange.x = Mathf.Clamp(decal.rotationRange.x, 0, 360);
                        decal.rotationRange.y = Mathf.Clamp(decal.rotationRange.y, 0, 360);
                    }
                    else
                    {
                        decal.lockedShapeAlways = EditorGUILayout.Toggle(new GUIContent("Lock shape always", "Lock shape always"), decal.lockedShapeAlways);

                        decal.lockedShapeInRuntime = EditorGUILayout.Toggle(new GUIContent("Lock shape in runtime", "Lock shape in runtime"), decal.lockedShapeInRuntime);

                        decal.planarDecal = EditorGUILayout.Toggle(new GUIContent("A Simple planar", "Do the decal to be a simple plane, it's performance friendly"), decal.planarDecal);
                        EditorGUILayout.Separator();
                    }

                    EditorGUILayout.Separator();

                    decal.angleLimit = EditorGUILayout.Slider(new GUIContent("Collision angle limit", "For not planar decals, max angle between hit objects"), decal.angleLimit, 1, 180);
                    decal.angleLimit = Mathf.Clamp(decal.angleLimit, 1, 180);

                    decal.distanceFromHit = EditorGUILayout.Slider(new GUIContent("Distance from hit", "Distance in the hit normal from hit object"), decal.distanceFromHit, 0.001f, 1);
                    decal.distanceFromHit = Mathf.Clamp(decal.distanceFromHit, 0.001f, 1);

                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();
                }

                EditorBasicFunctions.DrawEditorBox("Choose mesh decal!", Color.white, position);
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                decal.material = EditorBasicFunctions.ShowObjectField <Material> ("Actual selected material ", decal.material);

                decal.material = EditorBasicFunctions.DrawMeshDecalMaterialList(decal.material, Screen.width);

                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                if (decal.material)
                {
                    List <Sprite> spriteListFromTexture = EditorBasicFunctions.GetSpriteListFromTexture(decal.material.mainTexture);

                    if (spriteListFromTexture.Count > 0)
                    {
                        decal.sprite = spriteListFromTexture [0];
                    }

                    if (!comeFromEditor)
                    {
                        //EditorGUILayout.Separator ();
                        //EditorGUILayout.Separator ();

                        EditorBasicFunctions.DrawEditorBox("Info", Color.white, position);

                        //decal.affectedLayers = EditorBasicFunctions.LayerMaskField ("Affected Layers", decal.affectedLayers);

                        decal.showAffectedObject = EditorGUILayout.Foldout(decal.showAffectedObject, "Affected Objects");

                        if (decal.showAffectedObject && (decal.affectedObjects != null))
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.Space(15);
                            GUILayout.BeginVertical();

                            foreach (GameObject go in decal.affectedObjects)
                            {
                                EditorGUILayout.ObjectField(go, typeof(GameObject), true);
                            }
                            GUILayout.EndVertical();
                            GUILayout.EndHorizontal();
                        }

                        EditorGUILayout.Separator();
                    }


                    return(decal.material);
                }
            }


            return(null);
        }
コード例 #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawProjectedDecalElements
        /// # Draw all projected decal elements
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        public static Material DrawProjectedDecalElements(GenericProjectorDecal decal, bool comeFromEditor, Rect position, ConfigSaver configSaver)
        {
            if (decal)
            {
                EditorBasicFunctions.DrawEditorBox("Insert projected decals: Options", Color.white, position);

                if (!configSaver.parameters.hideBasicHelp)
                {
                    EditorBasicFunctions.DrawEditorBox("NOTE: Projected decals are experimental, they work but not perfectly!\n" + GetInsertModeHelpString() + " them", Color.yellow, position);
                }

                EditorGUILayout.Separator();

                configSaver.parameters.showProjectedDecalsConfigOptions = EditorGUILayout.Foldout(configSaver.parameters.showProjectedDecalsConfigOptions, new GUIContent("Show projected decals configuration options", "Show projected decals configuration options"));

                if (!configSaver.parameters.showProjectedDecalsConfigOptions)
                {
                    EditorGUILayout.Separator();
                }
                else
                {
                    EditorBasicFunctions.DrawEditorBox("Configuration", Color.yellow, position);

                    EditorGUILayout.Separator();

                    decal.attachToCollisionObject = EditorGUILayout.Toggle(new GUIContent("Attach to father", "Attach created decal to hit object"), decal.attachToCollisionObject);

                    if (comeFromEditor)
                    {
                        EditorGUILayout.Separator();

                        decal.scaleRange   = EditorGUILayout.Vector2Field(new GUIContent("Scale range", "Randomize decal scale between 2 values"), decal.scaleRange, new GUILayoutOption[] { GUILayout.Width(0.5f * position.width) });
                        decal.scaleRange.x = Mathf.Clamp(decal.scaleRange.x, 0.01f, 10);
                        decal.scaleRange.y = Mathf.Clamp(decal.scaleRange.y, 0.01f, 10);

                        EditorGUILayout.Separator();

                        decal.rotationRange   = EditorGUILayout.Vector2Field(new GUIContent("Rotation range", "Randomize decal rotation between 2 values"), decal.rotationRange, new GUILayoutOption[] { GUILayout.Width(0.5f * position.width) });
                        decal.rotationRange.x = Mathf.Clamp(decal.rotationRange.x, 0, 360);
                        decal.rotationRange.y = Mathf.Clamp(decal.rotationRange.y, 0, 360);
                    }

                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();
                }

                EditorBasicFunctions.DrawEditorBox("Choose projected decal!", Color.white, position);
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                decal.material = EditorBasicFunctions.ShowObjectField <Material> ("Actual selected material ", decal.material);

                decal.material = EditorBasicFunctions.DrawProjectedDecalMaterialList(decal.material, Screen.width);

                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                if (decal.material)
                {
                    List <Sprite> spriteListFromTexture = EditorBasicFunctions.GetSpriteListFromTexture(decal.material.mainTexture);

                    if (spriteListFromTexture.Count > 0)
                    {
                        decal.sprite = spriteListFromTexture [0];
                    }

                    if (!comeFromEditor)
                    {
                        EditorBasicFunctions.DrawEditorBox("Info", Color.white, position);

                        EditorGUILayout.Separator();
                    }

                    return(decal.material);
                }
            }


            return(null);
        }