Update() private method

private Update ( ) : void
return void
示例#1
0
    void Reset()
    {
        var obj = new UnityEditor.SerializedObject(this);

        obj.Update();

        var blocks = obj.FindProperty("_processingBlocks");

        blocks.ClearArray();

        var p  = UnityEditor.AssetDatabase.GetAssetPath(this);
        var bl = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(p);

        foreach (var a in bl)
        {
            if (a == this)
            {
                continue;
            }
            // Debug.Log(a, a);
            // DestroyImmediate(a, true);
            int i = blocks.arraySize++;
            var e = blocks.GetArrayElementAtIndex(i);
            e.objectReferenceValue = a;
        }

        obj.ApplyModifiedProperties();
        // UnityEditor.EditorUtility.SetDirty(this);
        UnityEditor.AssetDatabase.SaveAssets();
    }
示例#2
0
    void OnSceneGUI()
    {
        PointPath pointPath = (PointPath)target;

        float pixelSize = HandleUtility.GetHandleSize ( Vector3.zero ) / 160;

        // Handles.color = Color.white;

        Handles.color = Color.clear;

        for ( int i = 0; i < pointPath.Points.Count; i++ )
        {
            Vector3 oldPoint = pointPath.Points[i];
            Vector3 newPoint = Handles.FreeMoveHandle ( oldPoint, Quaternion.identity, pixelSize * 7, pointSnap, Handles.DotCap );
            if ( oldPoint != newPoint )
            {
                SerializedObject so = new SerializedObject ( target );
                if ( so != null )
                {
                    so.Update ();

                    SerializedProperty PointsArray = so.FindProperty ( "Points" );

                    SerializedProperty point = PointsArray.GetArrayElementAtIndex ( i );
                    if ( point != null )
                        point.vector3Value = newPoint;

                    so.ApplyModifiedProperties ();
                }
            }
        }
    }
示例#3
0
    void RemoveACar(int value)
    {
        // --> Find and Pause Cars
        GameObject[] arrCars = GameObject.FindGameObjectsWithTag("Car");

        List <GameObject> tmpList = new List <GameObject> ();

        foreach (GameObject car in arrCars)
        {
            if (car.GetComponent <CarController> () && car.GetComponent <CarController> ().playerNumber == (value + 1))
            {
                tmpList.Add(car);
            }
        }

        for (var i = tmpList.Count - 1; i >= 0; i--)
        {
            Undo.DestroyObjectImmediate(tmpList[i]);
        }
        tmpList.Clear();

        SerializedObject serializedObject0 = new UnityEditor.SerializedObject(inventoryItemList);

        serializedObject0.Update();
        SerializedProperty m_carName = serializedObject0.FindProperty("inventoryItem").GetArrayElementAtIndex(0).FindPropertyRelative("list_Cars");


        if (inventoryItemList)
        {
            m_carName.GetArrayElementAtIndex(value).objectReferenceValue = null;
        }
        serializedObject0.ApplyModifiedProperties();
    }
示例#4
0
        public override void ShowGUI()
        {
            if (this == null)
            {
                return;
            }

            var serializedObject = new UnityEditor.SerializedObject(this);

            serializedObject.Update();
            SerializedProperty eventProperty = serializedObject.FindProperty("unityEvent");

            EditorGUILayout.PropertyField(eventProperty, true);

            ignoreWhenSkipping = EditorGUILayout.Toggle("Ignore when skipping?", ignoreWhenSkipping);
            if (ignoreWhenSkipping)
            {
                SerializedProperty skipEventProperty = serializedObject.FindProperty("skipEvent");
                EditorGUILayout.PropertyField(skipEventProperty, true);
            }

            serializedObject.ApplyModifiedProperties();

            EditorGUILayout.HelpBox("Parameters passed from here cannot be set, unfortunately, due to a Unity limitation.", MessageType.Warning);

            AfterRunningOption();
        }
示例#5
0
//--> Move tile in scene view
    private void MoveTileInSceneView(int oldPosition, string direction, SlidingPuzzle myScript)
    {
        if (oldPosition != -1)
        {
            // Debug.Log("oldPosition : " + oldPosition);
            SerializedObject serializedObject2 = new UnityEditor.SerializedObject(myScript.tilesList[myScript.positionList[oldPosition]].GetComponent <Transform>());
            serializedObject2.Update();
            SerializedProperty m_Position = serializedObject2.FindProperty("m_LocalPosition");

            if (direction == "Down")
            {
                m_Position.vector3Value = new Vector3(m_Position.vector3Value.x, m_Position.vector3Value.y - .25f, 0);
            }
            if (direction == "Up")
            {
                m_Position.vector3Value = new Vector3(m_Position.vector3Value.x, m_Position.vector3Value.y + .25f, 0);
            }
            if (direction == "Left")
            {
                m_Position.vector3Value = new Vector3(m_Position.vector3Value.x - .25f, m_Position.vector3Value.y, 0);
            }
            if (direction == "Right")
            {
                m_Position.vector3Value = new Vector3(m_Position.vector3Value.x + .25f, m_Position.vector3Value.y, 0);
            }

            serializedObject2.ApplyModifiedProperties();
        }
    }
示例#6
0
	private void Draw(){
		SerializedObject cacheObject = new SerializedObject (cache);
		cacheObject.Update();
		SerializedProperty property = cacheObject.FindProperty ("prefabs");
		if (property != null) {
			int removeIndex=-1;
			for(int i=0;i< property.arraySize;i++){
				GUILayout.BeginHorizontal();
				SerializedProperty nameProperty=property.GetArrayElementAtIndex(i).FindPropertyRelative("name");
				EditorGUILayout.PropertyField(nameProperty,GUIContent.none);
				
				SerializedProperty prefabProperty=property.GetArrayElementAtIndex(i).FindPropertyRelative("prefab");
				bool isNull=prefabProperty.objectReferenceValue==null;
				EditorGUILayout.PropertyField(prefabProperty,GUIContent.none);
				if(isNull && prefabProperty.objectReferenceValue!=null){
					nameProperty.stringValue=prefabProperty.objectReferenceValue.name;
				}  
				if(GUILayout.Button(EditorGUIUtility.FindTexture("Toolbar Minus"),"label",GUILayout.Width(20))){
					removeIndex=i;
				}
				GUILayout.EndHorizontal();
			}			
			
			if(removeIndex != -1){
				property.DeleteArrayElementAtIndex(removeIndex);
			}
		}
		cacheObject.ApplyModifiedProperties();
	}
	void App(GameObject src, GameObject dst)
	{
		dst.transform.localPosition=src.transform.localPosition;
		Component comp=src.GetComponent<MeshFilter>();
		Component dst_comp = dst.AddComponent(comp.GetType());
 
			SerializedObject src_ser_obj = new SerializedObject(comp);
			SerializedObject dst_ser_obj = new SerializedObject(dst_comp);
			src_ser_obj.Update();
			dst_ser_obj.Update();
			SerializedProperty ser_prop = src_ser_obj.GetIterator();
			bool enterChildren = true;
			while (ser_prop.Next(enterChildren)) {
				enterChildren = true;
				string path = ser_prop.propertyPath;
 
				bool skip = false;
				foreach (string blacklisted_path in propertyBlacklist) {
					if (path.EndsWith(blacklisted_path)) {
						skip = true;
						break;
					}
				}
				if (skip) {
					enterChildren = false;
					continue;
				}
 
				//Debug.Log(path);
				SerializedProperty dst_ser_prop = dst_ser_obj.FindProperty(path);
				AssignSerializedProperty(ser_prop, dst_ser_prop);
			}
 
			dst_ser_obj.ApplyModifiedProperties();
	}
示例#8
0
		private void DoVariable(FsmVariable variable){
			SerializedObject serializedObject = new SerializedObject (variable);
			SerializedProperty nameProperty = serializedObject.FindProperty ("name");
			SerializedProperty valueProperty = serializedObject.FindProperty ("value");

			GUILayout.BeginHorizontal ();
			serializedObject.Update ();
			EditorGUILayout.PropertyField(nameProperty,GUIContent.none);
			if (valueProperty != null) {
				if (valueProperty.propertyType == SerializedPropertyType.Boolean) {
					EditorGUILayout.PropertyField (valueProperty, GUIContent.none, GUILayout.Width (17));	
				} else {
					EditorGUILayout.PropertyField (valueProperty, GUIContent.none);
				}
			}
			serializedObject.ApplyModifiedProperties ();
			GUILayout.FlexibleSpace ();
			if (GUILayout.Button (FsmEditorStyles.toolbarMinus,FsmEditorStyles.label)) {
				FsmEditor.Root.Variables=ArrayUtility.Remove<FsmVariable>(FsmEditor.Root.Variables,variable);
				UnityEngine.Object.DestroyImmediate(variable,true);
				AssetDatabase.SaveAssets();
			}
			GUILayout.EndHorizontal ();

		}
示例#9
0
    // ===========================================================
    // Static Methods
    // ===========================================================
    
    public static void DrawInspector(SerializedObject so) {
        so.Update();
        
        var mode = so.FindProperty("mode");
        var position = so.FindProperty("position");
        var anchorObject = so.FindProperty("anchorObject");
        var anchorCamera = so.FindProperty("anchorCamera");
        
        MadGUI.PropertyField(mode, "Mode");
        switch ((MadAnchor.Mode) mode.enumValueIndex) {
            case MadAnchor.Mode.ObjectAnchor:
                MadGUI.PropertyField(anchorObject, "Anchor Object", MadGUI.ObjectIsSet);
                MadGUI.PropertyField(anchorCamera, "Anchor Camera", property => property.objectReferenceValue != null || HasMainCamera());

                if (!HasMainCamera()) {
                    GUIMissingMainCameraWarning();
                } else if (anchorCamera.objectReferenceValue == null) {
                    GUIMainCameraWillBeUsed();
                }
                break;
                
            case MadAnchor.Mode.ScreenAnchor:
                MadGUI.PropertyField(position, "Position");
                break;
                
            default:
                MadDebug.Assert(false, "Unknown mode: " + (MadAnchor.Mode) mode.enumValueIndex);
                break;
        }
        
        so.ApplyModifiedProperties();
    }
示例#10
0
        public void Draw(Condition condition, SerializedObject serializedObject)
        {
            foldout = EditorGUILayout.Foldout(foldout, "Condition Editor");
            if (!foldout || (serializedObject == null)) return;

            serializedObject.Update();

            if (drawReferenceDatabase) {
                EditorTools.selectedDatabase = EditorGUILayout.ObjectField(new GUIContent("Reference Database", "Database to use for Lua and Quest conditions"), EditorTools.selectedDatabase, typeof(DialogueDatabase), true) as DialogueDatabase;
            }

            luaConditionWizard.database = EditorTools.selectedDatabase;
            if (luaConditionWizard.database != null) {
                if (!luaConditionWizard.IsOpen) {
                    luaConditionWizard.OpenWizard(string.Empty);
                }
                currentLuaWizardContent = luaConditionWizard.Draw(new GUIContent("Lua Condition Wizard", "Use to add Lua conditions below"), currentLuaWizardContent, false);
                if (!luaConditionWizard.IsOpen && !string.IsNullOrEmpty(currentLuaWizardContent)) {
                    List<string> luaList = new List<string>(condition.luaConditions);
                    luaList.Add(currentLuaWizardContent);
                    condition.luaConditions = luaList.ToArray();
                    currentLuaWizardContent = string.Empty;
                    luaConditionWizard.OpenWizard(string.Empty);
                }
            }

            EditorWindowTools.StartIndentedSection();

            SerializedProperty conditions = serializedObject.FindProperty("condition");
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(conditions, true);
            if (EditorGUI.EndChangeCheck()) serializedObject.ApplyModifiedProperties();

            EditorWindowTools.EndIndentedSection();
        }
示例#11
0
    void displayTracks(MainMenu myScript, int i)
    {
        // inventoryOnlineTracks

        //EditorGUILayout.PropertyField(inventoryOnlineTracks, new GUIContent(""));

        SerializedObject serializedObject0 = new UnityEditor.SerializedObject(myScript.S_CurrentBackground.GetComponent <Image>());

        serializedObject0.Update();

        SerializedProperty m_Scale = serializedObject0.FindProperty("m_Sprite");

        if (m_Scale.objectReferenceValue != (Sprite)TableBackgroundSpriteList.GetArrayElementAtIndex(i).objectReferenceValue)
        {
            m_Scale.objectReferenceValue = null;
            m_Scale.objectReferenceValue = (Sprite)TableBackgroundSpriteList.GetArrayElementAtIndex(i).objectReferenceValue;
        }


        // if (m_Scale.objectReferenceValue != (Sprite)TableBackgroundSpriteList.GetArrayElementAtIndex(i).objectReferenceValue)
        //   m_Scale.objectReferenceValue = (Sprite)TableBackgroundSpriteList.GetArrayElementAtIndex(i).objectReferenceValue;


        serializedObject0.ApplyModifiedProperties();
    }
	public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
	{
		position.x += 4;
		position.width -= 6;
		if (!initialized) {
			AIEditorWindow[] windows=Resources.FindObjectsOfTypeAll<AIEditorWindow>();
			if(windows.Length >0){
				controller = windows[0].controller;
			}
			initialized=true;
		}
		
		if (controller != null) {
			NamedParameter param=(NamedParameter)property.objectReferenceValue;
			if(param == null){
				property.objectReferenceValue=param=CreateUserParameter();
			}
			position.width-=15;
			Rect r= new Rect(position);
			r.x+=position.width;
			r.width=20;

			param.userVariable=GUI.Toggle(r,param.userVariable,GUIContent.none);

			if(param != null && param.userVariable){
				param.Name=string.Empty;
				SerializedObject paramObject= new SerializedObject(param);
				paramObject.Update();
				EditorGUI.PropertyField(position,paramObject.FindProperty("value"),new GUIContent(label.text));
				paramObject.ApplyModifiedProperties();
			}else{
				string[] parameters=null;
				if(fieldInfo.FieldType == typeof(Vector3Parameter)){
					parameters=controller.GetParameterNames(fieldInfo.FieldType,typeof(GameObjectParameter));
				}else{
					parameters=controller.GetParameterNames(fieldInfo.FieldType);
				}
				if(parameters.Length == 0){
					System.Array.Resize (ref parameters, parameters.Length + 1);
					parameters[parameters.Length - 1] = "None";
					List<string> list= new List<string>(parameters);
					list.Swap(0,parameters.Length-1);
					parameters=list.ToArray();
				}
				
				for(int i=0;i< parameters.Length;i++){
					if(parameters[i] == param.Name){
						selectedIndex=i;
					}
				}
				GUI.color=(parameters[selectedIndex]=="None"?Color.red:Color.white);
				selectedIndex=EditorGUI.Popup(position,label.text,selectedIndex,parameters);
				GUI.color=Color.white;
				if(parameters[selectedIndex]!="None"){
					param.Name=parameters[selectedIndex];
				}
			}
		}

	}
