///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawGeneralOptions
        /// # Draw the basic general options
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void DrawGeneralOptions()
        {
            if (systemMode == cSystemMode.edition)
            {
                configSaver.parameters.showBasicGeneralOptions = EditorGUILayout.Foldout(configSaver.parameters.showBasicGeneralOptions, new GUIContent("General options", "Show general options"));

                if (configSaver.parameters.showBasicGeneralOptions)
                {
                    EditorBasicFunctions.DrawEditorBox("General options", Color.yellow, position);

                    // basic actions only in edition mode?
                    configSaver.parameters.showBasicActionsAlways = EditorGUILayout.Toggle(new GUIContent("Basic actions always", "Attach created decal to hit object"), configSaver.parameters.showBasicActionsAlways);

                    // advanced actions only in edition mode?
                    configSaver.parameters.showAdvancedActionsAlways = EditorGUILayout.Toggle(new GUIContent("Advanced actions always", "Attach created decal to hit object"), configSaver.parameters.showAdvancedActionsAlways);

                    // show help?
                    configSaver.parameters.hideBasicHelp = EditorGUILayout.Toggle(new GUIContent("Hide basic help", "Hide basic help"), configSaver.parameters.hideBasicHelp);

                    // insert mode
                    EditorGUILayout.Separator();
                    insertMode = (cInsertMode)EditorGUILayout.EnumPopup(new GUIContent("Insert mode", "Select the way to insert decals or prefabs using keyboard and mouse"), insertMode, new GUILayoutOption[] { GUILayout.Width(0.81f * position.width) });


                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();
                    EditorBasicFunctions.DrawLineSeparator();
                }
            }
        }