示例#13
0
    private void clearSlectedCustomMethods(int value, actionsWhenPuzzleIsSolved myScript, bool b_Clear)
    {
        SerializedObject serializedObject2 = new UnityEditor.SerializedObject(myScript);

        SerializedProperty obj            = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("obj");
        SerializedProperty scriptRef      = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("scriptRef");
        SerializedProperty indexScript    = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("indexScript");
        SerializedProperty indexMethod    = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("indexMethod");
        SerializedProperty methodInfoName = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("methodInfoName");
        SerializedProperty intValue       = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("intValue");
        SerializedProperty floatValue     = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("floatValue");
        SerializedProperty stringValue    = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("stringValue");
        SerializedProperty objValue       = serializedObject2.FindProperty("methodsList").GetArrayElementAtIndex(value).FindPropertyRelative("objValue");



        serializedObject2.Update();
        if (b_Clear)
        {
            obj.objectReferenceValue = null;
        }

        scriptRef.objectReferenceValue = null;
        indexScript.intValue           = 0;
        indexMethod.intValue           = 0;
        methodInfoName.stringValue     = "";
        intValue.intValue             = 0;
        floatValue.floatValue         = 0;
        stringValue.stringValue       = "";
        objValue.objectReferenceValue = null;

        serializedObject2.ApplyModifiedProperties();
    }
示例#14
0
	protected void DrawColors ()
	{
		if (serializedObject.FindProperty("tweenTarget").objectReferenceValue == null) return;

		if (NGUIEditorTools.DrawHeader("Colors", "Colors", false, true))
		{
			NGUIEditorTools.BeginContents(true);
			NGUIEditorTools.SetLabelWidth(76f);
			UIButtonColor btn = target as UIButtonColor;

			if (btn.tweenTarget != null)
			{
				UIWidget widget = btn.tweenTarget.GetComponent<UIWidget>();

				if (widget != null)
				{
					EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
					{
						SerializedObject obj = new SerializedObject(widget);
						obj.Update();
						NGUIEditorTools.DrawProperty("Normal", obj, "mColor");
						obj.ApplyModifiedProperties();
					}
					EditorGUI.EndDisabledGroup();
				}
			}

			NGUIEditorTools.DrawProperty("Hover", serializedObject, "hover");
			NGUIEditorTools.DrawProperty("Pressed", serializedObject, "pressed");
			NGUIEditorTools.DrawProperty("Disabled", serializedObject, "disabledColor");
			NGUIEditorTools.EndContents();
		}
	}
示例#15
0
		public static void SavePose(Pose pose, Transform root)
		{
			List<Bone2D> bones = new List<Bone2D>(50);

			root.GetComponentsInChildren<Bone2D>(true,bones);

			SerializedObject poseSO = new SerializedObject(pose);
			SerializedProperty entriesProp = poseSO.FindProperty("m_PoseEntries");

			poseSO.Update();
			entriesProp.arraySize = bones.Count;

			for (int i = 0; i < bones.Count; i++)
			{
				Bone2D bone = bones [i];

				if(bone)
				{
					SerializedProperty element = entriesProp.GetArrayElementAtIndex(i);
					element.FindPropertyRelative("path").stringValue = BoneUtils.GetBonePath(root,bone);
					element.FindPropertyRelative("localPosition").vector3Value = bone.transform.localPosition;
					element.FindPropertyRelative("localRotation").quaternionValue = bone.transform.localRotation;
					element.FindPropertyRelative("localScale").vector3Value = bone.transform.localScale;
				}
			}

			poseSO.ApplyModifiedProperties();
		}
示例#16
0
    public void DrawWindow()
    {
        //Serializing Objects/Properties
        DLNode             thisNode         = this;
        SerializedObject   serializedObject = new UnityEditor.SerializedObject(thisNode);
        SerializedProperty st  = serializedObject.FindProperty("sentences");
        SerializedProperty ans = serializedObject.FindProperty("answers");
        SerializedProperty eve = serializedObject.FindProperty("onEnd");

        // End Serializing Objects/Properties


        nodeType = (NodeType)EditorGUILayout.EnumPopup("Node Type", nodeType);

        switch (nodeType)
        {
        case (NodeType)0:
            if (sentences != null)
            {
                rect.height = 100 + (sentences.Length * 60);
            }
            npcName     = EditorGUILayout.TextField("NPC name", npcName);
            windowTitle = "Sentences : " + npcName;
            serializedObject.Update();
            EditorGUILayout.PropertyField(st, true);
            serializedObject.ApplyModifiedProperties();
            break;

        case (NodeType)1:
            if (answers != null)
            {
                rect.height = 100 + (answers.Length * 60);
            }
            windowTitle = "Answers";
            serializedObject.Update();
            EditorGUILayout.PropertyField(ans, true);
            serializedObject.ApplyModifiedProperties();

            break;

        case (NodeType)2:
            rect.height = 220;
            windowTitle = "Event";
            EditorGUILayout.PropertyField(eve, true);
            break;
        }
    }
示例#17
0
    void RecursiveCopy(GameObject src, GameObject dst)
    {
        Debug.Log("Copying from " + src.name + " to " + dst.name);

        Component[] src_components = src.GetComponents(typeof(Component));

        foreach (Component comp in src_components) {
          if (comp is Transform || comp is Renderer || comp is Animation)
        continue;

          //Debug.Log("Adding " + comp.GetType().Name + " to " + dst.name);
          Component dst_comp = dst.AddComponent(comp.GetType());

          SerializedObject src_ser_obj = new SerializedObject(comp);
          SerializedObject dst_ser_obj = new SerializedObject(dst_comp);
          src_ser_obj.Update();
          dst_ser_obj.Update();

          SerializedProperty ser_prop = src_ser_obj.GetIterator();

          bool enterChildren = true;
          while (ser_prop.Next(enterChildren)) {
        enterChildren = true;
        string path = ser_prop.propertyPath;

        bool skip = false;
        foreach (string blacklisted_path in propertyBlacklist) {
          if (path.EndsWith(blacklisted_path)) {
            skip = true;
            break;
          }
        }
        if (skip) {
          enterChildren = false;
          continue;
        }

        //Debug.Log(path);
        SerializedProperty dst_ser_prop = dst_ser_obj.FindProperty(path);
        AssignSerializedProperty(ser_prop, dst_ser_prop);
          }

          dst_ser_obj.ApplyModifiedProperties();
        }

        foreach (Transform child_transform in src.transform) {
          GameObject child = child_transform.gameObject;

          string dst_object_name = namePrefix + child.name;
          GameObject dst_object = findChildWithName(dst, dst_object_name);

          if (dst_object == null) {
        Debug.LogWarning("Didn't find matching GameObject for " + child.name);
        continue;
          }

          RecursiveCopy(child, dst_object);
        }
    }
示例#18
0
	protected virtual void OnEnable(){
		database = ItemDatabase.Load ();

		parameterTypeNames = TypeUtility.GetSubTypeNames (typeof(FsmVariable));
		parameterTypeNames = ArrayUtility.Insert<string> (parameterTypeNames, "None", 0);

		customDataList = new ReorderableList(serializedObject, 
		                                     serializedObject.FindProperty("customData"), 
		                                     true, true, true, true);
		customDataList.elementHeight = EditorGUIUtility.singleLineHeight * 3+10;
		customDataList.onRemoveCallback = (ReorderableList list) => {
			list.serializedProperty.serializedObject.Update();
			DestroyImmediate(list.serializedProperty.GetArrayElementAtIndex(list.index).objectReferenceValue,true);
			AssetDatabase.SaveAssets();
			list.serializedProperty.DeleteArrayElementAtIndex(list.index);
			list.serializedProperty.serializedObject.ApplyModifiedProperties();
		};

		customDataList.drawElementCallback =  (Rect rect, int index, bool isActive, bool isFocused) => {
			var element = customDataList.serializedProperty.GetArrayElementAtIndex(index);
			FsmVariable variable = element.objectReferenceValue as FsmVariable;
			rect.y+=2;
			int m = parameterTypeNames.ToList ().FindIndex (x => x == (variable!= null?variable.GetType ().Name:""));
			m = Mathf.Clamp (m, 0, int.MaxValue);
			rect.height=EditorGUIUtility.singleLineHeight;
			m = EditorGUI.Popup (rect,"Parameter Type", m, parameterTypeNames);
			string typeName=parameterTypeNames [m];
			string variableTypeName = (variable == null ? "None" : variable.GetType ().Name);

			if(typeName != variableTypeName){
				DestroyImmediate(element.objectReferenceValue,true);
				if(typeName != "None"){
					variable = ScriptableObject.CreateInstance (TypeUtility.GetTypeByName(typeName)[0]) as FsmVariable;
					variable.hideFlags = HideFlags.HideInHierarchy;
					
					if (EditorUtility.IsPersistent (element.serializedObject.targetObject)) {
						AssetDatabase.AddObjectToAsset (variable, element.serializedObject.targetObject);
						AssetDatabase.SaveAssets ();
					}
					
					element.serializedObject.Update();
					element.objectReferenceValue = variable;
					element.serializedObject.ApplyModifiedProperties ();
				}
			}
			if(variable != null){
				SerializedObject mVariable=new SerializedObject(variable);
				mVariable.Update();
				rect.y+=EditorGUIUtility.singleLineHeight+2;
				EditorGUI.PropertyField(rect,mVariable.FindProperty("name"));
				rect.y+=EditorGUIUtility.singleLineHeight+2;
				EditorGUI.PropertyField(rect,mVariable.FindProperty("value"));
				mVariable.ApplyModifiedProperties();
			}
		};
		customDataList.drawHeaderCallback = (Rect rect) => {  
			EditorGUI.LabelField(rect, "Custom Data");
		};
	}
示例#19
0
    void LoadCar()
    {
        // --> Find and Pause Cars
        GameObject[] arrCars = GameObject.FindGameObjectsWithTag("Car");


        List <GameObject> tmpList = new List <GameObject> ();

        foreach (GameObject car in arrCars)
        {
            if (car.GetComponent <CarController> ())
            {
                tmpList.Add(car);
            }
        }
        for (var i = tmpList.Count - 1; i >= 0; i--)
        {
            //Debug.Log(arrCars.Length + " : " +  arrCars[i].name);
            Undo.DestroyObjectImmediate(tmpList[i]);
        }
        tmpList.Clear();


        for (var i = 0; i < 4; i++)
        {
            SerializedObject serializedObject0 = new UnityEditor.SerializedObject(inventoryItemList);
            serializedObject0.Update();
            SerializedProperty m_carName    = serializedObject0.FindProperty("inventoryItem").GetArrayElementAtIndex(0).FindPropertyRelative("list_Cars");
            SerializedProperty m_PlayerType = serializedObject0.FindProperty("inventoryItem").GetArrayElementAtIndex(0).FindPropertyRelative("list_playerType");

            if (inventoryItemList)
            {
                if (m_carName.GetArrayElementAtIndex(i).objectReferenceValue != null)
                {
                    GameObject instance = (GameObject)Instantiate(m_carName.GetArrayElementAtIndex(i).objectReferenceValue);

                    Undo.RegisterCreatedObjectUndo(instance, instance.name);

                    instance.name = instance.name.Replace("(Clone)", "");

                    GameObject tmpPosition = GameObject.Find("Start_Position_0" + (i + 1));

                    if (tmpPosition)
                    {
                        Undo.RegisterFullObjectHierarchyUndo(instance, "Pos_" + instance.name);

                        instance.GetComponent <CarController> ().playerNumber = i + 1;                                                                  // Select the player number

                        instance.GetComponent <CarAI>().enabled = m_PlayerType.GetArrayElementAtIndex(i).boolValue;

                        instance.transform.position    = new Vector3(tmpPosition.transform.position.x, tmpPosition.transform.position.y + .15f, tmpPosition.transform.position.z);
                        instance.transform.eulerAngles = tmpPosition.transform.eulerAngles;
                    }
                }
            }
            serializedObject0.ApplyModifiedProperties();
        }
    }
示例#20
0
        internal static SerializedProperty[] GetSerializedProperties(this Object go) {
            var so = new SerializedObject(go);
            so.Update();
            var result = new List<SerializedProperty>();

            var iterator = so.GetIterator();
            while (iterator.NextVisible(true)) result.Add(iterator.Copy());
            return result.ToArray();
        }
		public static void DrawInspector(Editor wcEditor, System.Type baseType, List<string> ignoreClasses = null) {

			var so = new SerializedObject(wcEditor.targets);
			var target = wcEditor.target;
			
			so.Update();

			var baseTypes = new List<System.Type>();
			var baseTargetType = target.GetType();
			baseTypes.Add(baseTargetType);
			while (baseType != baseTargetType) {

				baseTargetType = baseTargetType.BaseType;
				baseTypes.Add(baseTargetType);

			}
			baseTypes.Reverse();

			SerializedProperty prop = so.GetIterator();
			var result = prop.NextVisible(true);

			EditorGUILayout.PropertyField(prop, false);

			if (result == true) {

				var currentType = EditorUtilitiesEx.FindTypeByProperty(baseTypes, prop);
				EditorGUILayout.BeginVertical();
				{

					while (prop.NextVisible(false) == true) {
						
						var cType = EditorUtilitiesEx.FindTypeByProperty(baseTypes, prop);
						if (cType != currentType) {
							
							currentType = cType;

							var name = cType.Name;
							if (ignoreClasses != null && ignoreClasses.Contains(name) == true) continue;

							EditorUtilitiesEx.DrawSplitter(name);

						}

						EditorGUILayout.PropertyField(prop, true);

					}

					prop.Reset();

				}
				EditorGUILayout.EndVertical();

			}

			so.ApplyModifiedProperties();

		}
示例#22
0
 public static void DrawSerializedProperty(SerializedObject serializedObject, string propertyName)
 {
     serializedObject.Update();
     var property = serializedObject.FindProperty(propertyName);
     if (property == null) return;
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.PropertyField(property, true);
     if (EditorGUI.EndChangeCheck()) {
         serializedObject.ApplyModifiedProperties();
     }
 }
        public override void OnInspectorGUI()
        {
            var fb = target as FixedBase;
            var obj = new SerializedObject(fb);

            EditorGUILayout.PropertyField(obj.FindProperty("m_safeFloor"));

            if (GUI.changed)
            {
                obj.ApplyModifiedProperties();
                obj.Update();
            }
        }
示例#24
0
        public static void DoImportBitmapFont(string fntPatn)
        {
            if (!IsFnt(fntPatn)) return;

            TextAsset fnt = AssetDatabase.LoadMainAssetAtPath(fntPatn) as TextAsset;
            string text = fnt.text;
            FntParse parse = FntParse.GetFntParse(ref text);
            if (parse == null) return;

            string fntName = Path.GetFileNameWithoutExtension(fntPatn);
            string rootPath = Path.GetDirectoryName(fntPatn);
            string fontPath = string.Format("{0}/{1}.fontsettings", rootPath, fntName);
            string texPath = string.Format("{0}/{1}", rootPath, parse.textureName);

            Font font = AssetDatabase.LoadMainAssetAtPath(fontPath) as Font;
            if (font == null)
            {
                font = new Font();
                AssetDatabase.CreateAsset(font, fontPath);
                font.material = new Material(Shader.Find("UI/Default"));
                font.material.name = "Font Material";
                AssetDatabase.AddObjectToAsset(font.material, font);
            }

            SerializedObject so = new SerializedObject(font);
            so.Update();
            so.FindProperty("m_FontSize").floatValue = parse.fontSize;
            so.FindProperty("m_LineSpacing").floatValue = parse.lineHeight;
            UpdateKernings(so, parse.kernings);
            so.ApplyModifiedProperties();
            so.SetIsDifferentCacheDirty();

            Texture2D texture = AssetDatabase.LoadMainAssetAtPath(texPath) as Texture2D;
            if (texture == null)
            {
                Debug.LogErrorFormat(fnt, "{0}: not found '{1}'.", typeof(BFImporter), texPath);
                return;
            }

            TextureImporter texImporter = AssetImporter.GetAtPath(texPath) as TextureImporter;
            texImporter.textureType = TextureImporterType.GUI;
            texImporter.mipmapEnabled = false;
            texImporter.SaveAndReimport();

            font.material.mainTexture = texture;
            font.material.mainTexture.name = "Font Texture";

            font.characterInfo = parse.charInfos;

            AssetDatabase.SaveAssets();
        }