예제 #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// OnInspectorGUI
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        public override void OnInspectorGUI()
        {
            GenericMeshDecal decal = (GenericMeshDecal)target;

            bool updateShape = false;

            if (decal.material)
            {
                string actualMaterialName = decal.material.name;

                decal.material = EditorBasicFunctions.DrawMeshDecalElements(decal, false, new Rect(0, 0, EditorGUIUtility.currentViewWidth, EditorGUIUtility.singleLineHeight), null);

                if (decal.material.name != actualMaterialName)
                {
                    updateShape = true;

                    //Debug.Log ("Material Change: "+decal.material);
                    decal.GetComponent <Renderer>().sharedMaterial = decal.material;
                }
            }

            if (GUI.changed || updateShape)
            {
                decal.UpdateDecallShape(false, false);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawBasics
        /// # Draw basics
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void DrawBasics()
        {
            EditorGUILayout.Separator();

            EditorBasicFunctions.DrawActualVersion(position);

            EditorGUILayout.Separator();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// SaveAllGenericDecalMeshesDoDisk
        /// # Save all generic decal meshes to disk
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void SaveAllGenericDecalMeshesDoDisk()
        {
            string savingPath = BasicDefines.MAIN_PATH + "Saved/GenericDecalMeshes/";

            Directory.CreateDirectory(savingPath);

            List <Object> actualMeshesInSavingFolderList = EditorBasicFunctions.GetObjectListFromDirectory(savingPath, ".asset");


            string savingBaseName = "GenericMeshDecal_savedMesh_";

            int lastDetectedIndex = 1;

            for (int i = 0; i < actualMeshesInSavingFolderList.Count; i++)
            {
                string actualName        = actualMeshesInSavingFolderList[i].name;
                string actualIndexString = "";

                for (int j = actualName.Length - 1; j >= 0; j--)
                {
                    string actualSubString = actualName.Substring(j, 1);

                    if (actualSubString == "_")
                    {
                        break;
                    }
                    else
                    {
                        actualIndexString = actualSubString + actualIndexString;
                    }
                }

                if (actualName.Length > 0)
                {
                    //Debug.Log ("actualIndexString: " + actualIndexString);

                    int actualIndex = -1;

                    int.TryParse(actualIndexString, out actualIndex);

                    if (actualIndex > lastDetectedIndex)
                    {
                        lastDetectedIndex = actualIndex;
                    }
                }
            }

            //Debug.Log ("lastDetectedIndex: " + lastDetectedIndex);

            foreach (GenericMeshDecal decal in GameObject.FindObjectsOfType <GenericMeshDecal>())
            {
                lastDetectedIndex++;

                Mesh actualMesh = decal.GetComponent <MeshFilter>().sharedMesh;
                AssetDatabase.CreateAsset(actualMesh, savingPath + savingBaseName + lastDetectedIndex + ".asset"); // saves to "assets/"
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// OnGUI
        /// # Handle OnGUI
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void OnGUI()
        {
            GUILayout.BeginArea(new Rect(0.0f * position.width, 0, 1f * position.width, position.height));


            DrawBasics();
            DrawModeButtons();

            EditorBasicFunctions.DrawLineSeparator();

            windowPosition = EditorGUILayout.BeginScrollView(windowPosition, false, false);

            DrawGeneralOptions();
            DrawBasicButtons();
            DrawAdvancedButtons();
            DrawExtraOptions();


            // draw specifics modes
            switch (systemMode)
            {
            case cSystemMode.edition:
            {
                DrawEditionMode();
            }
            break;

            case cSystemMode.meshDecals:
            {
                DrawMeshDecalsMode();
            }
            break;

            case cSystemMode.projectedDecals:
            {
                DrawProjectedDecalsMode();
            }
            break;

            case cSystemMode.objects:
            {
                DrawObjectsMode();
            }
            break;
            }

            EditorGUILayout.EndScrollView();
            GUILayout.EndArea();

            // save config
            if (configSaver != null)
            {
                configSaver.SaveConfig();
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawModeButtons
        /// # Draw editor mode buttons
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void DrawModeButtons()
        {
            // create mode buttons
            EditorGUILayout.Separator();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            float buttonsScale = position.width / 6;

            // separator
            EditorBasicFunctions.GetEditorButton("EmptyButton", "", new Vector2(0.1f * buttonsScale, buttonsScale), false, true, true, true);

            if (EditorBasicFunctions.GetEditorButton("EditionModeButton", "Select 'Edit Mode'", new Vector2(buttonsScale, buttonsScale), (systemMode == cSystemMode.edition), true, false, false))
            {
                systemMode = cSystemMode.edition;
            }

            // separator
            EditorBasicFunctions.GetEditorButton("EmptyButton", "", new Vector2(0.1f * buttonsScale, buttonsScale), false, true, true, true);

            if (EditorBasicFunctions.GetEditorButton("PutMeshDecalsButton", "Select 'Mesh Decals Mode'", new Vector2(buttonsScale, buttonsScale), (systemMode == cSystemMode.meshDecals), true, false, false))
            {
                systemMode = cSystemMode.meshDecals;
            }

            // separator
            EditorBasicFunctions.GetEditorButton("EmptyButton", "", new Vector2(0.1f * buttonsScale, buttonsScale), false, true, true, true);

            if (EditorBasicFunctions.GetEditorButton("PutObjectsButton", "Select 'Insert Objects Mode'", new Vector2(buttonsScale, buttonsScale), (systemMode == cSystemMode.objects), true, false, false))
            {
                systemMode = cSystemMode.objects;
            }

            // separator
            EditorBasicFunctions.GetEditorButton("EmptyButton", "", new Vector2(0.1f * buttonsScale, buttonsScale), false, true, true, true);

            if (EditorBasicFunctions.GetEditorButton("PutProjectedDecalsButton", "Select 'Insert Projected Decals Mode'", new Vector2(buttonsScale, buttonsScale), (systemMode == cSystemMode.projectedDecals), true, false, false))
            {
                systemMode = cSystemMode.projectedDecals;
            }

            GUILayout.FlexibleSpace();
            EditorBasicFunctions.GetEditorButton("EmptyButton", "", new Vector2(0.1f * buttonsScale, buttonsScale), false, true, true, true);


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

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawProjectedDecalsMode
        /// # Draw al gui buttons, checboxes, ... to handle and insert projected decals in scene
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void DrawProjectedDecalsMode()
        {
            Material actualMaterial = EditorBasicFunctions.DrawProjectedDecalElements(projectedDecalPrefab, true, position, configSaver);

            if (actualMaterial)
            {
                EditorBasicFunctions.DrawEditorBox(actualMaterial.name, Color.yellow, position);
            }
            else
            {
                EditorBasicFunctions.DrawEditorBox("No projected decal selected to put!", Color.gray, position);
            }
        }
		///////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// DrawEditionMode
		/// # Draw al gui buttons, checboxes, ... to handle edition mode
		/// </summary>
		///////////////////////////////////////////////////////////////////////////////////////////////////////
		void DrawEditionMode ()
		{				
			if (!configSaver.parameters.hideBasicHelp)
			{
				EditorBasicFunctions.DrawEditorBox ("Use 'Edit Mode' to edit decals or objects, to clean scripts in the scene or to create new decals", Color.yellow, position);
			}

			EditorGUILayout.Separator ();
						
					
			EditorBasicFunctions.DrawEditorBox ("Edit the scene!", Color.white, position);	
			
			EditorGUILayout.Separator ();

			GameObject actualSelectedObject = Selection.activeGameObject;
			
			
			if (actualSelectedObject)
			{														
				GenericMeshDecal actualDecal = actualSelectedObject.GetComponent ("GenericMeshDecal") as GenericMeshDecal;
				GenericObject actualObject = actualSelectedObject.GetComponent ("GenericObject") as GenericObject;
				
				if (actualDecal)
				{
					EditorBasicFunctions.DrawEditorBox ("Selected decal: " + actualSelectedObject.name, Color.yellow, position);
										
					var editor = Editor.CreateEditor (actualDecal);
					editor.OnInspectorGUI ();            
				}
				else if (actualObject)
				{
					EditorBasicFunctions.DrawEditorBox ("Selected object: " + actualSelectedObject.name, Color.yellow, position);	
				}
				else
				{
					EditorBasicFunctions.DrawEditorBox ("Not editable object: " + actualSelectedObject.name, Color.gray, position);	
				}
			}
			else
			{
				EditorBasicFunctions.DrawEditorBox ("Nothing selected!", Color.black, position);	
			}
		}
예제 #9
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// CreateNewDecal
        /// # Create new decal
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void CreateNewDecal()
        {
            string   actualFolderName = "";
            Material originalMaterial = null;

            switch (createDecalType)
            {
            case cCreateDecalType.fade:
            {
                actualFolderName = fadeFolderNameList [actualCreateDecalFadeFolderIndex];
                originalMaterial = AssetDatabase.LoadAssetAtPath(BasicDefines.MAIN_PATH + "Paintable/MeshDecals/Materials/System/GenericFadeMaterial.mat", typeof(Material)) as Material;
            }
            break;

            case cCreateDecalType.cutout:
            {
                actualFolderName = cutOutFolderNameList [actualCreateDecalCutOutFolderIndex];
                originalMaterial = AssetDatabase.LoadAssetAtPath(BasicDefines.MAIN_PATH + "Paintable/MeshDecals/Materials/System/GenericCutOutMaterial.mat", typeof(Material)) as Material;
            }
            break;
            }

            Material materialCopy = new Material(originalMaterial);

            AssetDatabase.CreateAsset(materialCopy, BasicDefines.MAIN_PATH + "Paintable/MeshDecals/Materials/" + actualFolderName + "/" + createDecalName + ".mat");

            materialCopy.SetColor("_Color", Color.white);
            materialCopy.SetTexture("_MainTex", createDecalTexture_albedo);
            materialCopy.SetTexture("_BumpMap", createDecalTexture_normal);
            materialCopy.SetTexture("_EmissionMap", createDecalTexture_emission);


            EditorBasicFunctions.RefreshLists();
            AssetDatabase.Refresh();


            // the material has changed
            MaterialChangeManager.MaterialChanged(materialCopy);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// LoadBasics
        /// # Load basics
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        protected void LoadBasics()
        {
            configSaver = new ConfigSaver();


            meshDecalPrefab = AssetDatabase.LoadAssetAtPath(BasicDefines.MESH_DECAL_PREFAB_PATH, typeof(GenericMeshDecal)) as GenericMeshDecal;

            if (!meshDecalPrefab)
            {
                Debug.Log("NOTE -> no meshDecalPrefab, verify folder: " + BasicDefines.MESH_DECAL_PREFAB_PATH);
            }

            projectedDecalPrefab = AssetDatabase.LoadAssetAtPath(BasicDefines.PROJECTED_DECAL_PREFAB_PATH, typeof(GenericProjectorDecal)) as GenericProjectorDecal;

            if (!projectedDecalPrefab)
            {
                Debug.Log("NOTE -> no projectedDecalPrefab, verify folder: " + BasicDefines.MESH_DECAL_PREFAB_PATH);
            }

            if (EditorBasicFunctions.GetPrefabList().Count > 0)
            {
                genericObject = EditorBasicFunctions.GetPrefabList()[0];
            }
        }
예제 #11
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// HandleObjectsMode
        /// # To insert objects in scene using mouse
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void HandleObjectsMode()
        {
            if ((GetEditorTimeDiff() > 0.1f) && EditorBasicFunctions.GetMouseButtonDown(0) && EditorBasicFunctions.GetInsertModeKeyPressed() && !GetDoingSomethingSpecial())
            {
                previousEditorTime = EditorApplication.timeSinceStartup;

                Ray        ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit))
                {
                    if (lastPrefabHitPoint.ToString() == hit.point.ToString())
                    {
                        //Debug.Log ("NOTE: same point duplicate -> lastPrefabHitPoint: " + lastPrefabHitPoint);
                    }
                    else
                    {
                        //Debug.Log ("lastPrefabHitPoint A: " + lastPrefabHitPoint);

                        lastPrefabHitPoint = hit.point;

                        //Debug.Log ("New Object");
                        //Debug.Log ("Hit position: " + hit.point);
                        //Debug.Log ("Collider Name: " + hit.collider.name);

                        GameObject actualObject = Instantiate(genericObject);

                        switch (pivotMode)
                        {
                        case cPivotMode.useOriginalPivot:
                        {
                            actualObject.transform.position = hit.point + extraNormalOffset * hit.normal;
                        }
                        break;

                        case cPivotMode.autoCalculate:
                        {
                            MeshFilter actualMeshFilter = BasicFunctions.GetMeshFilterInChilds(actualObject.transform);

                            if (actualMeshFilter == null)
                            {
                                actualObject.transform.position = hit.point + extraNormalOffset * hit.normal;
                            }
                            else
                            {
                                float pivotOffset = extraNormalOffset + 0.5f * (Mathf.Abs(actualMeshFilter.sharedMesh.bounds.max.y) + Mathf.Abs(actualMeshFilter.sharedMesh.bounds.min.y));

                                //Debug.Log ("pivotOffset: " + pivotOffset);
                                //Debug.Log ("max: " + actualMeshFilter.sharedMesh.bounds.max);
                                //Debug.Log ("min: " + actualMeshFilter.sharedMesh.bounds.min);
                                //Debug.Log ("Center: " + actualMeshFilter.sharedMesh.bounds.center);

                                actualObject.transform.position = hit.point + pivotOffset * hit.normal;
                            }
                        }
                        break;
                        }

                        actualObject.transform.localScale = Random.Range(objectScaleRange.x, objectScaleRange.y) * actualObject.transform.localScale;
                        actualObject.transform.rotation   = Quaternion.FromToRotation(Vector3.up, hit.normal);
                        actualObject.transform.Rotate(genericObject.transform.rotation.eulerAngles);
                        actualObject.transform.Rotate(Random.Range(objectRotationRangeX.x, objectRotationRangeX.y), Random.Range(objectRotationRangeY.x, objectRotationRangeY.y), Random.Range(objectRotationRangeZ.x, objectRotationRangeZ.y));

                        if (attachObjectToCollisionObject)
                        {
                            actualObject.transform.parent = hit.collider.transform;
                        }
                        else
                        {
                            GameObject objectsContainer = BasicFunctions.CreateContainerIfNotExists(BasicDefines.OBJECT_CONTAINER_NAME);
                            actualObject.transform.parent = objectsContainer.transform;
                        }

                        actualObject.AddComponent <GenericObject> ();

                        actualObject.name = actualObject.GetComponent <GenericObject> ().Generate(BasicDefines.OBJECT_BASE_NAME, GetSeedForInstancies(), true, genericObject.name);

                        actualObjectToForceSelect = actualObject.gameObject;
                    }
                }
            }
        }
예제 #12
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawObjectsMode
        /// # Draw al gui buttons, checboxes, ... to handle and insert objects in scene
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void DrawObjectsMode()
        {
            EditorBasicFunctions.DrawEditorBox("Insert objects: Options", Color.white, position);

            if (!configSaver.parameters.hideBasicHelp)
            {
                EditorBasicFunctions.DrawEditorBox(EditorBasicFunctions.GetInsertModeHelpString() + " objects", Color.yellow, position);
            }

            EditorGUILayout.Separator();

            configSaver.parameters.showPrefabConfigOptions = EditorGUILayout.Foldout(configSaver.parameters.showPrefabConfigOptions, new GUIContent("Show prefab configuration options", "Show prefab configuration options"));

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

                EditorGUILayout.Separator();

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

                extraNormalOffset = EditorGUILayout.Slider(new GUIContent("Extra normal offset", "Set the extra offset using hit normal"), extraNormalOffset, -10, 10, new GUILayoutOption[] { GUILayout.Width(0.81f * position.width) });
                extraNormalOffset = Mathf.Clamp(extraNormalOffset, -10, 10);

                pivotMode = (cPivotMode)EditorGUILayout.EnumPopup(new GUIContent("Pivot mode", "Select the pivot mode to positionate prefab using hit normal"), pivotMode, new GUILayoutOption[] { GUILayout.Width(0.81f * position.width) });
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

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

                EditorGUILayout.Separator();

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

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

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

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

            EditorBasicFunctions.DrawEditorBox("Choose prefab!", Color.white, position);

            genericObject = EditorBasicFunctions.DrawPrefabList(genericObject, position);

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

            if (genericObject)
            {
                EditorBasicFunctions.DrawEditorBox(genericObject.name, Color.yellow, position);
            }
            else
            {
                EditorBasicFunctions.DrawEditorBox("No object selected to put!", Color.gray, position);
            }
        }
예제 #13
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawEditionMode
        /// # Draw al gui buttons, checboxes, ... to handle edition mode
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void DrawExtraOptions()
        {
            bool drawThis = true;

            if (systemMode != cSystemMode.edition)
            {
                drawThis = false;
            }

            if (drawThis)
            {
                configSaver.parameters.showExtraOptions = EditorGUILayout.Foldout(configSaver.parameters.showExtraOptions, new GUIContent("Extra options", "Show extra options"));

                if (configSaver.parameters.showExtraOptions)
                {
                    EditorBasicFunctions.DrawEditorBox("Extra options", Color.yellow, position);

                    if (splineDecalModeEnabled)
                    {
                        if (!configSaver.parameters.hideBasicHelp)
                        {
                            EditorGUILayout.HelpBox("You can insert new waypoints using actual selected insert mode. Once you create waypoints just select one decal to make it to follow a path", MessageType.Info);
                        }

                        EditorGUILayout.Separator();

                        closedWaypointSpline = EditorGUILayout.Toggle(new GUIContent("Closed spline", "Close the spline to finish in the initial point"), closedWaypointSpline);
                        loopWaypointSpline   = EditorGUILayout.Toggle(new GUIContent("Loop spline", "Update position in a cotinuous loop"), loopWaypointSpline);

                        EditorGUILayout.Separator();

                        // build spline decal
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();

                        if (EditorBasicFunctions.GetEditorTextButton("BUILD SPLINE DECAL", "Create a spline decal using actual waypoints", position))
                        {
                            List <WayPoint> wayPointList = new List <WayPoint> ();
                            List <Object>   objectList   = GameObject.FindObjectsOfType(typeof(WayPoint)).ToList();

                            for (int i = 0; i < objectList.Count; i++)
                            {
                                wayPointList.Add(objectList [i] as WayPoint);
                            }

                            wayPointList = wayPointList.OrderBy(x => x.index).ToList();

                            if (wayPointList.Count >= 2)
                            {
                                if (Selection.gameObjects.Count() == 1)
                                {
                                    GenericPathFollower actualPathFollower = Selection.gameObjects [0].GetComponent <GenericPathFollower> ();

                                    if (!actualPathFollower)
                                    {
                                        actualPathFollower = Selection.gameObjects [0].gameObject.AddComponent <GenericPathFollower> ();
                                    }

                                    actualPathFollower.Create(wayPointList, closedWaypointSpline, loopWaypointSpline);
                                }
                                else
                                {
                                    EditorUtility.DisplayDialog("WARNING", "Please, select one object only", "OK");
                                }
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("WARNING", "Please, insert at least two waypoints", "OK");
                            }
                        }

                        // remove waypoints
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();

                        if (EditorBasicFunctions.GetEditorTextButton("REMOVE ALL WAYPOINTS", "Remove all waypoins in scene", position))
                        {
                            GameObject wpContainer = GameObject.Find("_DECAL_WAYPOINTS");
                            DestroyImmediate(wpContainer);

                            List <WayPoint> wayPointList = new List <WayPoint> ();
                            List <Object>   objectList   = GameObject.FindObjectsOfType(typeof(WayPoint)).ToList();

                            for (int i = 0; i < objectList.Count; i++)
                            {
                                wayPointList.Add(objectList [i] as WayPoint);
                            }

                            foreach (WayPoint wp in wayPointList)
                            {
                                DestroyImmediate(wp.gameObject);
                            }
                        }

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

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

                        EditorGUILayout.Separator();


                        // leave spline decal mode
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();

                        if (EditorBasicFunctions.GetEditorTextButton("LEAVE", "Leave spline decal mode", position))
                        {
                            splineDecalModeEnabled = false;
                        }

                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.Separator();

                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();

                        if (EditorBasicFunctions.GetEditorTextButton("SPLINE DECAL MODE", "Go to spline decal mode", position))
                        {
                            splineDecalModeEnabled = true;
                        }

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


                    EditorGUILayout.Separator();

                    EditorBasicFunctions.DrawLineSeparator();
                }
            }
        }
예제 #14
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// OnGUI
        /// # Handle OnGUI
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void OnGUI()
        {
            // resize
            if (resizeIfNeeded && ((position.width != 320) || (position.height != 280)))
            {
                resizeIfNeeded = false;

                Rect actualPosition = position;

                actualPosition.width  = 320;
                actualPosition.height = 280;

                position = actualPosition;
            }

            GUILayout.BeginArea(new Rect(0.0f * position.width, 0, position.width, position.height));

            // title
            EditorGUILayout.Separator();
            EditorBasicFunctions.DrawEditorBox("Merge decals", Color.yellow, position);
            EditorGUILayout.Separator();

            deleteOldDecals = EditorGUILayout.Toggle(new GUIContent("Delete old decals", "Delete selected decals once the new gameobject is created"), deleteOldDecals);


            // decal name
            EditorGUILayout.Separator();

            GUILayout.BeginHorizontal();

            EditorGUILayout.LabelField(new GUIContent("Merged name", "Once merge the name of the create gameobject"), new GUILayoutOption[] { GUILayout.Width(100) });
            mergedObjectName = EditorGUILayout.TextArea(mergedObjectName, new GUILayoutOption[] { GUILayout.Width(200) });

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


            // create button
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            // merge selected
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button(new GUIContent("MERGE SELECTED", "Merge actual selected decals"), new GUILayoutOption[] { GUILayout.Height(32) }))
            {
                MergeActualSelectedDecals();
                Close();
            }

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


            // merge all
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button(new GUIContent("MERGE ALL", "Merge all decals in the scene. Use with cauttion!"), new GUILayoutOption[] { GUILayout.Height(32) }))
            {
                MergeAllDecals();
                Close();
            }

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


            GUILayout.EndArea();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawObjectlList
        /// # Draw actual selectable prefab list (looking inside it's folder) and handle dev's selections
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        public static GameObject DrawPrefabList(GameObject actualGameObject, Rect position)
        {
            // save actual gui color
            Color actualGuiColor = GUI.color;
            Color bgColor        = GUI.backgroundColor;

            GameObject selectedGameObject = actualGameObject;

            EditorGUILayout.Separator();

            // get actual prefab list
            bool redoTheList = false;

            for (int i = 0; i < prefabList.Count; i++)
            {
                if (AssetDatabase.GetAssetPath(prefabList [i]).Length < 2)
                {
                    redoTheList = true;
                }
            }

            if (redoTheList)
            {
                Debug.Log("Prefab deleted, redo prefab decal list");
            }

            if ((prefabList.Count <= 0) || redoTheList)
            {
                prefabList = EditorBasicFunctions.GetPrefabList();
            }

            // calculate paths
            List <string> localTotalGameObjectPathList = new List <string> ();

            for (int i = 0; i < prefabList.Count; i++)
            {
                string totalPath  = AssetDatabase.GetAssetPath(prefabList [i]);
                string actualPath = Path.GetDirectoryName(totalPath);

                int index = 0;

                for (int j = 0; j < actualPath.Length; j++)
                {
                    if (actualPath [j] == '/')
                    {
                        index = j;
                    }
                }

                string finalPath = actualPath.Substring(index + 1, actualPath.Length - index - 1);

                localTotalGameObjectPathList.Add(finalPath);
            }

            List <string> localGameObjectPathList = localTotalGameObjectPathList.Distinct().ToList();

            if (!showSystemFolders)
            {
                localGameObjectPathList.Remove("System");
            }

            //print ("------------------------------------------");
            //for (int i = 0; i < localGameObjectPathList.Count; i++)
            //{
            //print (localGameObjectPathList [i]);
            //}

            EditorGUILayout.Separator();
            GenericObject.actualFolderIndex = EditorGUILayout.Popup(GenericObject.actualFolderIndex, localGameObjectPathList.ToArray(), new GUILayoutOption[] { GUILayout.Width(0.81f * position.width) });

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (EditorBasicFunctions.GetEditorTextButton("Refresh", "Refresh the list, just in case", position))
            {
                RefreshLists();
            }

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

            EditorGUILayout.Separator();

            string selectedGameObjectPath = BasicDefines.NOT_DEFINED;

            if (localGameObjectPathList.Count > 0)
            {
                selectedGameObjectPath = localGameObjectPathList [GenericObject.actualFolderIndex];
            }


            // test some things
            int        numberOfObjectsPerLine = 4;
            int        cont  = 0;
            bool       begin = false;
            bool       actualSelectedElementIsInSelectedPathList = false;
            GameObject firstElementInActualPath = null;


            // draw objects in editor window
            for (int i = 0; i < Mathf.Ceil((float)prefabList.Count); i++)
            {
                if (localTotalGameObjectPathList [i] == selectedGameObjectPath)
                {
                    if (firstElementInActualPath == null)
                    {
                        firstElementInActualPath = prefabList [i];
                    }

                    if ((selectedGameObject == prefabList [i]))
                    {
                        actualSelectedElementIsInSelectedPathList = true;
                    }

                    if (cont % numberOfObjectsPerLine == 0)
                    {
                        GUILayout.BeginHorizontal();
                        begin = true;
                    }

                    Texture previsualization = BasicFunctions.GetThumbnail(prefabList [i]);

                    Texture unityPreview = AssetPreview.GetAssetPreview(actualGameObject);

                    if (unityPreview)
                    {
                        //previsualization = unityPreview;
                    }

                    if (actualGameObject == prefabList [i])
                    {
                        GUI.color           = new Color(1, 1, 1, 1);
                        GUI.backgroundColor = new Color(0.6f, 0.0f, 0.6f, 1f);
                    }
                    else
                    {
                        GUI.color           = new Color(1, 1, 1, 1f);
                        GUI.backgroundColor = new Color(1, 1, 1, 0.3f);
                    }

                    float buttonsScale = 0.94f * position.width / (numberOfObjectsPerLine + 0.3f);

                    bool selected = GUILayout.Button(new GUIContent(previsualization, prefabList [i].name), new GUILayoutOption[] {
                        GUILayout.Width(buttonsScale),
                        GUILayout.Height(buttonsScale)
                    });


                    if (selected)
                    {
                        selectedGameObject = prefabList [i];
                    }

                    if (cont % numberOfObjectsPerLine == numberOfObjectsPerLine - 1)
                    {
                        GUILayout.EndHorizontal();
                        begin = false;
                    }

                    cont++;
                }
            }

            if (!actualSelectedElementIsInSelectedPathList)
            {
                //print ("Change to firstElementInActualPath: " + firstElementInActualPath.name);
                selectedGameObject = firstElementInActualPath;
            }

            if (begin)
            {
                EditorGUILayout.EndHorizontal();
            }

            // restore Gui Color
            GUI.color           = actualGuiColor;
            GUI.backgroundColor = bgColor;


            //return selected game object
            return(selectedGameObject);
        }
예제 #16
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// HandleAllElementsEdition
        /// # To edit objects in scene using Unity controls
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void HandleExtraOptions()
        {
            if (splineDecalModeEnabled && (systemMode == cSystemMode.edition) && (GetEditorTimeDiff() > 0.1f) && EditorBasicFunctions.GetMouseButtonDown(0) && EditorBasicFunctions.GetInsertModeKeyPressed() && !GetDoingSomethingSpecial())
            {
                previousEditorTime = EditorApplication.timeSinceStartup;

                AddAWayPointWithMouse();
            }
        }
예제 #17
0
 ///////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// DrawActualVersion
 /// # Draw actual ADAOPS version
 /// </summary>
 ///////////////////////////////////////////////////////////////////////////////////////////////////////
 public static void DrawActualVersion(Rect position)
 {
     EditorBasicFunctions.DrawEditorBox("ADAOPS [v" + BasicDefines.VERSION + "]", Color.white, position);
 }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <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);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <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);
        }
예제 #20
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// OnGUI
        /// # Handle OnGUI
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void OnGUI()
        {
            // resize
            if (resizeIfNeeded && ((position.width != 320) || (position.height != 280)))
            {
                resizeIfNeeded = false;

                Rect actualPosition = position;

                actualPosition.width  = 320;
                actualPosition.height = 280;

                position = actualPosition;
            }


            DirectoryInfo actualDirInfo = new DirectoryInfo(BasicDefines.MAIN_PATH + "Paintable/MeshDecals/Materials/");

            if ((fadeFolderNameList.Count <= 0) || (cutOutFolderNameList.Count <= 0))
            {
                for (int i = 0; i < actualDirInfo.GetDirectories().Count(); i++)
                {
                    string actualName = actualDirInfo.GetDirectories() [i].Name;
                    //Debug.Log(actualName);

                    if (actualName.Length > 1)
                    {
                        if ((actualName.Length > 7) && actualName.Substring(0, 7) == "[Fade] ")
                        {
                            fadeFolderNameList.Add(actualDirInfo.GetDirectories() [i].Name);
                        }
                        else
                        {
                            cutOutFolderNameList.Add(actualDirInfo.GetDirectories() [i].Name);
                        }
                    }
                }
            }

            GUILayout.BeginArea(new Rect(0.0f * position.width, 0, position.width, position.height));

            // title
            EditorGUILayout.Separator();
            EditorBasicFunctions.DrawEditorBox("Create a new decal", Color.yellow, position);
            EditorGUILayout.Separator();


            // type
            GUILayout.BeginHorizontal();

            GUILayout.Label("Mode");
            createDecalType = (cCreateDecalType)EditorGUILayout.EnumPopup(createDecalType);

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

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


            // texture albedo
            EditorGUILayout.Separator();

            GUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Albedo", new GUILayoutOption[] { GUILayout.Width(100) });
            createDecalTexture_albedo = EditorGUILayout.ObjectField(createDecalTexture_albedo, typeof(Texture), true, new GUILayoutOption[] { GUILayout.Width(200) }) as Texture;

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


            // texture normal
            EditorGUILayout.Separator();

            GUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Normal", new GUILayoutOption[] { GUILayout.Width(100) });
            createDecalTexture_normal = EditorGUILayout.ObjectField(createDecalTexture_normal, typeof(Texture), true, new GUILayoutOption[] { GUILayout.Width(200) }) as Texture;

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



            // texture albedo
            EditorGUILayout.Separator();

            GUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Emission", new GUILayoutOption[] { GUILayout.Width(100) });
            createDecalTexture_emission = EditorGUILayout.ObjectField(createDecalTexture_emission, typeof(Texture), true, new GUILayoutOption[] { GUILayout.Width(200) }) as Texture;

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



            // decal name
            EditorGUILayout.Separator();

            GUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Decal name", new GUILayoutOption[] { GUILayout.Width(100) });
            createDecalName = EditorGUILayout.TextArea(createDecalName, new GUILayoutOption[] { GUILayout.Width(200) });

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


            // folder
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            GUILayout.BeginHorizontal();

            GUILayout.Label("Folder");

            switch (createDecalType)
            {
            case cCreateDecalType.fade:
            {
                actualCreateDecalFadeFolderIndex = EditorGUILayout.Popup(actualCreateDecalFadeFolderIndex, fadeFolderNameList.ToArray(), new GUILayoutOption[] { GUILayout.Width(200) });
            }
            break;

            case cCreateDecalType.cutout:
            {
                actualCreateDecalCutOutFolderIndex = EditorGUILayout.Popup(actualCreateDecalCutOutFolderIndex, cutOutFolderNameList.ToArray(), new GUILayoutOption[] { GUILayout.Width(200) });
            }
            break;
            }

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


            // create button
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("CREATE", new GUILayoutOption[] { GUILayout.Height(32) }))
            {
                if (createDecalTexture_albedo)
                {
                    CreateNewDecal();
                    Close();
                }
                else
                {
                    EditorUtility.DisplayDialog("ERROR", "You need a texture to create a decal", "OK");
                }
            }

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


            GUILayout.EndArea();
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// HandleProjectedDecalsMode
        /// # To insert projected decals in scene using mouse
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void HandleProjectedDecalsMode()
        {
            if ((GetEditorTimeDiff() > 0.1f) && EditorBasicFunctions.GetMouseButtonDown(0) && EditorBasicFunctions.GetInsertModeKeyPressed() && !GetDoingSomethingSpecial())
            {
                previousEditorTime = EditorApplication.timeSinceStartup;

                //Debug.Log ("Event.current.mousePosition: " + Event.current.mousePosition);

                Ray        ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit))
                {
                    if (lastProjectedDecalsHitPoint.ToString() == hit.point.ToString())
                    {
                        //Debug.Log ("NOTE: same point duplicate -> lastProjectedDecalsHitPoint: " + lastProjectedDecalsHitPoint);
                    }
                    else
                    {
                        //Debug.Log ("lastProjectedDecalsHitPoint A: " + lastProjectedDecalsHitPoint);

                        lastProjectedDecalsHitPoint = hit.point;

                        //Debug.Log ("New Decal");
                        //Debug.Log ("Hit position: " + hit.point);
                        //Debug.Log ("Collider Name: " + hit.collider.name);

                        GenericProjectorDecal actualProjectedDecal = Instantiate(projectedDecalPrefab.gameObject).GetComponent <GenericProjectorDecal> () as GenericProjectorDecal;
                        actualProjectedDecal.SetOldParameters(projectedDecalPrefab.transform.localScale, projectedDecalPrefab.GetComponent <Projector> ().orthographicSize, projectedDecalPrefab.GetComponent <Projector> ().aspectRatio);

                        //Debug.Log (actualProjectedDecal.material.mainTexture.name);

                        actualProjectedDecal.transform.position = hit.point + 0.3f * hit.normal;

                        Vector3 finalScale = Random.Range(actualProjectedDecal.scaleRange.x, actualProjectedDecal.scaleRange.y) * actualProjectedDecal.transform.localScale;

                        float textureAspectRatio = (float)actualProjectedDecal.material.mainTexture.width / (float)actualProjectedDecal.material.mainTexture.height;

                        finalScale.x = textureAspectRatio * finalScale.x;

                        actualProjectedDecal.transform.localScale = finalScale;

                        actualProjectedDecal.transform.LookAt(hit.point);

                        actualProjectedDecal.transform.Rotate(new Vector3(0, 0, Random.Range(actualProjectedDecal.rotationRange.x, actualProjectedDecal.rotationRange.y)));

                        actualProjectedDecal.name = actualProjectedDecal.Generate(BasicDefines.PROJECTED_DECAL_BASE_NAME, GetSeedForInstancies(), true, actualProjectedDecal.material.name);

                        //Debug.Log ("actualProjectedDecal.attachToCollisionObject: " + actualProjectedDecal.attachToCollisionObject);

                        if (actualProjectedDecal.attachToCollisionObject)
                        {
                            //Debug.Log ("Parent name: " + hit.collider.name);
                            actualProjectedDecal.transform.parent = hit.collider.transform;
                        }
                        else
                        {
                            GameObject decalsContainer = BasicFunctions.CreateContainerIfNotExists(BasicDefines.PROJECTED_DECAL_CONTAINER_NAME);
                            actualProjectedDecal.transform.parent = decalsContainer.transform;
                        }

                        actualProjectedDecal.UpdateShape();

                        actualObjectToForceSelect = actualProjectedDecal.gameObject;
                    }
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawAdvancedButtons
        /// # Draw all advanced buttons
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void DrawAdvancedButtons()
        {
            bool drawThis = true;

            if (!configSaver.parameters.showAdvancedActionsAlways && (systemMode != cSystemMode.edition))
            {
                drawThis = false;
            }

            if (drawThis)
            {
                configSaver.parameters.showAdvancedActions = EditorGUILayout.Foldout(configSaver.parameters.showAdvancedActions, new GUIContent("Advanced actions", "Show advanced actions"));

                if (configSaver.parameters.showAdvancedActions)
                {
                    EditorBasicFunctions.DrawEditorBox("Advanced actions", Color.yellow, position);

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

                    float buttonsScale = position.width / 6;

                    if (cleanAlSceneScriptsConfirmationMode)
                    {
                        EditorBasicFunctions.DrawEditorBox("Do you really want to clean all the scripts?", Color.white, position);

                        // clean all scripts
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();

                        if (EditorBasicFunctions.GetEditorButton("NoButton", "Don't clean", new Vector2(buttonsScale, buttonsScale), true, false, false, true))
                        {
                            cleanAlSceneScriptsConfirmationMode = false;
                        }

                        EditorBasicFunctions.GetEditorButton("EmptyButton", "", new Vector2(buttonsScale, buttonsScale), false, true, true, true);
                        EditorBasicFunctions.GetEditorButton("EmptyButton", "", new Vector2(buttonsScale, buttonsScale), false, true, true, true);

                        if (EditorBasicFunctions.GetEditorButton("YesButton", "Continue cleaning", new Vector2(buttonsScale, buttonsScale), true, false, false, true))
                        {
                            CleanAllSceneScriptsAction();
                            cleanAlSceneScriptsConfirmationMode = false;
                        }

                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        // clean all scripts
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();

                        if (EditorBasicFunctions.GetEditorTextButton("CLEAN SCRIPTS", "Clean all the scripts in the scene, for example to use without this editor extension in the system", position))
                        {
                            cleanAlSceneScriptsConfirmationMode = true;
                        }

                        // create new decal
                        if (EditorBasicFunctions.GetEditorTextButton("CREATE DECAL", "Create a new decal just selecting textures, type and folder", position))
                        {
                            CreateDecalWindow window = ScriptableObject.CreateInstance <CreateDecalWindow>();
                            window.name = "Create new decal";
#if UNITY_5_0
                            window.title = window.name;
#else
                            window.titleContent = new GUIContent(window.name);
#endif
                            window.Show();
                        }

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

                        EditorGUILayout.Separator();

                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();


                        // lock all future time lockable decals
                        if (EditorBasicFunctions.GetEditorTextButton("LOCK DECALS", "Mark all 'futureTimeLockableShape' decals as locked", position))
                        {
                            foreach (GenericMeshDecal actualDecal in GameObject.FindObjectsOfType <GenericMeshDecal>())
                            {
                                if (actualDecal.futureTimeLockableShape)
                                {
                                    actualDecal.lockedShapeAlways = true;
                                }
                            }
                        }

                        // merge decals
                        if (EditorBasicFunctions.GetEditorTextButton("MERGE DECALS", "Merge all selected decals into single one mesh", position))
                        {
                            MergeDecalWindow window = ScriptableObject.CreateInstance <MergeDecalWindow>();
                            window.name = "Merge new decal";
#if UNITY_5_0
                            window.title = window.name;
#else
                            window.titleContent = new GUIContent(window.name);
#endif
                            window.Show();
                        }

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

                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();
                    EditorBasicFunctions.DrawLineSeparator();
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawBasicButtons
        /// # Draw all basic buttons
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void DrawBasicButtons()
        {
            bool drawThis = true;

            if (!configSaver.parameters.showBasicActionsAlways && (systemMode != cSystemMode.edition))
            {
                drawThis = false;
            }

            if (drawThis)
            {
                configSaver.parameters.showBasicActions = EditorGUILayout.Foldout(configSaver.parameters.showBasicActions, new GUIContent("Basic actions", "Show basic actions"));

                if (configSaver.parameters.showBasicActions)
                {
                    EditorBasicFunctions.DrawEditorBox("Basic actions", Color.yellow, position);

                    float buttonsScale = position.width / 5;

                    if (deleteAllConfirmationMode)
                    {
                        EditorBasicFunctions.DrawEditorBox("Do you really want to delete all?", Color.white, position);

                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();

                        if (EditorBasicFunctions.GetEditorButton("NoButton", "Don't delete", new Vector2(buttonsScale, buttonsScale), true, false, false, true))
                        {
                            deleteAllConfirmationMode = false;
                        }

                        GUILayout.FlexibleSpace();

                        if (EditorBasicFunctions.GetEditorButton("YesButton", "Continue deleting", new Vector2(buttonsScale, buttonsScale), true, false, false, true))
                        {
                            DeleteAllAction();
                            deleteAllConfirmationMode = false;
                        }

                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.Separator();
                        EditorGUILayout.Separator();

                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();

                        if (EditorBasicFunctions.GetEditorButton("DeleteAllButton", "Delete all created objects of every mode, in edit mode delete all created objects of all modes", new Vector2(buttonsScale, buttonsScale), true, false, false, true))
                        {
                            deleteAllConfirmationMode = true;
                        }

                        GUILayout.FlexibleSpace();

                        if (EditorBasicFunctions.GetEditorButton("DeleteLastButton", "Delete last created object of every mode, in edit mode delete last create object of all modes", new Vector2(buttonsScale, buttonsScale), true, false, false, true))
                        {
                            DeleteLastAction();
                        }

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

                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();
                    EditorBasicFunctions.DrawLineSeparator();
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// HandleMeshDecalsMode
        /// # To insert mesh decals in scene using mouse
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        void HandleMeshDecalsMode()
        {
            if ((GetEditorTimeDiff() > 0.1f) && EditorBasicFunctions.GetMouseButtonDown(0) && EditorBasicFunctions.GetInsertModeKeyPressed() && !GetDoingSomethingSpecial())
            {
                previousEditorTime = EditorApplication.timeSinceStartup;

                //Debug.Log ("Event.current.mousePosition: " + Event.current.mousePosition);

                Ray        ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                RaycastHit hit;

                //Debug.Log ("-----------------------------------------------------------");

                if (Physics.Raycast(ray, out hit))
                {
                    if (lastMeshDecalsHitPoint.ToString() == hit.point.ToString())
                    {
                        //Debug.Log ("NOTE: same point duplicate -> lastMeshDecalsHitPoint: " + lastMeshDecalsHitPoint);
                    }
                    else
                    {
                        //Debug.Log ("lastMeshDecalsHitPoint A: " + lastMeshDecalsHitPoint);

                        lastMeshDecalsHitPoint = hit.point;

                        //Debug.Log ("hit.point: " + hit.point);
                        //Debug.Log ("lastMeshDecalsHitPoint B: " + lastMeshDecalsHitPoint);

                        //Debug.Log ("New Decal");
                        //Debug.Log ("Hit position: " + hit.point);
                        //Debug.Log ("Collider Name: " + hit.collider.name);

                        bool setPlanarDecal = EditorBasicFunctions.planarMeshDecals;

                        if (hit.collider.GetComponent <Terrain> ())
                        {
                            //Debug.Log ("It's a terrain, set the decal as planar");
                            setPlanarDecal = true;
                        }

                        meshDecalPrefab.planarDecal    = setPlanarDecal;
                        meshDecalPrefab.comeFromEditor = setPlanarDecal;

                        GenericMeshDecal actualDecal = Instantiate(meshDecalPrefab.gameObject).GetComponent <GenericMeshDecal> ();
                        actualDecal.transform.position = hit.point;

                        meshDecalPrefab.comeFromEditor = false;

                        Vector3 finalScale = Random.Range(actualDecal.scaleRange.x, actualDecal.scaleRange.y) * actualDecal.transform.localScale;

                        float textureAspectRatio = (float)actualDecal.material.mainTexture.width / (float)actualDecal.material.mainTexture.height;

                        if (actualDecal.GetPlanar())
                        {
                            finalScale.x = 0.5f * finalScale.x;
                            finalScale.y = textureAspectRatio * finalScale.x;
                        }
                        else
                        {
                            finalScale.x = textureAspectRatio * finalScale.x;
                        }

                        //finalScale.y = finalScale.x;
                        //finalScale.z = finalScale.x;


                        actualDecal.transform.localScale = finalScale;

                        actualDecal.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);

                        actualDecal.name = actualDecal.Generate(BasicDefines.MESH_DECAL_BASE_NAME, GetSeedForInstancies(), true, actualDecal.material.name);

                        actualDecal.UpdateDecallShape(true, false);

                        //Debug.Log ("actualDecal.attachToCollisionObject: " + actualDecal.attachToCollisionObject);

                        if (actualDecal.attachToCollisionObject)
                        {
                            //Debug.Log ("Parent name: " + hit.collider.name);
                            actualDecal.transform.parent = hit.collider.transform;
                        }
                        else
                        {
                            GameObject decalsContainer = BasicFunctions.CreateContainerIfNotExists(BasicDefines.MESH_DECAL_CONTAINER_NAME);
                            actualDecal.transform.parent = decalsContainer.transform;
                        }

                        if (actualDecal.addCollider)
                        {
                            actualDecal.gameObject.AddComponent <MeshCollider> ();
                            //actualDecal.gameObject.GetComponent<MeshCollider> ().convex = true;
                        }

                        actualObjectToForceSelect = actualDecal.gameObject;
                    }
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// DrawMeshDecalMaterialList
        /// Draw actual selectable material (looking inside it's folder) list and handle dev's selections
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        public static Material DrawMeshDecalMaterialList(Material actualMaterial, float areaWidth)
        {
            // save actual gui color
            Color actualGuiColor = GUI.color;
            Color bgColor        = GUI.backgroundColor;

            // initialise selected material to actual material
            Material selectedMaterial = actualMaterial;

            EditorGUILayout.Separator();

            // get actual material list from decal's material folder
            bool redoTheList = false;

            for (int i = 0; i < meshDecalMaterialsList.Count; i++)
            {
                if (AssetDatabase.GetAssetPath(meshDecalMaterialsList [i]).Length < 2)
                {
                    redoTheList = true;
                }
            }

            if (redoTheList)
            {
                Debug.Log("Material deleted, redo mesh decal list");
            }

            if ((meshDecalMaterialsList.Count <= 0) || redoTheList)
            {
                meshDecalMaterialsList = EditorBasicFunctions.GetMeshDecalMaterialList();
            }

            // calculate paths
            List <string> localTotalMaterialPathList = new List <string> ();

            for (int i = 0; i < meshDecalMaterialsList.Count; i++)
            {
                string totalPath  = AssetDatabase.GetAssetPath(meshDecalMaterialsList [i]);
                string actualPath = Path.GetDirectoryName(totalPath);

                int index = 0;

                for (int j = 0; j < actualPath.Length; j++)
                {
                    if (actualPath [j] == '/')
                    {
                        index = j;
                    }
                }

                string finalPath = actualPath.Substring(index + 1, actualPath.Length - index - 1);

                localTotalMaterialPathList.Add(finalPath);
            }

            List <string> localMaterialPathList = localTotalMaterialPathList.Distinct().ToList();

            if (!showSystemFolders)
            {
                localMaterialPathList.Remove("System");
            }

            //print ("------------------------------------------");
            //for (int i = 0; i < localMaterialPathList.Count; i++)
            //{
            //print (localMaterialPathList [i]);
            //}

            EditorGUILayout.Separator();
            GenericMeshDecal.actualFolderIndex = EditorGUILayout.Popup(GenericMeshDecal.actualFolderIndex, localMaterialPathList.ToArray(), new GUILayoutOption[] { GUILayout.Width(0.81f * areaWidth) });
            EditorGUILayout.Separator();

            string selectedMaterialPath = BasicDefines.NOT_DEFINED;

            if (localMaterialPathList.Count > 0)
            {
                selectedMaterialPath = localMaterialPathList [GenericMeshDecal.actualFolderIndex];
            }

            // test some things
            int      numberOfMaterialsPerLine = 4;
            bool     begin = false;
            int      cont  = 0;
            bool     actualSelectedElementIsInSelectedPathList = false;
            Material firstElementInActualPath = null;


            // draw materials in editor window
            for (int i = 0; i < Mathf.Ceil((float)meshDecalMaterialsList.Count); i++)
            {
                if (localTotalMaterialPathList [i] == selectedMaterialPath)
                {
                    if (firstElementInActualPath == null)
                    {
                        firstElementInActualPath = meshDecalMaterialsList [i];
                    }

                    if ((selectedMaterial == meshDecalMaterialsList [i]))
                    {
                        actualSelectedElementIsInSelectedPathList = true;
                    }

                    if (cont % numberOfMaterialsPerLine == 0)
                    {
                        GUILayout.BeginHorizontal();
                        begin = true;
                    }

                    if (actualMaterial == meshDecalMaterialsList [i])
                    {
                        GUI.color           = new Color(1, 1, 1, 1);
                        GUI.backgroundColor = new Color(0.6f, 0.0f, 0.6f, 1f);
                    }
                    else
                    {
                        GUI.color           = new Color(1, 1, 1, 1f);
                        GUI.backgroundColor = new Color(1, 1, 1, 0.3f);
                    }

                    float buttonsScale = 0.94f * areaWidth / (numberOfMaterialsPerLine + 0.3f);

                    // test if one material is selected
                    bool selected = GUILayout.Button(new GUIContent(meshDecalMaterialsList [i].mainTexture, meshDecalMaterialsList [i].name), new GUILayoutOption[] {
                        GUILayout.Width(buttonsScale),
                        GUILayout.Height(buttonsScale)
                    });

                    // if selected then is the actual selected material
                    if (selected)
                    {
                        selectedMaterial = meshDecalMaterialsList [i];
                    }

                    if (cont % numberOfMaterialsPerLine == numberOfMaterialsPerLine - 1)
                    {
                        GUILayout.EndHorizontal();
                        begin = false;
                    }

                    cont++;
                }
            }

            if (!actualSelectedElementIsInSelectedPathList && DecalManagerWindow.autoChangeToFirstElementInList)
            {
                //print ("Change to firstElementInActualPath: " + firstElementInActualPath.name);
                selectedMaterial = firstElementInActualPath;
            }

            if (begin)
            {
                EditorGUILayout.EndHorizontal();
            }

            // restore Gui Color
            GUI.color           = actualGuiColor;
            GUI.backgroundColor = bgColor;


            // return actual selected material
            return(selectedMaterial);
        }