示例#25
0
    static void _CopyParticleSystem(ParticleSystem original, GameObject copyTo)
    {
        ParticleSystem ps = null;
        if( (ps = copyTo .GetComponent<ParticleSystem>()) ==null)
        {
          ps = copyTo.AddComponent<ParticleSystem>();
        }
        SerializedObject newPsSerial = new SerializedObject(ps);
        SerializedObject srcPsSerial = new SerializedObject(original);
        SerializedProperty srcProperty = srcPsSerial.FindProperty("InitialModule.startLifetime");

        LegacyToShurikenConverter.SetShurikenMinMaxCurve(newPsSerial, "InitialModule.startLifetime", 0.3f, 0.4f, true);
        newPsSerial.Update();
    }
	public static void DrawArrayField(SerializedObject serializedObject,string property){
	    serializedObject.Update();
	    EditorGUIUtility.LookLikeInspector();
	
	    SerializedProperty myIterator = serializedObject.FindProperty(property);
	    while (true){
	        Rect myRect = GUILayoutUtility.GetRect(0f, 16f);
	        bool showChildren = EditorGUI.PropertyField(myRect, myIterator);
			if (!myIterator.NextVisible(showChildren)){
				break;	
			}
		}
	    serializedObject.ApplyModifiedProperties();		
	}
        public override void OnInspectorGUI()
        {
            var acc = target as Accessory;
            var obj = new SerializedObject(acc);

            EditorGUILayout.PropertyField(obj.FindProperty("m_pack"));
            EditorGUILayout.PropertyField(obj.FindProperty("m_offhand"));

            if (GUI.changed)
            {
                obj.ApplyModifiedProperties();
                obj.Update();
            }
        }
示例#28
0
		public static void OnGUI(UnityEngine.Object targetObject){
			EditorGUI.BeginChangeCheck ();
			SerializedObject serializedObject = new SerializedObject (targetObject);
			serializedObject.Update ();
			FieldInfo[] fields;
			if(!fieldsLookup.TryGetValue (targetObject.GetType (),out fields)){
				fields=targetObject.GetPublicFields().OrderBy(field => field.MetadataToken).ToArray();

				fieldsLookup.Add(targetObject.GetType(),fields);
			}
			if(PreferencesEditor.GetBool(Preference.ShowActionTooltips) && !string.IsNullOrEmpty(targetObject.GetTooltip())){
				GUILayout.BeginVertical((GUIStyle)"hostview");

				GUILayout.Label(targetObject.GetTooltip(),FsmEditorStyles.wrappedLabelLeft);
				GUILayout.EndVertical();
			}


			for (int i=0; i< fields.Length; i++) {
				FieldInfo field=fields[i];
				if(field.HasAttribute(typeof(HideInInspector))){
					continue;
				}
				PropertyDrawer drawer=GUIDrawer.GetDrawer(field);
				GUIContent content = field.GetInspectorGUIContent ();
				SerializedProperty property=serializedObject.FindProperty(field.Name);
				if(PreferencesEditor.GetBool(Preference.ShowVariableTooltips) && !string.IsNullOrEmpty(field.GetTooltip())){
					GUILayout.BeginVertical("box");
					GUILayout.Label(field.GetTooltip(),FsmEditorStyles.wrappedLabelLeft);
					GUILayout.EndVertical();
				}

				if(drawer != null){
					drawer.fieldInfo=field;
					drawer.OnGUI(property,content);
				}else{
					int indentLevel=EditorGUI.indentLevel;
					EditorGUI.indentLevel=	typeof(IList).IsAssignableFrom(field.FieldType)?indentLevel+1:indentLevel;
					EditorGUILayout.PropertyField (property, content,true);
					EditorGUI.indentLevel=indentLevel;
				}
			}


			if (EditorGUI.EndChangeCheck()) {
				serializedObject.ApplyModifiedProperties();
				ErrorChecker.CheckForErrors();
			}
		}
示例#29
0
        private void addFriendlyGesture(SerializedProperty prop, Gesture value)
        {
            if (value == null || value == target) return;

            addGesture(prop, value);

            var so = new SerializedObject(value);
            so.Update();
            SerializedProperty p = so.FindProperty(FRIENDLY_GESTURES_PROP);
            p.arraySize++;
            p.GetArrayElementAtIndex(p.arraySize - 1).objectReferenceValue = target;

            so.ApplyModifiedProperties();
            EditorUtility.SetDirty(value);
        }
示例#30
0
    public void DrawWindowGUI(int i)
    {
        EditorGUI.BeginChangeCheck();
        SerializedObject serializedObject = new SerializedObject(this);
        serializedObject.Update();
        SerializedProperty iterator = serializedObject.GetIterator();
        for (bool flag = true; iterator.NextVisible(flag); flag = false)
        {
            EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]);
        }
        serializedObject.ApplyModifiedProperties();
        EditorGUI.EndChangeCheck();

        GUI.DragWindow(new Rect(0, 0, 10000, 20));
    }
示例#31
0
        //EDITOR-ONLY SERIALIZATION:
#if UNITY_EDITOR
        public static E.SerializedProperty FindDeepProperty(this E.SerializedObject so, string path)
        {
            so.ApplyModifiedProperties();
            so.Update();

            string[] _pathArray = StringUtil.ToPathArray(path);

            E.SerializedProperty
                _so_parentDir = null,
                _so_targ      = null;

            if (_pathArray.Length > 1)
            {
                _so_parentDir = so.FindProperty(_pathArray[0]);
                for (int i = 0; i < _pathArray.Length - 1 /*go only through the parents, hence -1*/; i++)
                {
                    if (_so_parentDir != null)
                    {
                        if (i > 0)                         //iterate through the parents
                        {
                            _so_parentDir = _so_parentDir.FindPropertyRelative(_pathArray[i]);
                        }
                        _so_targ = _so_parentDir.FindPropertyRelative(_pathArray[i + 1]);
                    }
                    else
                    {
                        EditorUtil.Debug("[SETUtil_EditorUtil.FindDeepProperty ERROR] Invalid path element: " + _so_parentDir);
                    }
                }
            }
            else if (_pathArray.Length == 1)
            {
                _so_targ = so.FindProperty(_pathArray[0]);
            }
            else
            {
                EditorUtil.Debug("[SETUtil_EditorUtil.FindDeepProperty ERROR] Empty target path!");
                return(null);
            }

            if (_so_targ == null)
            {
                EditorUtil.Debug("[SETUtil_EditorUtil.FindDeepProperty ERROR] Nonexistent or inaccessible property: " + path + ". Make sure you are not targeting a MonoBehavior-derived class instance.");
                return(null);
            }

            return(_so_targ);
        }
    private static void ProcessDependencies()
    {
        ResourceSingletonBuilder.BuildResourceSingletonsIfDirty();

        var so = new UnityEditor.SerializedObject(instance);

        var types = new string[] { ".cs", ".js" };

        var allScriptPaths = Directory.GetFiles("Assets", "*.*", SearchOption.AllDirectories)
                             .Where(s => types.Any(x => s.EndsWith(x, System.StringComparison.CurrentCultureIgnoreCase)))
                             .ToArray();

        instance.m_serializedItems.Clear();

        for (int i = 0; i < allScriptPaths.Length; ++i)
        {
            UnityEditor.MonoScript script = UnityEditor.AssetDatabase.LoadAssetAtPath(allScriptPaths[i], typeof(UnityEditor.MonoScript)) as UnityEditor.MonoScript;

            if (!script || script.GetClass() == null)
            {
                continue;
            }

            var type = script.GetClass();
            if (!typeof(Component).IsAssignableFrom(script.GetClass()) &&
                !typeof(ScriptableObject).IsAssignableFrom(script.GetClass()))
            {
                continue;
            }

            var typeExecutionOrder = UnityEditor.MonoImporter.GetExecutionOrder(script);
            if (typeExecutionOrder == 0)
            {
                continue;
            }

            instance.m_serializedItems.Add(new SerializedItem()
            {
                typeName       = type.FullName,
                executionOrder = typeExecutionOrder,
            });
        }

        so.Update();
        instance.hideFlags = HideFlags.NotEditable;
        UnityEditor.EditorUtility.SetDirty(instance);
        UnityEditor.AssetDatabase.Refresh();
    }
    public override void OnInspectorGUI()
    {
        SerializedObject obj = new SerializedObject(Target);
        obj.Update();

        foreach(KeyValuePair<EditorObject, List<EditorObjectConnection>> pair in Target.ConnectionRegistry)
        {
            foreach(EditorObjectConnection connection in pair.Value)
            {
                GUI.color = connection.MessageColor;
                GUILayout.Label(string.Format("{0} to {1}", pair.Key.ToString(), connection.Subject.ToString()), GUI.skin.box);
                GUI.color = Color.white;
            }
        }
        obj.ApplyModifiedProperties();
    }
示例#34
0
	protected override void DrawProperties ()
	{
		SerializedProperty sp = serializedObject.FindProperty("dragHighlight");
		Highlight ht = sp.boolValue ? Highlight.Press : Highlight.DoNothing;
		GUILayout.BeginHorizontal();
		bool highlight = (Highlight)EditorGUILayout.EnumPopup("Drag Over", ht) == Highlight.Press;
		GUILayout.Space(18f);
		GUILayout.EndHorizontal();
		if (sp.boolValue != highlight) sp.boolValue = highlight;

		DrawTransition();
		DrawColors();

		UIButton btn = target as UIButton;

		if (btn.tweenTarget != null)
		{
			UISprite sprite = btn.tweenTarget.GetComponent<UISprite>();

			if (sprite != null)
			{
				if (NGUIEditorTools.DrawHeader("Sprites"))
				{
					NGUIEditorTools.BeginContents();
					EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
					{
						SerializedObject obj = new SerializedObject(sprite);
						obj.Update();
						SerializedProperty atlas = obj.FindProperty("mAtlas");
						NGUIEditorTools.DrawSpriteField("Normal", obj, atlas, obj.FindProperty("mSpriteName"));
						obj.ApplyModifiedProperties();

						NGUIEditorTools.DrawSpriteField("Hover", serializedObject, atlas, serializedObject.FindProperty("hoverSprite"), true);
						NGUIEditorTools.DrawSpriteField("Pressed", serializedObject, atlas, serializedObject.FindProperty("pressedSprite"), true);
						NGUIEditorTools.DrawSpriteField("Disabled", serializedObject, atlas, serializedObject.FindProperty("disabledSprite"), true);
					}
					EditorGUI.EndDisabledGroup();

					NGUIEditorTools.DrawProperty("Pixel Snap", serializedObject, "pixelSnap");
					NGUIEditorTools.EndContents();
				}
			}
		}

		UIButton button = target as UIButton;
		NGUIEditorTools.DrawEvents("On Click", button, button.onClick);
	}
示例#35
0
 private void OnGUI()
 {
     for (int r = 0; r < 4; r++)
     {
         for (int c = 0; c < 8; c++)
         {
             GUI.backgroundColor = colors[(r * 8) + (c)];
             if (GUI.Button(new Rect(10 + c*COLORSIZE, 10 + r*COLORSIZE, COLORSIZE, COLORSIZE), ""))
             {
                 SerializedObject so = new SerializedObject(cv);
                 so.Update();
                 cv.SetandBake(piece, (r * 8) + (c));
                 so.ApplyModifiedProperties();
                 Close();
             }
         }
     }
 }
示例#36
0
 /// <summary>
 /// 显示数据里面的变量
 /// </summary>
 /// <param name="_editor"></param>
 /// <param name="serializedObject"></param>
 /// <returns></returns>
 public static bool DrawInspectorGUI(EditorBase _editor, SerializedObject serializedObject)
 {
     serializedObject.Update();
     EditorGUI.BeginChangeCheck();
     GUILayout.BeginHorizontal(new GUILayoutOption[0]);
     EditorGUILayout.LabelField("名称", new GUILayoutOption[]
         {
             GUILayout.Width(120f)
         });
     _editor.Data.Name = EditorGUILayout.TextField(_editor.Data.Name, new GUILayoutOption[0]);
     GUILayout.EndHorizontal();
     if (EditorGUI.EndChangeCheck())
     {
         serializedObject.ApplyModifiedProperties();
         return true;
     }
     return false;
 }
    void F_XBOX360_MAC_P2()
    {
        SetupDefaultInputs myScript          = (SetupDefaultInputs)target;
        SerializedObject   serializedObject0 = new UnityEditor.SerializedObject(myScript.defaultInputsValues);

        serializedObject0.Update();
        SerializedProperty m_gamepadPlayer1 = serializedObject0.FindProperty("ListOfInputs");

        m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(0).stringValue = "Joystick2Axis1";
        m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(1).stringValue = "Joystick2Axis1";
        m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(2).stringValue = "Joystick2Axis6";
        m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(3).stringValue = "Joystick2Axis5";
        m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(5).stringValue = "Joystick2Button19";
        m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(6).stringValue = "Joystick2Button16";
        m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(7).stringValue = "Joystick2Button17";
        m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(8).stringValue = "Joystick2Button9";
        serializedObject0.ApplyModifiedProperties();
    }
示例#38
0
    public static void DrawMixer(InMusicNode node, SerializedProperty prop)
    {
        if (!node.IsRoot)
        {
            bool overrideParent = EditorGUILayout.Toggle("Override Parent Mixer", node._overrideParentMixerGroup);
            if (overrideParent != node._overrideParentMixerGroup)
            {
                InUndoHelper.RecordObjectFull(node, "Override parent mixer group");
                node._overrideParentMixerGroup = overrideParent;
            }
            if (!node._overrideParentMixerGroup)
                GUI.enabled = false;
        }
        EditorGUILayout.BeginHorizontal();

        if (node._overrideParentMixerGroup)
            EditorGUILayout.PropertyField(prop, new GUIContent("Mixer Group"));
        else
        {
            if (node._parent != null)
            {
                var parentProp = new SerializedObject(node.GetParentMixing());
                parentProp.Update();
                EditorGUILayout.PropertyField(parentProp.FindProperty("_mixerGroup"),
                    new GUIContent("Parent Mixer Group"));
                parentProp.ApplyModifiedProperties();
            }
            else
            {
                var parentProp = new SerializedObject(node);
                parentProp.Update();
                EditorGUILayout.PropertyField(parentProp.FindProperty("_mixerGroup"), new GUIContent("Mixer Group"));
                parentProp.ApplyModifiedProperties();
            }
        }

        GUI.enabled = node.GetParentMixing() != null;
        if (GUILayout.Button("Find", GUILayout.Width(40)))
        {
            SearchHelper.SearchFor(node._mixerGroup);
        }
        EditorGUILayout.EndHorizontal();
        GUI.enabled = true;
    }
    public override void OnInspectorGUI() {
        serializedObject.Update();

        NGUIEditorTools.SetLabelWidth(80F);
        var animateOnHoverTarget = target as AnimateOnHover;

        NGUIEditorTools.DrawProperty("Target Sprite", serializedObject, "targetSprite");

        if (animateOnHoverTarget.targetSprite != null) {
            SerializedObject spriteSO = new SerializedObject(animateOnHoverTarget.targetSprite);
            spriteSO.Update();
            SerializedProperty atlas = spriteSO.FindProperty("mAtlas");

            spriteSO.ApplyModifiedProperties();

            NGUIEditorTools.DrawSpriteField("HoveredSprite", serializedObject, atlas, serializedObject.FindProperty("hoveredSpriteName"), true);
        }
        serializedObject.ApplyModifiedProperties();
    }
    public static void DrawAnimProperties(AIBehaviorsAnimationState animState, bool is3D)
    {
        SerializedObject m_animState = new SerializedObject(animState);
        string speedTooltip = "";

        m_animState.Update();

        SerializedProperty m_animName = m_animState.FindProperty("name");
        SerializedProperty m_speed = m_animState.FindProperty("speed");
        SerializedProperty m_wrapMode = m_animState.FindProperty("animationWrapMode");

        EditorGUILayout.Separator();

        EditorGUILayout.PropertyField(m_animName);

        if ( !is3D )
        {
            SerializedProperty m_startFrame = m_animState.FindProperty("startFrame");
            SerializedProperty m_endFrame = m_animState.FindProperty("endFrame");
            EditorGUILayout.PropertyField(m_startFrame);
            EditorGUILayout.PropertyField(m_endFrame);

            if ( m_startFrame.intValue < 0 )
                m_startFrame.intValue = 0;

            if ( m_endFrame.intValue < 0 )
                m_endFrame.intValue = 0;

            speedTooltip = "This is a frames persecond value, IE: 30";
        }
        else
        {
            speedTooltip = "This is a normalized value\n\n0.5 = half speed\n1.0 = normal speed\n2.0 = double speed";
        }

        EditorGUILayout.PropertyField(m_speed, new GUIContent("Speed " + (is3D ? "" : "(FPS)"), speedTooltip));
        EditorGUILayout.PropertyField(m_wrapMode);

        EditorGUILayout.Separator();

        m_animState.ApplyModifiedProperties();
    }
        public override void OnInspectorGUI()
        {
            var grab = target as GrabPoint;
            var obj = new SerializedObject(grab);

            EditorGUILayout.PropertyField(obj.FindProperty("m_handedness"));
            EditorGUILayout.PropertyField(obj.FindProperty("m_animationTransition"));

            EditorGUILayout.PropertyField(obj.FindProperty("m_grabRange"));
            EditorGUILayout.PropertyField(obj.FindProperty("m_grabMaxAngle"));
            EditorGUILayout.PropertyField(obj.FindProperty("m_radialSymmetry"));

            EditorGUILayout.PropertyField(obj.FindProperty("m_dropOnRelease"));

            if (GUI.changed)
            {
                obj.ApplyModifiedProperties();
                obj.Update();
            }
        }
示例#42
0
//--> Add new language for data section
    private void addANewLanguage()
    {
        EditorGUILayout.LabelField("Add new language to the current Project : ");

        EditorGUILayout.HelpBox("Each language must have a unique name.", MessageType.Warning);


        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Choose Name : ", GUILayout.Width(100));
        EditorGUILayout.PropertyField(s_newLanguageName, new GUIContent(""));
        EditorGUILayout.EndHorizontal();


        if (GUILayout.Button("Add New language"))
        {
            for (var i = 0; i < listDatas2.Length; i++)
            {
                string objectPath = "Assets/AP/Assets/Resources/" + currentDatasProjectFolder.stringValue + "/TextList/" + listDatas2[i] + ".asset";

                //Debug.Log(objectPath);

                TextList tmpTextList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(UnityEngine.Object)) as TextList;

                SerializedObject   serializedObject3 = new UnityEditor.SerializedObject(tmpTextList);
                SerializedProperty diaryList         = serializedObject3.FindProperty("diaryList");
                SerializedProperty _listOfLanguage   = serializedObject3.FindProperty("listOfLanguage");

                serializedObject3.Update();
                //-> Create new language
                manipulateTextList.Add_A_Language(_listOfLanguage, diaryList, s_newLanguageName.stringValue);
                serializedObject3.ApplyModifiedProperties();
            }

            if (EditorUtility.DisplayDialog(
                    "INFO : New Language added",
                    s_newLanguageName.stringValue + " is added to windows : w_TxtbVoice, w_Item, w_Feedback, w_UI"
                    , "Continue"))
            {
            }
        }
    }
    private void Change_Scaleinlightmap(GameObject go, bool OneMesh, Mesh finalMesh, Meshcombinervtwo myScript)
    {
        //Check if he got a renderer
        if (go.GetComponent <MeshRenderer>() != null)
        {
            //Find the property and modify them

            SerializedObject   serializedObject2     = new UnityEditor.SerializedObject(go.GetComponent <Renderer>());
            SerializedProperty m_nScaleInLightmap    = serializedObject2.FindProperty("m_ScaleInLightmap");
            SerializedProperty m_StitchLightmapSeams = serializedObject2.FindProperty("m_StitchLightmapSeams");
            serializedObject2.Update();

            m_nScaleInLightmap.floatValue   = f_ScaleInLightmap.floatValue;
            m_StitchLightmapSeams.boolValue = b_StitchSeams.boolValue;

            serializedObject2.ApplyModifiedProperties();
        }


        if (!OneMesh)
        {                                           // If there is nothing to combine delete the object
            if (myScript.gameObject.GetComponent <MeshFilter>())
            {
                myScript.gameObject.GetComponent <MeshFilter>().sharedMesh = null;
            }
        }
        else
        {
            UnwrapParam param = new UnwrapParam();              // enable lightmap


            UnwrapParam.SetDefaults(out param);
            param.hardAngle  = _HardAngle.floatValue;
            param.packMargin = _PackMargin.floatValue;
            param.angleError = _AngleError.floatValue;
            param.areaError  = _AreaError.floatValue;


            Unwrapping.GenerateSecondaryUVSet(finalMesh, param);
        }
    }
    static void ProcessAll_SetDependencies(Type type, Dependency[] dependencies)
    {
        var items = instance.m_serializedItems;

        if (dependencies == null)
        {
            dependencies = new Dependency[0];
        }

        items.RemoveAll(x => x.typeName == type.Name);
        if (dependencies.Length > 0)
        {
            var seralisedDeps = new List <SerializedDependency>();
            foreach (var dependency in dependencies)
            {
                Assert.IsNotNull(dependency.requiredType);
                Assert.IsNotNull(dependency.defaultType);
                seralisedDeps.Add(new SerializedDependency()
                {
                    requiredTypeName = dependency.requiredType.FullName,
                    defaultTypeName  = dependency.defaultType.FullName,
                });
            }
            items.Add(new SerializedItem()
            {
                typeName     = type.FullName,
                dependencies = seralisedDeps.ToArray()
            });
        }

        instance.hideFlags = HideFlags.NotEditable;
        UnityEditor.EditorUtility.SetDirty(instance);

        var so = new UnityEditor.SerializedObject(instance);

        so.Update();

        UnityEditor.AssetDatabase.SaveAssets();
    }
示例#45
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            using (new EditorGUI.PropertyScope(position, label, property)) {
                FloatOnTransform target = (FloatOnTransform)fieldInfo.GetValue(property.serializedObject.targetObject);

                position.height = EditorGUIUtility.singleLineHeight;

                var sliderPosition = new Rect(position)
                {
                    width = position.width - EditorGUIUtility.labelWidth,
                    x     = position.x + EditorGUIUtility.labelWidth
                };
                var transformPosition = new Rect(sliderPosition)
                {
                    y = sliderPosition.yMax
                };


                //各プロパティーの Rect を求める
                //var transformProperty = property.FindPropertyRelative ("transform");
                //var transform = (Transform)transformProperty.objectReferenceValue;


                EditorGUI.LabelField(position, label);

                if (target.transform != null)
                {
                    SerializedObject transformSerializedObject = new UnityEditor.SerializedObject(target.transform);
                    transformSerializedObject.Update();
                    var sss = transformSerializedObject.FindProperty("m_LocalPosition");
                    var v   = EditorGUI.Slider(sliderPosition, sss.vector3Value.x, 0, 1);
                    sss.vector3Value = Vector3.right * v;
                    transformSerializedObject.ApplyModifiedProperties();
                }

                EditorGUI.ObjectField(transformPosition, target.transform, typeof(Transform), true);
            }
        }
示例#46
0
    // --> Update Id for a specific gameObject
    public void Find_UniqueId_In_VoiceProperties(Transform child)
    {
        int HowManyEntry = 0;

        TextList _textList;

        if (child.GetComponent <VoiceProperties>().textList == null)
        {
            _textList = loadTextList(returnTextListType(child.GetComponent <VoiceProperties>().editorType));
            Debug.Log(_textList.name);

            HowManyEntry = _textList.diaryList[0]._languageSlot.Count;
        }
        else
        {
            _textList = child.GetComponent <VoiceProperties>().textList;
        }


        HowManyEntry = _textList.diaryList[0]._languageSlot.Count;

        for (var i = 0; i < HowManyEntry; i++)
        {
            if (child.GetComponent <VoiceProperties>().textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <VoiceProperties>().uniqueID)
            {
                Undo.RegisterFullObjectHierarchyUndo(child, child.name);

                SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <VoiceProperties>());
                SerializedProperty m_managerID       = serializedObject2.FindProperty("managerID");

                serializedObject2.Update();
                m_managerID.intValue = i;
                serializedObject2.ApplyModifiedProperties();

                break;
            }
        }
    }
示例#47
0
        public static void AddTag(string _tag)
        {
#if UNITY_EDITOR
            UnityEngine.Object[] _asset = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset");
            if ((_asset != null) && (_asset.Length > 0))
            {
                UnityEditor.SerializedObject   _object = new UnityEditor.SerializedObject(_asset[0]);
                UnityEditor.SerializedProperty _tags   = _object.FindProperty("tags");

                for (int i = 0; i < _tags.arraySize; ++i)
                {
                    if (_tags.GetArrayElementAtIndex(i).stringValue == _tag)
                    {
                        return;
                    }
                }

                _tags.InsertArrayElementAtIndex(0);
                _tags.GetArrayElementAtIndex(0).stringValue = _tag;
                _object.ApplyModifiedProperties();
                _object.Update();
            }
#endif
        }
示例#48
0
    public void Find_UniqueId_In_Puzzle(Transform child)
    {
        TextList _textList;

        //-> Update : Player Object needed in the Inventory
        _textList = loadTextList("wItem");


        int HowManyEntry = _textList.diaryList[0]._languageSlot.Count;

        for (var i = 0; i < HowManyEntry; i++)
        {
            for (var j = 0; j < child.GetComponent <conditionsToAccessThePuzzle>().inventoryIDList.Count; j++)
            {
                if (child.GetComponent <conditionsToAccessThePuzzle>().inventoryIDList.Count > 0 &&
                    _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <conditionsToAccessThePuzzle>().inventoryIDList[j].uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                    SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <conditionsToAccessThePuzzle>());
                    SerializedProperty m_managerID       = serializedObject2.FindProperty("inventoryIDList").GetArrayElementAtIndex(j).FindPropertyRelative("ID");

                    serializedObject2.Update();
                    m_managerID.intValue = i;
                    serializedObject2.ApplyModifiedProperties();
                    break;
                }
            }
        }

        //-> Update : Feedback lock and Unlock
        _textList = loadTextList("wFeedback");


        HowManyEntry = _textList.diaryList[0]._languageSlot.Count;

        for (var i = 0; i < HowManyEntry; i++)
        {
            if (child.GetComponent <conditionsToAccessThePuzzle>().feedbackIDList.Count > 0 &&
                _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <conditionsToAccessThePuzzle>().feedbackIDList[0].uniqueID)
            {
                Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <conditionsToAccessThePuzzle>());
                SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                serializedObject2.Update();
                m_managerID.intValue = i;
                serializedObject2.ApplyModifiedProperties();
                break;
            }
        }

        if (child.GetComponent <LogicsPuzzle>())
        {
            for (var i = 0; i < HowManyEntry; i++)
            {
                if (child.GetComponent <LogicsPuzzle>().feedbackIDList.Count > 0 &&
                    _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <LogicsPuzzle>().feedbackIDList[0].uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                    SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <LogicsPuzzle>());
                    SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                    serializedObject2.Update();
                    m_managerID.intValue = i;
                    serializedObject2.ApplyModifiedProperties();
                    break;
                }
            }
        }

        if (child.GetComponent <PipesPuzzle>())
        {
            for (var i = 0; i < HowManyEntry; i++)
            {
                if (child.GetComponent <PipesPuzzle>().feedbackIDList.Count > 0 &&
                    _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <PipesPuzzle>().feedbackIDList[0].uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                    SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <PipesPuzzle>());
                    SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                    serializedObject2.Update();
                    m_managerID.intValue = i;
                    serializedObject2.ApplyModifiedProperties();
                    break;
                }
            }
        }

        if (child.GetComponent <GearsPuzzle>())
        {
            for (var i = 0; i < HowManyEntry; i++)
            {
                if (child.GetComponent <GearsPuzzle>().feedbackIDList.Count > 0 &&
                    _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <GearsPuzzle>().feedbackIDList[0].uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                    SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <GearsPuzzle>());
                    SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                    serializedObject2.Update();
                    m_managerID.intValue = i;
                    serializedObject2.ApplyModifiedProperties();
                    break;
                }
            }
        }

        if (child.GetComponent <cylinderPuzzle>())
        {
            for (var i = 0; i < HowManyEntry; i++)
            {
                if (child.GetComponent <cylinderPuzzle>().feedbackIDList.Count > 0 &&
                    _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <cylinderPuzzle>().feedbackIDList[0].uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                    SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <cylinderPuzzle>());
                    SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                    serializedObject2.Update();
                    m_managerID.intValue = i;
                    serializedObject2.ApplyModifiedProperties();
                    break;
                }
            }
        }

        if (child.GetComponent <DigicodePuzzle>())
        {
            for (var i = 0; i < HowManyEntry; i++)
            {
                if (child.GetComponent <DigicodePuzzle>().feedbackIDList.Count > 0 &&
                    _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <DigicodePuzzle>().feedbackIDList[0].uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                    SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <DigicodePuzzle>());
                    SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                    serializedObject2.Update();
                    m_managerID.intValue = i;
                    serializedObject2.ApplyModifiedProperties();
                    break;
                }
            }
        }

        if (child.GetComponent <LeverPuzzle>())
        {
            for (var i = 0; i < HowManyEntry; i++)
            {
                if (child.GetComponent <LeverPuzzle>().feedbackIDList.Count > 0 &&
                    _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <LeverPuzzle>().feedbackIDList[0].uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                    SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <LeverPuzzle>());
                    SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                    serializedObject2.Update();
                    m_managerID.intValue = i;
                    serializedObject2.ApplyModifiedProperties();
                    break;
                }
            }
        }

        if (child.GetComponent <SlidingPuzzle>())
        {
            for (var i = 0; i < HowManyEntry; i++)
            {
                if (child.GetComponent <SlidingPuzzle>().feedbackIDList.Count > 0 &&
                    _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <SlidingPuzzle>().feedbackIDList[0].uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                    SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <SlidingPuzzle>());
                    SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                    serializedObject2.Update();
                    m_managerID.intValue = i;
                    serializedObject2.ApplyModifiedProperties();
                    break;
                }
            }
        }

        if (child.GetComponent <focusOnly>())
        {
            for (var i = 0; i < HowManyEntry; i++)
            {
                if (child.GetComponent <focusOnly>().feedbackIDList.Count > 0 &&
                    _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <focusOnly>().feedbackIDList[0].uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                    SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <focusOnly>());
                    SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                    serializedObject2.Update();
                    m_managerID.intValue = i;
                    serializedObject2.ApplyModifiedProperties();
                    break;
                }
            }
        }

        //-> Update : Feedback lock and Unlock
        _textList    = loadTextList("wTextnVoices");
        HowManyEntry = _textList.diaryList[0]._languageSlot.Count;
        if (child.GetComponent <focusOnly>())
        {
            for (var i = 0; i < HowManyEntry; i++)
            {
                if (child.GetComponent <focusOnly>().diaryIDList.Count > 0 &&
                    _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <focusOnly>().diaryIDList[0].uniqueID)
                {
                    Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                    SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <focusOnly>());
                    SerializedProperty m_managerID       = serializedObject2.FindProperty("diaryIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                    serializedObject2.Update();
                    m_managerID.intValue = i;
                    serializedObject2.ApplyModifiedProperties();
                    break;
                }
            }
        }
    }
        void DrawControlMethods()
        {
            GUILayout.Label("Global Settings", EditorStyles.boldLabel);

            //controller
            CurvedUIInputModule.Controller = (CurvedUIInputModule.CurvedUIController)EditorGUILayout.EnumPopup("Control Method", CurvedUIInputModule.Controller);
            GUILayout.BeginHorizontal();
            GUILayout.Space(150);
            GUILayout.BeginVertical();

            switch (CurvedUIInputModule.Controller)
            {
            case CurvedUIInputModule.CurvedUIController.MOUSE:
            {
#if CURVEDUI_GOOGLEVR
                EditorGUILayout.HelpBox("Enabling this control method will disable GoogleVR Gaze support.", MessageType.Warning);

                DrawCustomDefineSwitcher("");
#else
                GUILayout.Label("Basic Controller. Mouse on screen", EditorStyles.helpBox);
                                        #endif
                break;
            }

            case CurvedUIInputModule.CurvedUIController.GAZE:
            {
#if CURVEDUI_GOOGLEVR
                EditorGUILayout.HelpBox("Enabling this control method will disable GoogleVR Gaze support.", MessageType.Warning);

                DrawCustomDefineSwitcher("");
#else
                GUILayout.Label("Center of Canvas's World Camera acts as a pointer. This is a generic gaze implementation, to be used with any headset. If you're on cardboard, use GOOGLEVR control method for Reticle and GameObject interaction support.", EditorStyles.helpBox);
                                        #endif
                break;
            }

            case CurvedUIInputModule.CurvedUIController.WORLD_MOUSE:
            {
#if CURVEDUI_GOOGLEVR
                EditorGUILayout.HelpBox("Enabling this control method will disable GoogleVR Gaze support.", MessageType.Warning);

                DrawCustomDefineSwitcher("");
#else
                GUILayout.Label("Mouse controller that is independent of the camera view. Use WorldSpaceMouseOnCanvas function to get its position.", EditorStyles.helpBox);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Space(150);
                CurvedUIInputModule.Instance.WorldSpaceMouseSensitivity = EditorGUILayout.FloatField("Mouse Sensitivity", CurvedUIInputModule.Instance.WorldSpaceMouseSensitivity);
                                        #endif
                break;
            }

            case CurvedUIInputModule.CurvedUIController.CUSTOM_RAY:
            {
#if CURVEDUI_GOOGLEVR
                EditorGUILayout.HelpBox("Enabling this control method will disable GoogleVR Gaze support.", MessageType.Warning);

                DrawCustomDefineSwitcher("");
#else
                GUILayout.Label("Set a ray used to interact with canvas using CustomControllerRay function. Use CustromControllerButtonDown bool to set button pressed state. \nYou can find both in CurvedUIInputModule class", EditorStyles.helpBox);
                                        #endif
                break;
            }

            case CurvedUIInputModule.CurvedUIController.DAYDREAM:
            {
#if CURVEDUI_GOOGLEVR
                EditorGUILayout.HelpBox("Enabling this control method will disable GoogleVR Gaze Reticle support. It's counter-intuitive, but if you're working with daydream controller - you want this.", MessageType.Warning);

                DrawCustomDefineSwitcher("");
#else
                GUILayout.Label("Set a ray used to find selected objects with CustomControllerRay function. Use CustromControllerButtonDown bool to set button pressed state. /n You can find both of these in CurvedUIInputModule", EditorStyles.helpBox);
                                        #endif
                break;
            }

            case CurvedUIInputModule.CurvedUIController.VIVE:
            {
#if CURVEDUI_VIVE
                // vive enabled, we can show settings
                GUILayout.Label("Use one or both vive controllers as to interact with canvas. Trigger acts a button", EditorStyles.helpBox);
                CurvedUIInputModule.Instance.UsedVRController = (CurvedUIInputModule.ActiveVRController)EditorGUILayout.EnumPopup("Used Controller", CurvedUIInputModule.Instance.UsedVRController);
#else
                DrawCustomDefineSwitcher("CURVEDUI_VIVE");
#endif
                break;
            }

            case CurvedUIInputModule.CurvedUIController.OCULUS_TOUCH:
            {
#if CURVEDUI_TOUCH
                // oculus enabled, we can show settings
                GUILayout.Label("Use Touch controller to interact with canvas.", EditorStyles.helpBox);

                //transform property
                SerializedObject serializedInputModule = new UnityEditor.SerializedObject(CurvedUIInputModule.Instance);
                serializedInputModule.Update();
                EditorGUILayout.PropertyField(serializedInputModule.FindProperty("TouchControllerTransform"));
                serializedInputModule.ApplyModifiedProperties();

                //button property
                CurvedUIInputModule.Instance.OculusTouchInteractionButton = (OVRInput.Button)EditorGUILayout.EnumPopup("Interaction Button", CurvedUIInputModule.Instance.OculusTouchInteractionButton);
#else
                DrawCustomDefineSwitcher("CURVEDUI_TOUCH");
#endif
                break;
            }

            case CurvedUIInputModule.CurvedUIController.GOOGLEVR:
            {
#if CURVEDUI_GOOGLEVR
                GUILayout.Label("Use GoogleVR Reticle to interact with canvas.", EditorStyles.helpBox);
#else
                DrawCustomDefineSwitcher("CURVEDUI_GOOGLEVR");
#endif
                break;
            }
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
            GUILayout.Space(20);
        }
示例#50
0
    public override void OnInspectorGUI()
    {
        if (SeeInspector.boolValue)                                                             // If true Default Inspector is drawn on screen
        {
            DrawDefaultInspector();
        }

        serializedObject.Update();
        Game_Manager myScript = (Game_Manager)target;

        GUIStyle style_Yellow_01     = new GUIStyle(GUI.skin.box);   style_Yellow_01.normal.background = Tex_01;
        GUIStyle style_Blue          = new GUIStyle(GUI.skin.box);   style_Blue.normal.background = Tex_03;
        GUIStyle style_Purple        = new GUIStyle(GUI.skin.box);   style_Purple.normal.background = Tex_04;
        GUIStyle style_Orange        = new GUIStyle(GUI.skin.box);   style_Orange.normal.background = Tex_05;
        GUIStyle style_Yellow_Strong = new GUIStyle(GUI.skin.box);   style_Yellow_Strong.normal.background = Tex_02;

        GUILayout.Label("");

        GUILayout.Label("");
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Inspector :", GUILayout.Width(90));
        EditorGUILayout.PropertyField(SeeInspector, new GUIContent(""), GUILayout.Width(30));
        EditorGUILayout.EndHorizontal();



        GUILayout.Label("");
        EditorGUILayout.HelpBox("This script Manager Game Rules.", MessageType.Info);
        GUILayout.Label("");


        SerializedObject serializedObject2 = new UnityEditor.SerializedObject(myScript.inventoryItemCar);

        serializedObject2.Update();
        SerializedProperty m_b_mobile             = serializedObject2.FindProperty("b_mobile");
        SerializedProperty m_mobileMaxSpeedOffset = serializedObject2.FindProperty("mobileMaxSpeedOffset");
        SerializedProperty mobileWheelStearingOffsetReactivity = serializedObject2.FindProperty("mobileWheelStearingOffsetReactivity");

        //SerializedProperty m_b_LapCounter = serializedObject2.FindProperty ("b_LapCounter");


// -->Mobile Options
        EditorGUILayout.BeginVertical(style_Yellow_Strong);



        EditorGUILayout.HelpBox("IMPORTANT : Modification is applied to the entire project in this section." +
                                "\n" +
                                "\n-You could modify the Max speed for all car on Mobile." +
                                "\n" +
                                "-You could modify the wheel stearing reactivity for all cars on mobile." +
                                "\n", MessageType.Info);

        if (m_b_mobile.boolValue)
        {
            if (GUILayout.Button("Cars are setup for Mobile Inputs"))
            {
                m_b_mobile.boolValue = false;
            }
        }
        else
        {
            if (GUILayout.Button("Cars are setup for Desktop Inputs"))
            {
                m_b_mobile.boolValue = true;
            }
        }


        if (m_b_mobile.boolValue)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Mobile Max Speed Offset :", GUILayout.Width(220));
            EditorGUILayout.PropertyField(m_mobileMaxSpeedOffset, new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Mobile Wheel Stearing Offset Reactivity :", GUILayout.Width(220));
            EditorGUILayout.PropertyField(mobileWheelStearingOffsetReactivity, new GUIContent(""));
            EditorGUILayout.EndHorizontal();
        }



        EditorGUILayout.EndVertical();


// --> Countdown

/*		EditorGUILayout.BeginVertical (style_Orange);
 *              EditorGUILayout.HelpBox("IMPORTANT : Modification is applied to the entire project in this section.",MessageType.Info);
 *
 *              if (m_b_Countdown.boolValue) {
 *                      if (GUILayout.Button ("Countdown is activated when game Start")) {
 *                              //b_UseCountdown.boolValue = false;
 *                              m_b_Countdown.boolValue = false;
 *                      }
 *              } else {
 *                      if (GUILayout.Button ("Countdown is deactivated when game Start")) {
 *                              //b_UseCountdown.boolValue = true;
 *                              m_b_Countdown.boolValue = true;
 *                      }
 *              }
 *              EditorGUILayout.EndVertical ();*/

// --> Lap Counter

        /*	EditorGUILayout.BeginVertical (style_Blue);
         *      EditorGUILayout.HelpBox("IMPORTANT : Modification is applied to the entire project in this section.",MessageType.Info);
         *      if (!lapCounter) {
         *              GameObject tmpObj = GameObject.FindGameObjectWithTag ("TriggerStart");
         *              if (tmpObj)
         *                      lapCounter = tmpObj.GetComponent<LapCounter> ();
         *      }
         *
         *      if (lapCounter) {
         *              //SerializedObject serializedObject1 = new UnityEditor.SerializedObject (lapCounter);
         *              //serializedObject1.Update ();
         *              //SerializedProperty m_b_ActivateLapCounter = serializedObject1.FindProperty ("b_ActivateLapCounter");
         *              //SerializedProperty m_lapNumber = serializedObject1.FindProperty ("lapNumber");
         *
         *
         *              if (m_b_LapCounter.boolValue) {
         *                      if (GUILayout.Button ("Lap Counter is activated")) {
         *                              m_b_LapCounter.boolValue = false;
         *                      }
         *              } else {
         *                      if (GUILayout.Button ("Lap Counter is deactivated")) {
         *                              m_b_LapCounter.boolValue = true;
         *                      }
         *              }
         *
         *              //serializedObject1.ApplyModifiedProperties ();
         *      }
         *      EditorGUILayout.EndVertical ();*/

        serializedObject2.ApplyModifiedProperties();

        GUILayout.Label("");
        GUILayout.Label("");
        // --> Lap Counter
        EditorGUILayout.BeginVertical(style_Yellow_01);
        EditorGUILayout.HelpBox("The next sections only affect this scene.", MessageType.Info);
        if (!lapCounter)
        {
            GameObject tmpObj = GameObject.FindGameObjectWithTag("TriggerStart");
            if (tmpObj)
            {
                lapCounter = tmpObj.GetComponent <LapCounter> ();
            }
        }

        if (lapCounter)
        {
            SerializedObject serializedObject1 = new UnityEditor.SerializedObject(lapCounter);
            serializedObject1.Update();
            //SerializedProperty m_b_ActivateLapCounter = serializedObject1.FindProperty ("b_ActivateLapCounter");
            SerializedProperty m_lapNumber = serializedObject1.FindProperty("lapNumber");

            // --> Lap Numbers
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Lap number:", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_lapNumber, new GUIContent(""));
            EditorGUILayout.EndHorizontal();


            serializedObject1.ApplyModifiedProperties();
        }
        EditorGUILayout.EndVertical();

        GUILayout.Label("");



        EditorGUILayout.BeginVertical(style_Yellow_01);
        EditorGUILayout.HelpBox("Set the number of player for this race.", MessageType.Info);


        // --> Lap Numbers
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Cars number:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(howManyCarsInRace, new GUIContent(""));
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Cars per line:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(numberOfLine, new GUIContent(""));
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Distance between cars on the same line X:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(distanceXbetweenTwoCars, new GUIContent(""));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Offset between two cars on the same line Z:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(distanceZbetweenTwoCarsInSameLine, new GUIContent(""));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Distance between two lines Z:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(distanceZbetweenTwoCars, new GUIContent(""));
        EditorGUILayout.EndHorizontal();

        GUILayout.Label("");

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Offset car AI:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(offsetRoadAi, new GUIContent(""));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("random Range Offset Road AI:", GUILayout.Width(250));
        EditorGUILayout.PropertyField(randomRangeOffsetRoadAI, new GUIContent(""));
        EditorGUILayout.EndHorizontal();



        if (GUILayout.Button("Update"))
        {
            List <float> listFloat = new List <float>();
            float        newValue  = offsetRoadAi.floatValue;
            listFloat.Clear();
            float multipler = 1;
            int   counter   = 0;

            if (numberOfLine.intValue % 2 != 0)
            {
                listFloat.Add(0);
            }

            int howManyEntry = numberOfLine.intValue;
            if (numberOfLine.intValue % 2 != 0)
            {
                howManyEntry = numberOfLine.intValue - 1;
            }

            for (var i = 0; i < howManyEntry; i++)
            {
                listFloat.Add(newValue);

                counter++;
                if (counter % 2 == 0)
                {
                    multipler++;
                    newValue += offsetRoadAi.floatValue;
                }
                counter = counter % 2;
            }

            counter = 0;
            for (var i = 0; i < listFloat.Count; i++)
            {
                if (counter % 2 == 0)
                {
                    listFloat[i] = -listFloat[i];
                }
                counter++;
            }


            string value = "";
            foreach (float val in listFloat)
            {
                value += val + " : ";
            }
            //Debug.Log(value);

            listFloat.Sort();
            value = "";
            foreach (float val in listFloat)
            {
                value += val + " : ";
            }
            // Debug.Log(value);

            //-> Destroy current StartPosition
            GameObject refStartPosition = GameObject.Find("Start_Position_01");

            for (var i = 1; i < 300; i++)
            {
                GameObject tmpPosition = GameObject.Find("Start_Position_0" + (i + 1));
                if (tmpPosition)
                {
                    Undo.DestroyObjectImmediate(tmpPosition);
                }
            }


            //-> Create new Start_Position
            Undo.RegisterFullObjectHierarchyUndo(refStartPosition, refStartPosition.name);
            //float offsetX = distanceXbetweenTwoCars.floatValue;
            float offsetDependingNumberOfLine = distanceXbetweenTwoCars.floatValue * .5f * (numberOfLine.intValue - 1);

            refStartPosition.transform.localPosition = new Vector3(0 - offsetDependingNumberOfLine,
                                                                   -0.4f,
                                                                   1.2f);
            refStartPosition.name = "Start_Position_0" + howManyCarsInRace.intValue;

            //distanceXbetweenTwoCars
            //distanceZbetweenTwoCars
            float newPos    = 0;
            int   newModulo = 0;
            for (var i = howManyCarsInRace.intValue - 1; i > 0; i--)
            {
                //offsetX = -offsetX;

                GameObject tmpPosition = Instantiate(refStartPosition, refStartPosition.transform.parent);
                tmpPosition.name = "Start_Position_0" + i;

                newModulo++;
                newModulo %= numberOfLine.intValue;

                if (newModulo == 0)
                {
                    newPos += .5f + distanceZbetweenTwoCars.floatValue;
                }


                //numberOfLine
                tmpPosition.transform.localPosition = new Vector3(newModulo * distanceXbetweenTwoCars.floatValue - offsetDependingNumberOfLine,
                                                                  -0.4f,
                                                                  1.2f - newPos - distanceZbetweenTwoCarsInSameLine.floatValue * newModulo);

                //tmpPosition.transform.localPosition = new Vector3(offsetX,0,1.5f - howManyCarsInRace.intValue * .5f + (1+i)*.5f);

                Undo.RegisterCreatedObjectUndo(tmpPosition, tmpPosition.name);
            }

            //-> Destroy current target for each car
            GameObject refTarget = GameObject.Find("P1_Target");

            for (var i = 1; i < 300; i++)
            {
                GameObject tmptarget = GameObject.Find("P" + (i + 1) + "_Target");
                if (tmptarget)
                {
                    Undo.DestroyObjectImmediate(tmptarget);
                }
            }

            //-> Create new target for each car
            for (var i = 0; i < howManyCarsInRace.intValue - 1; i++)
            {
                GameObject tmptarget = Instantiate(refTarget);
                tmptarget.name = "P" + (i + 2) + "_Target";
                tmptarget.transform.GetChild(0).name = tmptarget.name + "_Part2";

                Undo.RegisterCreatedObjectUndo(tmptarget, tmptarget.name);
            }


            //-> Create new difficulties parameters
            Undo.RegisterFullObjectHierarchyUndo(myScript, myScript.name);
            for (var i = 0; i < 3; i++)
            {
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].addGlobalSpeedOffset.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointSuccesRate.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMinTarget.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMaxTarget.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].speedSuccesRate.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].speedOffset.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].rotationSuccesRate.Clear();
                myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].rotationOffset.Clear();


                for (var j = 0; j < howManyCarsInRace.intValue - 1; j++)
                {
                    if (j % 3 == 0)
                    {
                        SetCarValue(myScript,
                                    i,
                                    -.2f, 0, 100, 100,
                                    -.05f, 0, 100, 100,
                                    .05f, 0, 100, 100);
                    }
                    else if (j % 3 == 1)
                    {
                        SetCarValue(myScript,
                                    i,
                                    -.1f, 0, 50, 70,
                                    0f, 0, 50, 70,
                                    .15f, 0, 50, 70);
                    }
                    else
                    {
                        SetCarValue(myScript,
                                    i,
                                    0f, 0, 100, 70,
                                    .1f, 0, 100, 70,
                                    .25f, 0, 100, 70);
                    }

                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMinTarget.Add(0);
                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMaxTarget.Add(0);


                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].speedOffset.Add(0);

                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].rotationOffset.Add(-15);

                    counter++;
                    counter = counter % listFloat.Count;
                }

                counter = 0;
                for (var k = howManyCarsInRace.intValue - 2; k >= 0; k--)
                {
                    float newValue2 = returnRandomValue(listFloat[counter]);
                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMinTarget[k] = newValue2;
                    myScript.gameObject.GetComponent <DifficultyManager>().difficulties[i].waypointMaxTarget[k] = newValue2;

                    counter++;
                    counter = counter % listFloat.Count;
                    //Debug.Log("car_" + k);
                }
            }
        }

        EditorGUILayout.EndVertical();

        GUILayout.Label("");


        serializedObject.ApplyModifiedProperties();
    }
示例#51
0
    // --> Update Id for a specific gameObject
    public void Find_UniqueId_In_objRotateTranslate(Transform child)
    {
        TextList _textList;

        //-> Update : Player Object needed in the Inventory
        _textList = loadTextList("wItem");

        int HowManyEntry = _textList.diaryList[0]._languageSlot.Count;

        for (var i = 0; i < HowManyEntry; i++)
        {
            if (child.GetComponent <objTranslateRotate>().inventoryIDList.Count > 0 &&
                _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <objTranslateRotate>().inventoryIDList[0].uniqueID)
            {
                //Debug.Log ("Here : " + i);

                Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <objTranslateRotate>());
                SerializedProperty m_managerID       = serializedObject2.FindProperty("inventoryIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                serializedObject2.Update();
                m_managerID.intValue = i;
                serializedObject2.ApplyModifiedProperties();
                break;
            }
        }


        //-> Update : Voice lock and Unlock
        _textList = loadTextList("wTextnVoices");

        HowManyEntry = _textList.diaryList[0]._languageSlot.Count;

        for (var i = 0; i < HowManyEntry; i++)
        {
            if (child.GetComponent <objTranslateRotate>().diaryIDList.Count > 0 &&
                _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <objTranslateRotate>().diaryIDList[0].uniqueID)
            {
                Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <objTranslateRotate>());
                SerializedProperty m_managerID       = serializedObject2.FindProperty("diaryIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                serializedObject2.Update();
                m_managerID.intValue = i;
                serializedObject2.ApplyModifiedProperties();
                break;
            }
        }
        for (var i = 0; i < HowManyEntry; i++)
        {
            if (child.GetComponent <objTranslateRotate>().diaryIDListUnlock.Count > 0 &&
                _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <objTranslateRotate>().diaryIDListUnlock[0].uniqueID)
            {
                Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <objTranslateRotate>());
                SerializedProperty m_managerID       = serializedObject2.FindProperty("diaryIDListUnlock").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                serializedObject2.Update();
                m_managerID.intValue = i;
                serializedObject2.ApplyModifiedProperties();
                break;
            }
        }


        //-> Update : Feedback lock and Unlock
        _textList = loadTextList("wFeedback");


        HowManyEntry = _textList.diaryList[0]._languageSlot.Count;

        for (var i = 0; i < HowManyEntry; i++)
        {
            if (child.GetComponent <objTranslateRotate>().feedbackIDList.Count > 0 &&
                _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <objTranslateRotate>().feedbackIDList[0].uniqueID)
            {
                Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <objTranslateRotate>());
                SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDList").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                serializedObject2.Update();
                m_managerID.intValue = i;
                serializedObject2.ApplyModifiedProperties();
                break;
            }
        }
        for (var i = 0; i < HowManyEntry; i++)
        {
            if (child.GetComponent <objTranslateRotate>().feedbackIDListUnlock.Count > 0 &&
                _textList.diaryList[0]._languageSlot[i].uniqueItemID == child.GetComponent <objTranslateRotate>().feedbackIDListUnlock[0].uniqueID)
            {
                Undo.RegisterFullObjectHierarchyUndo(child, child.name);
                SerializedObject   serializedObject2 = new UnityEditor.SerializedObject(child.GetComponent <objTranslateRotate>());
                SerializedProperty m_managerID       = serializedObject2.FindProperty("feedbackIDListUnlock").GetArrayElementAtIndex(0).FindPropertyRelative("ID");

                serializedObject2.Update();
                m_managerID.intValue = i;
                serializedObject2.ApplyModifiedProperties();
                break;
            }
        }
    }
    public override void OnInspectorGUI()
    {
        var modConfigSO = new UnityEditor.SerializedObject(ModConfig.Instance);

        modConfigSO.Update();
        serializedObject.Update();

        WorkshopItem item = (WorkshopItem)target;

        //Basic Info
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("WorkshopPublishedFileID"), new GUIContent("Workshop File ID"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("Title"));
        EditorGUILayout.PropertyField(modConfigSO.FindProperty("description"));
        EditorGUILayout.EndVertical();

        //Preview Image
        EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
        using (new EditorGUILayout.VerticalScope())
        {
            EditorGUILayout.LabelField("Preview Image:");
            EditorGUILayout.PropertyField(modConfigSO.FindProperty("previewImage"), new GUIContent());

            if (ModConfig.PreviewImage != null)
            {
                FileInfo f = new FileInfo(AssetDatabase.GetAssetPath(ModConfig.PreviewImage));
                if (f.Exists)
                {
                    EditorGUILayout.LabelField(string.Format("File Size: {0}", WorkshopEditorWindow.FormatFileSize(f.Length)));

                    if (f.Length > 1024 * 1024)
                    {
                        EditorGUILayout.HelpBox("Max allowed size is 1MB", MessageType.Error);
                    }
                }
            }
        }
        GUILayout.Label(ModConfig.PreviewImage, GUILayout.MaxWidth(128), GUILayout.MaxHeight(128));
        EditorGUILayout.EndHorizontal();

        //Tags
        if (item.Tags == null)
        {
            item.Tags = new List <string>();
        }

        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.MaxWidth(128));
        EditorGUILayout.LabelField("Tags:");
        for (int i = 0; i < tags.Length; i++)
        {
            bool hasTag = item.Tags.Contains(tags[i]);

            bool toggled = EditorGUILayout.Toggle(tags[i], hasTag);

            if (hasTag && !toggled)
            {
                item.Tags.Remove(tags[i]);
            }
            else if (!hasTag && toggled)
            {
                item.Tags.Add(tags[i]);
            }
        }
        EditorGUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
        modConfigSO.ApplyModifiedProperties();
    }
示例#53
0
    static void ReadyForMobile()
    {
        #region
        GameObject gameManager = GameObject.Find("Game_Manager");
        if (gameManager)
        {
            SerializedObject serializedObject2 = new UnityEditor.SerializedObject(gameManager.GetComponent <Game_Manager>().inventoryItemCar);
            serializedObject2.Update();
            SerializedProperty m_b_mobile = serializedObject2.FindProperty("b_mobile");
            m_b_mobile.boolValue = true;

            serializedObject2.ApplyModifiedProperties();
            GameObject eventSystem = GameObject.Find("EventSystem");
            if (eventSystem)
            {
                Selection.activeGameObject = eventSystem;
            }
        }

        GameObject canvas_MainMenu = GameObject.Find("Canvas_MainMenu");
        if (canvas_MainMenu)
        {
            SerializedObject serializedObject2 = new UnityEditor.SerializedObject(canvas_MainMenu.GetComponent <Menu_Manager>());
            serializedObject2.Update();
            SerializedProperty m_b_DesktopOrMobile = serializedObject2.FindProperty("b_DesktopOrMobile");
            m_b_DesktopOrMobile.boolValue = true;

            serializedObject2.ApplyModifiedProperties();


            for (int m = 0; m < canvas_MainMenu.GetComponent <Menu_Manager>().List_GroupCanvas.Count; m++)
            {
                for (int i = 0; i < canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject.Count; i++)
                {
                    if (!canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject[i].Desktop)
                    {
                        if (canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject[i].objList)
                        {
                            SerializedObject serializedObject3 = new UnityEditor.SerializedObject(canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject[i].objList);
                            serializedObject3.Update();
                            SerializedProperty tmpSer2 = serializedObject3.FindProperty("m_IsActive");
                            tmpSer2.boolValue = true;
                            serializedObject3.ApplyModifiedProperties();
                        }
                    }
                    else
                    {
                        if (canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject[i].objList)
                        {
                            SerializedObject serializedObject3 = new UnityEditor.SerializedObject(canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject[i].objList);
                            serializedObject3.Update();
                            SerializedProperty tmpSer2 = serializedObject3.FindProperty("m_IsActive");
                            tmpSer2.boolValue = false;
                            serializedObject3.ApplyModifiedProperties();
                        }
                    }
                }
            }



            GameObject eventSystem = GameObject.Find("EventSystem");
            if (eventSystem)
            {
                Selection.activeGameObject = eventSystem;
            }

            Button[] allUIButtons = canvas_MainMenu.GetComponentsInChildren <Button>(true);

            foreach (Button _button in allUIButtons)
            {
                Undo.RegisterFullObjectHierarchyUndo(_button.gameObject, _button.name);

                SerializedObject serializedObject3 = new UnityEditor.SerializedObject(_button.gameObject.GetComponent <Button>());
                serializedObject3.Update();
                SerializedProperty tmpSer2 = serializedObject3.FindProperty("m_Transition");
                tmpSer2.enumValueIndex = 0;                                                                                                                             //_button.transition =  Selectable.Transition.SpriteSwap;
                serializedObject3.ApplyModifiedProperties();
            }
        }

        Debug.Log("MRC Creator : IMPORTANT");
        Debug.Log("-You need to de the Operation ''Ready For Mobile'' on each scene of your project");
        Debug.Log("-Don't forget to use materials for mobile");
        Debug.Log("(More information on documentation)");
        #endregion
    }
    public override void OnInspectorGUI()
    {
        Meshcombinervtwo myScript = (Meshcombinervtwo)target;
        GUIStyle         style    = new GUIStyle(GUI.skin.box);

        style.normal.background = MakeTex(2, 2, new Color(1, 1, 0, .6f));

        serializedObject.Update();

        EditorGUILayout.LabelField("");

        if (SeeInspector.boolValue)
        {
            DrawDefaultInspector();
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("See Variables : ", GUILayout.Width(90));
        EditorGUILayout.PropertyField(SeeInspector, new GUIContent(""));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.LabelField("");

        EditorGUILayout.HelpBox("\n" + "Combine Meshes : " +
                                "\n" +
                                "\n1 - GameObject inside this gameObject are combine." +
                                "\n" +
                                "\nAll the gameObjects with the same material are combine in a single mesh." +
                                "\n" +
                                "\nCombining Process could take time if there are a lots of gameObjects to combine." +
                                "\n" +
                                "\n2 - Choose the ScaleInLightmap then Press button Combine to start the process" +
                                "\n", MessageType.Info);


        EditorGUILayout.BeginVertical(style);
        EditorGUILayout.LabelField("");
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Scale In Lightmap : ", GUILayout.Width(120));
        EditorGUILayout.PropertyField(f_ScaleInLightmap, new GUIContent(""));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Show more options : ", GUILayout.Width(120));
        EditorGUILayout.PropertyField(moreOptions, new GUIContent(""));
        EditorGUILayout.EndHorizontal();

        if (moreOptions.boolValue)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Hard Angle : ", GUILayout.Width(120));
            EditorGUILayout.PropertyField(_HardAngle, new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Pack Margin : ", GUILayout.Width(120));
            EditorGUILayout.PropertyField(_PackMargin, new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Angle Error : ", GUILayout.Width(120));
            EditorGUILayout.PropertyField(_AngleError, new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Area Error : ", GUILayout.Width(120));
            EditorGUILayout.PropertyField(_AreaError, new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Stitch Seams : ", GUILayout.Width(120));
            EditorGUILayout.PropertyField(b_StitchSeams, new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Keep Shadow Mode : ", GUILayout.Width(120));
            EditorGUILayout.PropertyField(keepShadowMode, new GUIContent(""));
            EditorGUILayout.EndHorizontal();
        }


        if (!CombineDone.boolValue)
        {
            if (GUILayout.Button("Combine"))
            {
                b_Combine = true;
            }
        }
        else
        {
            if (GUILayout.Button("Reset"))
            {
                b_Uncombine = true;
            }
        }
        EditorGUILayout.LabelField("");
        EditorGUILayout.EndVertical();
        //

        EditorGUILayout.HelpBox("3 - After the combining process gameObjects are created for each material inside this folder.", MessageType.Info);
        EditorGUILayout.HelpBox("INFO 1 : Mesh renderer are disabled for the gameObjects that have been used in the combining process." +
                                "\nINFO 2 : After combinig process, colliders stay activated.", MessageType.Info);


        EditorGUILayout.LabelField("");
        EditorGUILayout.LabelField("");
        style.normal.background = MakeTex(2, 2, new Color(.5f, .8f, 0, .3f));
        EditorGUILayout.BeginVertical(style);
        EditorGUILayout.HelpBox("(Optional) : Exclude gameObjects with specific TAG", MessageType.Info);
        EditorGUILayout.LabelField("");

        if (GUILayout.Button("Add new tag"))
        {
            b_AddTag = true;
        }
        EditorGUILayout.LabelField("");

        EditorGUILayout.LabelField("Exclude gameObjects with these Tags :");

        for (int i = 0; i < myScript.list_Tags.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PropertyField(list_Tags.GetArrayElementAtIndex(i), new GUIContent(""));
            if (GUILayout.Button("-", GUILayout.Width(20)))
            {
                b_DeleteTag = true;
                deleteNum   = i;
                break;
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndVertical();


        serializedObject.ApplyModifiedProperties();

        if (b_Combine)
        {
            Undo.RegisterCompleteObjectUndo(myScript, "MeshCombiner" + myScript.gameObject.name);
            myScript.CombineDone = true;
            Component[] ChildrenMesh = myScript.GetComponentsInChildren(typeof(MeshRenderer), true);

            myScript.list_Materials.Clear();

            foreach (MeshRenderer child in ChildrenMesh)                                        // Find all the different materials
            {
                myScript.list_Materials.Add(child.sharedMaterial);
            }

            for (int i = 0; i < myScript.list_Materials.Count; i++)                                     // remove materials using multiple time
            {
                for (int k = 0; k < myScript.list_Materials.Count; k++)
                {
                    if (k != i && myScript.list_Materials[i] == myScript.list_Materials[k])
                    {
                        myScript.list_Materials[k] = null;
                    }
                }
            }

            List <Material> Tmp_list_Materials = new List <Material>();                                 // List of materials

            for (int i = 0; i < myScript.list_Materials.Count; i++)                                     // Update Materials List
            {
                if (myScript.list_Materials[i])
                {
                    Tmp_list_Materials.Add(myScript.list_Materials[i]);
                }
            }

            myScript.list_Materials.Clear();

            for (int i = 0; i < Tmp_list_Materials.Count; i++)                                  // Update Materials List
            {
                myScript.list_Materials.Add(Tmp_list_Materials[i]);
            }

            myScript.list_CreatedObjects.Clear();
            myScript.list_CombineObjects.Clear();

            Quaternion oldRot = myScript.transform.rotation;                                                            // Save the original position and rotation of obj
            Vector3    oldPos = myScript.transform.position;

            myScript.transform.rotation = Quaternion.identity;
            myScript.transform.position = new Vector3(0, 0, 0);

            for (int i = 0; i < myScript.list_Materials.Count; i++)
            {
                CombineMeshes(myScript.list_Materials[i]);
            }

            myScript.transform.rotation = oldRot;
            myScript.transform.position = oldPos;

            b_Combine = false;
        }

        if (b_Uncombine)
        {
            Undo.RegisterCompleteObjectUndo(myScript, "MeshCombiner" + myScript.gameObject.name);
            myScript.CombineDone = false;

            for (int i = 0; i < myScript.list_CombineObjects.Count; i++)
            {
                if (myScript.list_CombineObjects[i] != null)
                {
                    SerializedObject serializedObject3 = new UnityEditor.SerializedObject(myScript.list_CombineObjects[i].gameObject.GetComponents <Renderer>());
                    serializedObject3.Update();
                    SerializedProperty tmpSer2 = serializedObject3.FindProperty("m_Enabled");
                    tmpSer2.boolValue = true;
                    serializedObject3.ApplyModifiedProperties();
                }
            }

            for (int i = 0; i < myScript.list_CreatedObjects.Count; i++)
            {
                if (myScript.list_CreatedObjects[i] != null)
                {
                    Undo.DestroyObjectImmediate(myScript.list_CreatedObjects[i]);
                }
            }

            myScript.list_CreatedObjects.Clear();
            myScript.list_CombineObjects.Clear();
            b_Uncombine = false;
        }

        if (b_AddTag)
        {
            Undo.RegisterCompleteObjectUndo(myScript, "Save" + myScript.gameObject.name);
            myScript.list_Tags.Add("Your Tag");
            b_AddTag = false;
        }

        if (b_DeleteTag)
        {
            Undo.RegisterCompleteObjectUndo(myScript, "Delete" + myScript.gameObject.name);
            myScript.list_Tags.RemoveAt(deleteNum);
            b_DeleteTag = false;
        }
    }
示例#55
0
    public override void OnInspectorGUI()
    {
        SeeInspector = EditorGUILayout.Foldout(SeeInspector, "Inspector");

        if (SeeInspector)                                                               // If true Default Inspector is drawn on screen
        {
            DrawDefaultInspector();
        }

        OrderSprites myScript = (OrderSprites)target;

        serializedObject.Update();
        GUIStyle style = new GUIStyle(GUI.skin.box);

        GUILayout.Label("");

        style.normal.background = MakeTex(2, 2, new Color(1, .2f, 0, .3f));

        List <cList_Z_Position> List_Z_Position = new List <cList_Z_Position>();

        style.normal.background = MakeTex(2, 2, new Color(1, 1, 0, .5f));
        EditorGUILayout.BeginVertical(style);
        EditorGUILayout.HelpBox("1 - Choose a unique ''Order in Layer'' for each Sprite" +
                                "\n (Order is choosed depending Transform Z position)", MessageType.Info);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("First Layer : ", GUILayout.Width(100));
        EditorGUILayout.PropertyField(sortingOrderStart, new GUIContent(""), GUILayout.Width(40));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Reverse Order : ", GUILayout.Width(100));
        EditorGUILayout.PropertyField(b_increase, new GUIContent(""));
        EditorGUILayout.EndHorizontal();

        serializedObject.ApplyModifiedProperties();

        if (GUILayout.Button("Order"))
        {
            foreach (Renderer renderer in myScript.gameObject.GetComponentsInChildren <Renderer>())
            {
                List_Z_Position.Add(new cList_Z_Position(renderer.gameObject, Mathf.RoundToInt(renderer.gameObject.transform.position.z * 1000)));
            }

            List_Z_Position.Sort();
            if (b_increase.boolValue)
            {
                List_Z_Position.Reverse();
            }


            int renderOrderOffset = sortingOrderStart.intValue;
            int cmpt = 0;
            for (int i = 0; i < List_Z_Position.Count; i++)
            {
                cmpt++;
                SerializedObject serializedObjectRenderer = new UnityEditor.SerializedObject(List_Z_Position[i].obj.GetComponent <Renderer>());
                serializedObjectRenderer.Update();
                SerializedProperty tmpSer = serializedObjectRenderer.FindProperty("m_SortingOrder");
                tmpSer.intValue = renderOrderOffset;
                serializedObjectRenderer.ApplyModifiedProperties();
                renderOrderOffset++;
            }

            Debug.Log("Info : Order Done : " + cmpt + " file(s)");
        }
        EditorGUILayout.EndVertical();
    }
    //draws wheel settings
    private void drawWheelGUI(GameObject wheelObj)
    {
        //wheel Object
        SerializedObject   wheelTemp = new UnityEditor.SerializedObject(wheelObj.GetComponent <wheel>());
        SerializedProperty steerable, steeringRange, wheelAngle, targetAngle, rotationSpeed, motor, brakeTorque;

        steerable     = wheelTemp.FindProperty("steerable");
        steeringRange = wheelTemp.FindProperty("steeringRange");
        wheelAngle    = wheelTemp.FindProperty("wheelAngle");
        targetAngle   = wheelTemp.FindProperty("targetAngle");
        rotationSpeed = wheelTemp.FindProperty("rotationSpeed");
        brakeTorque   = wheelTemp.FindProperty("brakeTorque");

        motor = wheelTemp.FindProperty("motor");

        //wheel colider settings

        //create a wheel feild inorder to display wheel obj
        WheelCollider wheelColliderTemp = (WheelCollider)wheelTemp.FindProperty("wheelCollider").objectReferenceValue;
        JointSpring   suspensionSpring  = wheelColliderTemp.suspensionSpring;

        wheelTemp.Update();

        //creates a wheel feilds for spring susspenssion
        GUILayout.BeginVertical("box");

        label(wheelObj.name);

        EditorGUILayout.ObjectField(wheelObj, typeof(GameObject));

        header("Wheel Collider");

        wheelColliderTemp.mass = EditorGUILayout.FloatField("mass", wheelColliderTemp.mass);

        wheelColliderTemp.radius /= 2;
        wheelColliderTemp.radius  = EditorGUILayout.Slider("radius", wheelColliderTemp.radius, 0, 25);
        wheelColliderTemp.radius *= 2;

        wheelColliderTemp.wheelDampingRate = EditorGUILayout.Slider("wheel Damping Rate", wheelColliderTemp.wheelDampingRate, 0, 1);

        wheelColliderTemp.suspensionDistance = EditorGUILayout.FloatField("suspension Distance", wheelColliderTemp.suspensionDistance);

        label("Spring");

        suspensionSpring.spring = EditorGUILayout.FloatField("spring", suspensionSpring.spring);

        suspensionSpring.damper = EditorGUILayout.FloatField("damper", suspensionSpring.damper);

        suspensionSpring.targetPosition = EditorGUILayout.Slider("Target Position", suspensionSpring.targetPosition, 0, 1);

        wheelColliderTemp.suspensionSpring = suspensionSpring;

        wheelTemp.FindProperty("wheelCollider").objectReferenceValue = wheelColliderTemp;

        brakeTorque.floatValue = EditorGUILayout.FloatField("Brake Force", brakeTorque.floatValue);

        header("Wheel Tags");

        //creates a toggle feild for steerable or motor
        steerable.boolValue = EditorGUILayout.Toggle("Steerable ", steerable.boolValue);

        motor.boolValue = EditorGUILayout.Toggle("Motor ", motor.boolValue);

        //for loops get every caractersitics of the wheel
        List <string> nameTags     = wheelObj.name.Split(':')[1].Split(',').ToList();
        int           nameTagIndex = 0;

        for (int i1 = 0; i1 < wheelObj.name.Split(':')[1].Split(',').Length; i1++)
        {
            if (wheelObj.name.Split(':')[1].Split(',')[nameTagIndex] != "n" && wheelObj.name.Split(':')[1].Split(',')[nameTagIndex] != "p" && wheelObj.name.Split(':')[1].Split(',')[nameTagIndex] != "s")
            {
                GUILayout.BeginHorizontal();
                nameTags[nameTagIndex] = EditorGUILayout.TextField(nameTags[nameTagIndex]);

                if (GUILayout.Button("Remove Tag"))
                {
                    nameTags.Remove(nameTags[nameTagIndex]);
                    nameTagIndex -= 1;
                }

                GUILayout.EndHorizontal();
            }
            nameTagIndex++;
        }

        if (GUILayout.Button("add tag"))
        {
            nameTags.Add("");
        }

        wheelObj.name = "wheel:" + String.Join(",", nameTags);

        //draws steerable wheel settings
        if (steerable.boolValue)
        {
            label("steering");

            label("Steering Range");

            //creates feild for min and max steering
            steeringRange.GetArrayElementAtIndex(0).floatValue = EditorGUILayout.Slider("Min Range", steeringRange.GetArrayElementAtIndex(0).floatValue, -90, steeringRange.GetArrayElementAtIndex(1).floatValue);
            steeringRange.GetArrayElementAtIndex(1).floatValue = EditorGUILayout.Slider("Max Range", steeringRange.GetArrayElementAtIndex(1).floatValue, steeringRange.GetArrayElementAtIndex(0).floatValue, 90);

            label("start Position");

            //if game is in editor mode then it will allow the user modify the staring angle
            if (EditorApplication.isPlaying == false)
            {
                wheelAngle.floatValue = EditorGUILayout.Slider("Start Angle", wheelAngle.floatValue, steeringRange.GetArrayElementAtIndex(0).floatValue, steeringRange.GetArrayElementAtIndex(1).floatValue);
            }

            //crate feild for target wheel angel
            targetAngle.floatValue = EditorGUILayout.Slider("Target Angle", targetAngle.floatValue, steeringRange.GetArrayElementAtIndex(0).floatValue, steeringRange.GetArrayElementAtIndex(1).floatValue);

            rotationSpeed.floatValue = EditorGUILayout.Slider("Target Angle", rotationSpeed.floatValue, 0, 100);

            if (wheelObj.name.Split(':')[1].Split(',').Contains("s") == false)
            {
                wheelObj.name += ",s";
            }
        }
        else
        {
            //removes steerable caracter
            if (wheelObj.name.Split(':')[1].Split(',').Contains("s"))
            {
                List <string> tempTag = wheelObj.name.Split(':')[1].Split(',').ToList();
                tempTag.Remove("s");
                wheelObj.name = "wheel:" + string.Join(",", tempTag);
            }
        }

        //draws motor wheel settings
        if (motor.boolValue)
        {
            label("Motor");

            //checks if the wheel has the motor caracteristic
            if (wheelObj.name.Split(':')[1].Split(',').Contains("p") == false)
            {
                wheelObj.name += ",p";
            }
        }
        else
        {
            //removes if the wheel has the motor caracteristic
            if (wheelObj.name.Split(':')[1].Split(',').Contains("p"))
            {
                List <string> tempTag = wheelObj.name.Split(':')[1].Split(',').ToList();
                tempTag.Remove("p");
                wheelObj.name = "wheel:" + string.Join(",", tempTag);
            }
        }

        //if wheel has the steerable or motor caracteristic then the neutral wheel is removed
        if (steerable.boolValue || motor.boolValue)
        {
            if (wheelObj.name.Split(':')[1].Split(',').Contains("n"))
            {
                List <string> newName = wheelObj.name.Split(':')[1].Split(',').ToList();
                newName.Remove("n");

                wheelObj.name = "wheel:" + String.Join(",", newName.ToArray());
            }
        }
        //if wheel does not have the steerable or motor caracteristic then the neutral wheel is added
        else
        {
            List <string> newName = wheelObj.name.Split(':')[1].Split(',').ToList();
            newName.Remove("p");
            newName.Remove("s");

            if (wheelObj.name.Split(':')[1].Split(',').Contains("n") == false)
            {
                newName.Add("n");
                wheelObj.name = "wheel:" + String.Join(",", newName.ToArray());
            }
        }

        GUILayout.EndVertical();
        wheelTemp.ApplyModifiedProperties();
    }
    public override void OnInspectorGUI()
    {
        if (SeeInspector.boolValue)                                                             // If true Default Inspector is drawn on screen
        {
            DrawDefaultInspector();
        }

        serializedObject.Update();

        GUIStyle style_Yellow_01     = new GUIStyle(GUI.skin.box);   style_Yellow_01.normal.background = Tex_01;
        GUIStyle style_Blue          = new GUIStyle(GUI.skin.box);   style_Blue.normal.background = Tex_03;
        GUIStyle style_Purple        = new GUIStyle(GUI.skin.box);   style_Purple.normal.background = Tex_04;
        GUIStyle style_Orange        = new GUIStyle(GUI.skin.box);   style_Orange.normal.background = Tex_05;
        GUIStyle style_Yellow_Strong = new GUIStyle(GUI.skin.box);   style_Yellow_Strong.normal.background = Tex_02;



        GUILayout.Label("");
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Inspector :", GUILayout.Width(90));
        EditorGUILayout.PropertyField(SeeInspector, new GUIContent(""), GUILayout.Width(30));
        EditorGUILayout.EndHorizontal();

        SetupDefaultInputs myScript = (SetupDefaultInputs)target;

        GUILayout.Label("");


// --> display default the default Inputs (keyboard and gamepad)
        EditorGUILayout.BeginVertical(style_Yellow_01);
        EditorGUILayout.HelpBox("This script allow to setup the default Inputs (keyboard and gamepad).", MessageType.Info);
        EditorGUILayout.BeginHorizontal();
        //GUILayout.Label( "Countdown text :",GUILayout.Width(100));
        EditorGUILayout.PropertyField(defaultInputsValues, new GUIContent(""));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        GUILayout.Label("");

        if (myScript.defaultInputsValues != null)
        {
            // --> display default the default Inputs (keyboard and gamepad)

            SerializedObject serializedObject0 = new UnityEditor.SerializedObject(myScript.defaultInputsValues);
            serializedObject0.Update();
            SerializedProperty m_gamepadPlayer1 = serializedObject0.FindProperty("ListOfInputs");

            EditorGUILayout.BeginVertical(style_Blue);
// --> Gamepad Player 1 Default
            EditorGUILayout.HelpBox("Player 1 Gamepad", MessageType.Info);

// --> Use preset for PC and Mac
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("XBOX 360 PC"))
            {
                F_XBOX360_PC_P1();
            }
            if (GUILayout.Button("XBOX 360 MAC"))
            {
                F_XBOX360_MAC_P1();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Left :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(0), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Right :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(1), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Acceleration :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(2), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Break :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(3), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Respawn :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(5), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Validate :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(6), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Back :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(7), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Pause :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(8), new GUIContent(""));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();


// --> Keyboard Player 1 Default
            EditorGUILayout.BeginVertical(style_Blue);
            EditorGUILayout.HelpBox("Player 1 Desktop", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Left :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Desktop").GetArrayElementAtIndex(0), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Right :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Desktop").GetArrayElementAtIndex(1), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Acceleration :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Desktop").GetArrayElementAtIndex(2), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Break :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Desktop").GetArrayElementAtIndex(3), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Respawn :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(0).FindPropertyRelative("Desktop").GetArrayElementAtIndex(5), new GUIContent(""));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            GUILayout.Label("");

            EditorGUILayout.BeginVertical(style_Orange);
// --> Gamepad Player 2 Default
            EditorGUILayout.HelpBox("Player 2 Gamepad", MessageType.Info);
// --> Use preset for PC and Mac
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("XBOX 360 PC"))
            {
                F_XBOX360_PC_P2();
            }
            if (GUILayout.Button("XBOX 360 MAC"))
            {
                F_XBOX360_MAC_P2();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Left :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(0), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Right :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(1), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Acceleration :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(2), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Break :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(3), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Respawn :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(5), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Validate :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(6), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Back :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(7), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Pause :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Gamepad").GetArrayElementAtIndex(8), new GUIContent(""));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();


// --> Keyboard Player 2 Default
            EditorGUILayout.BeginVertical(style_Orange);
            EditorGUILayout.HelpBox("Player 2 Desktop", MessageType.Info);
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Left :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Desktop").GetArrayElementAtIndex(0), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Right :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Desktop").GetArrayElementAtIndex(1), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Acceleration :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Desktop").GetArrayElementAtIndex(2), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Break :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Desktop").GetArrayElementAtIndex(3), new GUIContent(""));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Respawn :", GUILayout.Width(100));
            EditorGUILayout.PropertyField(m_gamepadPlayer1.GetArrayElementAtIndex(1).FindPropertyRelative("Desktop").GetArrayElementAtIndex(5), new GUIContent(""));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            GUILayout.Label("");

            serializedObject0.ApplyModifiedProperties();
        }

        GUILayout.Label("");
        serializedObject.ApplyModifiedProperties();
    }
示例#58
0
    static void switchCanvasMenuToMobile()
    {
        GameObject canvas_MainMenu = GameObject.Find("Canvas_MainMenu");

        if (canvas_MainMenu)
        {
            SerializedObject serializedObject2 = new UnityEditor.SerializedObject(canvas_MainMenu.GetComponent <Menu_Manager>());
            serializedObject2.Update();
            SerializedProperty m_b_DesktopOrMobile = serializedObject2.FindProperty("b_DesktopOrMobile");
            m_b_DesktopOrMobile.boolValue = true;

            serializedObject2.ApplyModifiedProperties();


            for (int m = 0; m < canvas_MainMenu.GetComponent <Menu_Manager>().List_GroupCanvas.Count; m++)
            {
                for (int i = 0; i < canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject.Count; i++)
                {
                    if (!canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject[i].Desktop)
                    {
                        if (canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject[i].objList)
                        {
                            SerializedObject serializedObject3 = new UnityEditor.SerializedObject(canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject[i].objList);
                            serializedObject3.Update();
                            SerializedProperty tmpSer2 = serializedObject3.FindProperty("m_IsActive");
                            tmpSer2.boolValue = true;
                            serializedObject3.ApplyModifiedProperties();
                        }
                    }
                    else
                    {
                        if (canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject[i].objList)
                        {
                            SerializedObject serializedObject3 = new UnityEditor.SerializedObject(canvas_MainMenu.GetComponent <Menu_Manager>().list_gameObjectByPage[m].listOfMenuGameobject[i].objList);
                            serializedObject3.Update();
                            SerializedProperty tmpSer2 = serializedObject3.FindProperty("m_IsActive");
                            tmpSer2.boolValue = false;
                            serializedObject3.ApplyModifiedProperties();
                        }
                    }
                }
            }



            GameObject eventSystem = GameObject.Find("EventSystem");
            if (eventSystem)
            {
                Selection.activeGameObject = eventSystem;
            }

            Button[] allUIButtons = canvas_MainMenu.GetComponentsInChildren <Button>(true);

            foreach (Button _button in allUIButtons)
            {
                Undo.RegisterFullObjectHierarchyUndo(_button.gameObject, _button.name);

                SerializedObject serializedObject3 = new UnityEditor.SerializedObject(_button.gameObject.GetComponent <Button>());
                serializedObject3.Update();
                SerializedProperty tmpSer2 = serializedObject3.FindProperty("m_Transition");
                tmpSer2.enumValueIndex = 0;                                                                                                                             //_button.transition =  Selectable.Transition.none;
                serializedObject3.ApplyModifiedProperties();
            }
        }
    }
示例#59
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        PathCircuit myScript = (PathCircuit)target;

        serializedObject.Update();
        GUIStyle style = new GUIStyle(GUI.skin.box);

        GUILayout.Label("");

        style.normal.background = MakeTex(2, 2, new Color(1, .2f, 0, .3f));


        EditorGUILayout.HelpBox("How to create a new path :" +
                                "\n1 - Select this gameobject on the Hierarchy (" + myScript.name + ")." +
                                "\n2 - Select the ''Scene Tab'' (click on the icon named Scene)" +
                                "\n3 - Press keyboard ''F'' button to activate the focus mode" +
                                "\n4 - Put your mouse where you want to create a new checkpoint." +
                                "\n5 - Press keyboard ''J'' button to create a new checkpoint" +
                                "\nCheckpoint is created only if there a gameObject under the mouse position", MessageType.Info);



        EditorGUILayout.HelpBox(
            "\n7 - Press button ''Create'' when all the checkpoints are created"
            , MessageType.Info);


// --> Create the path
        if (GUILayout.Button("Create Path"))                                                                                                                                            // --> Create path using checkpoints in Track_Path gameObject
        {
            var track       = waypoint.waypointList.circuit;                                                                                                                            // Access Waypoint list
            var checkPoints = new Transform[track.transform.childCount];                                                                                                                // Know the number of checkpoints
            int n           = 0;
            foreach (Transform checkpoint in track.transform)
            {
                checkPoints[n++] = checkpoint;
            }
            Array.Sort(checkPoints, new TransformNameComparer());
            track.waypointList.items = new Transform[checkPoints.Length];
            for (n = 0; n < checkPoints.Length; ++n)
            {
                track.waypointList.items[n] = checkPoints[n];
            }

            for (int i = 0; i < waypoint.waypointList.items.Length - 1; i++)                                                                                                            //checkpoints look forward
            {
                waypoint.waypointList.items[i].LookAt(waypoint.waypointList.items[i + 1]);
            }

            waypoint.waypointList.items[waypoint.waypointList.items.Length - 1].LookAt(waypoint.waypointList.items[0]);

            for (int i = 0; i < waypoint.waypointList.items.Length; i++)
            {
                waypoint.waypointList.items[i].localEulerAngles = new Vector3(0,
                                                                              waypoint.waypointList.items[i].localEulerAngles.y,
                                                                              waypoint.waypointList.items[i].localEulerAngles.z);
            }


            GameObject tmpObj = GameObject.Find("Grp_StartLine");                                                                                                                       // --> Update StartLine group position
            if (tmpObj)
            {
                Undo.RegisterFullObjectHierarchyUndo(tmpObj, tmpObj.name);
                SerializedObject serializedObject0 = new UnityEditor.SerializedObject(tmpObj.GetComponent <Transform> ());
                serializedObject0.Update();
                SerializedProperty m_LocalPos = serializedObject0.FindProperty("m_LocalPosition");

                m_LocalPos.vector3Value = new Vector3(
                    waypoint.waypointList.items[0].transform.position.x,
                    waypoint.waypointList.items[0].transform.position.y + .5f,
                    waypoint.waypointList.items[0].transform.position.z);


                serializedObject0.ApplyModifiedProperties();

                tmpObj.transform.eulerAngles = waypoint.waypointList.items [0].transform.eulerAngles;
            }
        }

        GUILayout.Label("");

        EditorGUILayout.HelpBox(
            "Checkpoints are used to respawn cars. So : " +
            "\n-Add your checkpoints on road." +
            "\n-Not to close a jump" +
            "\n-Not on a cliff", MessageType.Info);


        GUILayout.Label("");

        EditorGUILayout.HelpBox(
            "You need to ''open'' the script ''Waypoint Circuit'' on the Inspector to see the path. Click on gray rectangle beside the logo c#", MessageType.Warning);


        GUILayout.Label("");

// --> Delete the path
        if (GUILayout.Button("Delete Path"))
        {
            Undo.RegisterFullObjectHierarchyUndo(myScript, "Reset_" + myScript.name);

            int children = myScript.transform.childCount;

            for (int i = children - 1; i >= 0; i--)
            {
                Undo.DestroyObjectImmediate(myScript.transform.GetChild(i).gameObject);
            }

            waypoint.waypointList.items = new Transform[0];
        }


        GUILayout.Label("");

        serializedObject.ApplyModifiedProperties();
    }
    public void CombineMeshes(Material mat)                                                                                             // -> Combine all the maesh with a specif material.
    {
        Meshcombinervtwo myScript = (Meshcombinervtwo)target;

        GameObject newGameObject = new GameObject();

        newGameObject.AddComponent <MeshFilter>();
        newGameObject.AddComponent <MeshRenderer>();

        newGameObject.GetComponent <Renderer>().sharedMaterial = null;

        newGameObject.name = "Combine_" + mat.name;
        Undo.RegisterCreatedObjectUndo(newGameObject, "CombineMat" + mat.name);

        myScript.list_CreatedObjects.Add(newGameObject);

        bool OneMesh = false;                                                                                   // This variable is used to know if there is at least one mesh to combine

        newGameObject.transform.rotation = Quaternion.identity;                                                 // Init position to zero

        newGameObject.transform.SetParent(myScript.transform);
        newGameObject.transform.localPosition = new Vector3(0, 0, 0);                                                                   // Init position to Vector3(0,0,0)
        newGameObject.isStatic = true;

        MeshFilter[] filters = myScript.gameObject.GetComponentsInChildren <MeshFilter>(); // Find all the children with MeshFilter component

        Mesh finalMesh = new Mesh();                                                       // Create the new mesh

        CombineInstance[] combiners = new CombineInstance[filters.Length];                 // Struct used to describe meshes to be combined using Mesh.CombineMeshes.

        UnityEngine.Rendering.ShadowCastingMode currentShadowMode = UnityEngine.Rendering.ShadowCastingMode.On;

        for (int i = 0; i < filters.Length; i++)                                                                // Check all the children
        {
            if (filters[i].transform == myScript.gameObject.transform)                                          // Do not select the parent himself
            {
                continue;
            }
            if (filters[i].gameObject.GetComponent <Renderer>() == null)                        // Check if there is Renderer component
            {
                continue;
            }
            bool checkTag = false;
            for (int j = 0; j < myScript.list_Tags.Count; j++)                                                          // Check tag to know if you need to ignore this gameobject
            {
                if (filters[i].gameObject.tag == myScript.list_Tags[j])
                {
                    checkTag = true;
                }
            }

            if (mat == filters[i].gameObject.GetComponent <Renderer>().sharedMaterial&& !checkTag &&            // Add this gameObject to the combiner
                filters[i].gameObject.GetComponent <Renderer>().enabled)
            {
                combiners[i].subMeshIndex = 0;
                combiners[i].mesh         = filters[i].sharedMesh;

                combiners[i].transform = filters[i].transform.localToWorldMatrix;

                myScript.list_CombineObjects.Add(filters[i].gameObject);

                SerializedObject serializedObject3 = new UnityEditor.SerializedObject(filters[i].gameObject.GetComponents <Renderer>());
                serializedObject3.Update();
                SerializedProperty tmpSer2 = serializedObject3.FindProperty("m_Enabled");
                tmpSer2.boolValue = false;
                serializedObject3.ApplyModifiedProperties();


                currentShadowMode = filters[i].GetComponent <Renderer>().shadowCastingMode;

                OneMesh = true;
            }
        }

        finalMesh.CombineMeshes(combiners);                                                     // Combine the new mesh
        newGameObject.GetComponent <MeshFilter>().sharedMesh = finalMesh;                       // Create the new Mesh Filter
        newGameObject.GetComponent <Renderer>().material     = mat;                             // ADd the good material


        // newGameObject.GetComponent<MeshRenderer>().
        Change_Scaleinlightmap(newGameObject, OneMesh, finalMesh, myScript);

        if (keepShadowMode.boolValue == true)                    // use the shadow mode find find on the last combine object
        {
            UpdateCasShadowMode(newGameObject, currentShadowMode);
        }
    }