ApplyModifiedProperties() private méthode

private ApplyModifiedProperties ( ) : bool
Résultat bool
Exemple #1
0
    public static bool AddAxis( AxisDefinition axis )
    {
        if( AxisDefined( axis.name ) )
        {
            return false;
        }

        SerializedObject serializedObject = new SerializedObject( AssetDatabase.LoadAllAssetsAtPath( "ProjectSettings/InputManager.asset" )[0] );
        SerializedProperty axesProperty = serializedObject.FindProperty( "m_Axes" );

        axesProperty.arraySize++;
        serializedObject.ApplyModifiedProperties();

        SerializedProperty axisProperty = axesProperty.GetArrayElementAtIndex( axesProperty.arraySize - 1 );

        GetChildProperty( axisProperty, "m_Name" ).stringValue = axis.name;
        GetChildProperty( axisProperty, "descriptiveName" ).stringValue = axis.descriptiveName;
        GetChildProperty( axisProperty, "descriptiveNegativeName" ).stringValue = axis.descriptiveNegativeName;
        GetChildProperty( axisProperty, "negativeButton" ).stringValue = axis.negativeButton;
        GetChildProperty( axisProperty, "positiveButton" ).stringValue = axis.positiveButton;
        GetChildProperty( axisProperty, "altNegativeButton" ).stringValue = axis.altNegativeButton;
        GetChildProperty( axisProperty, "altPositiveButton" ).stringValue = axis.altPositiveButton;
        GetChildProperty( axisProperty, "gravity" ).floatValue = axis.gravity;
        GetChildProperty( axisProperty, "dead" ).floatValue = axis.dead;
        GetChildProperty( axisProperty, "sensitivity" ).floatValue = axis.sensitivity;
        GetChildProperty( axisProperty, "snap" ).boolValue = axis.snap;
        GetChildProperty( axisProperty, "invert" ).boolValue = axis.invert;
        GetChildProperty( axisProperty, "type" ).intValue = (int)axis.type;
        GetChildProperty( axisProperty, "axis" ).intValue = axis.axis - 1;
        GetChildProperty( axisProperty, "joyNum" ).intValue = axis.joyNum;

        serializedObject.ApplyModifiedProperties();
        return true;
    }
		public override void createMecanimResources(GAFAnimationAssetInternal _Asset)
		{
			var serializedAsset = new SerializedObject(_Asset);
			var mecanimFolder = serializedAsset.FindProperty("m_MecanimResourcesDirectory");

			var mecanimFolderPath = string.Empty;
			if (!string.IsNullOrEmpty(mecanimFolder.stringValue) &&
				System.IO.Directory.Exists(Application.dataPath + "/" + mecanimFolder.stringValue))
			{
				mecanimFolderPath = "Assets/" + mecanimFolder.stringValue;
			}
			else
			{
				var assetDirectoryPath = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(_Asset));
				mecanimFolderPath = assetDirectoryPath + "/" + _Asset.name + "_animator/";
				mecanimFolder.stringValue = mecanimFolderPath.Substring("Assets/".Length, mecanimFolderPath.Length - "Assets/".Length);
				serializedAsset.ApplyModifiedProperties();

				if (!System.IO.Directory.Exists(Application.dataPath + "/" + mecanimFolderPath.Substring("Assets/".Length, mecanimFolderPath.Length - "Assets/".Length)))
					AssetDatabase.CreateFolder(assetDirectoryPath, _Asset.name + "_animator");
			}

			List<RuntimeAnimatorController> controllersList = new List<RuntimeAnimatorController>();
			foreach (var timeline in _Asset.getTimelines())
			{
				var controllerPath = mecanimFolderPath + "[" + _Asset.name + "]_Timeline_" + timeline.linkageName + ".controller";
				var animatorController = AssetDatabase.LoadAssetAtPath(controllerPath, typeof(AnimatorController)) as AnimatorController;
				if (animatorController == null)
					animatorController = AnimatorController.CreateAnimatorControllerAtPath(controllerPath);

				createAnimations(timeline, animatorController, mecanimFolderPath);

				controllersList.Add(animatorController);
			}

			var controllers = serializedAsset.FindProperty("m_AnimatorControllers");
			controllers.ClearArray();
			for (int i = 0; i < controllersList.Count; ++i)
			{
				controllers.InsertArrayElementAtIndex(0);
				var property = controllers.GetArrayElementAtIndex(0);
				property.objectReferenceValue = controllersList[i];
			}

			serializedAsset.ApplyModifiedProperties();

			AssetDatabase.SaveAssets();
			AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
		}
    public void ShurikenParticleScaleChange(float _Value)
    {
        ParticleSystem[] ParticleSystems = GetComponentsInChildren<ParticleSystem>();

        transform.localScale *= _Value;

        foreach(ParticleSystem _ParticleSystem in ParticleSystems) {
            _ParticleSystem.startSpeed *= _Value;
            _ParticleSystem.startSize *= _Value;
            _ParticleSystem.gravityModifier *= _Value;
            SerializedObject _SerializedObject = new SerializedObject(_ParticleSystem);
            _SerializedObject.FindProperty("CollisionModule.particleRadius").floatValue *= _Value;
            _SerializedObject.FindProperty("ShapeModule.radius").floatValue *= _Value;
            _SerializedObject.FindProperty("ShapeModule.boxX").floatValue *= _Value;
            _SerializedObject.FindProperty("ShapeModule.boxY").floatValue *= _Value;
            _SerializedObject.FindProperty("ShapeModule.boxZ").floatValue *= _Value;
            _SerializedObject.FindProperty("VelocityModule.x.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("VelocityModule.y.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("VelocityModule.z.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("ClampVelocityModule.x.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("ClampVelocityModule.y.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("ClampVelocityModule.z.scalar").floatValue *= _Value;
            _SerializedObject.FindProperty("ClampVelocityModule.magnitude.scalar").floatValue *= _Value;
            _SerializedObject.ApplyModifiedProperties();
        }
    }
        private string ShowComponents(SerializedObject objTarget, GameObject gameObject)
        {
            var targetComponentAssemblyName = objTarget.FindProperty("targetComponentAssemblyName");
            var targetComponentFullname = objTarget.FindProperty("targetComponentFullname");
            var targetComponentText = objTarget.FindProperty("targetComponentText");
            var objComponents = gameObject.GetComponents<Component>();
            var objTypesAssemblynames = (from objComp in objComponents select objComp.GetType().AssemblyQualifiedName).ToList();
            var objTypesName = (from objComp in objComponents select objComp.GetType().Name).ToList();

            int index = objTypesAssemblynames.IndexOf(targetComponentAssemblyName.stringValue);

            index = EditorGUILayout.Popup("Target Component", index, objTypesName.ToArray());

            if (index != -1)
            {
                targetComponentAssemblyName.stringValue = objTypesAssemblynames[index];
                targetComponentFullname.stringValue = objComponents.GetType().FullName;
                targetComponentText.stringValue = objTypesName[index];
            }
            else
            {
                targetComponentAssemblyName.stringValue = null;
            }

            objTarget.ApplyModifiedProperties();

            return targetComponentAssemblyName.stringValue;
        }
Exemple #5
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();
    }
	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];
				}
			}
		}

	}
    void OnGUI()
    {
        m_Type = (ItemType)EditorGUILayout.EnumPopup("Item Type", m_Type);
        m_strName = EditorGUILayout.TextField("Name", m_strName);
        m_strDescription = EditorGUILayout.TextField("Description", m_strDescription);

        ScriptableObject target = this;
        SerializedObject so = new SerializedObject(target);
        SerializedProperty sp_picNames = so.FindProperty("m_strPicNames");
        SerializedProperty sp_childItems = so.FindProperty("m_iChildItems");

        EditorGUILayout.PropertyField(sp_picNames, true);
        EditorGUILayout.PropertyField(sp_childItems, true);
        so.ApplyModifiedProperties();


        if (GUILayout.Button("Create"))
        {
            ItemInfo info = new ItemInfo();
            info.m_iID = 0;
            info.m_Type = m_Type;
            info.m_strName = m_strName;
            info.m_strDescription = m_strDescription;
            info.m_iPhotoIDs = m_iPhotoIDs;
            info.m_iChildIDs = m_iChildIDs;

            WriteItemInfo(info);
        }
    }
	void OnEnable () {
		so = new SerializedObject (target);
			
		cameras = so.FindProperty("m_Cameras");
		shadowmapMode = so.FindProperty("m_ShadowmapMode");
		size = so.FindProperty("m_Size");
		near = so.FindProperty("m_SpotNear");
		far = so.FindProperty("m_SpotFar");
		cullingMask = so.FindProperty("m_CullingMask");
		colorFilterMask = so.FindProperty("m_ColorFilterMask");
		brightness = so.FindProperty("m_Brightness");
		brightnessColored = so.FindProperty("m_BrightnessColored");
		extinction = so.FindProperty("m_Extinction");
		minDistFromCamera = so.FindProperty("m_MinDistFromCamera");
		shadowmapRes = so.FindProperty("m_ShadowmapRes");
		colored = so.FindProperty("m_Colored");
		colorBalance = so.FindProperty("m_ColorBalance");
		epipolarLines = so.FindProperty("m_EpipolarLines");
		epipolarSamples = so.FindProperty("m_EpipolarSamples");
		depthThreshold = so.FindProperty("m_DepthThreshold");
		interpolationStep = so.FindProperty("m_InterpolationStep");
		showSamples = so.FindProperty("m_ShowSamples");
		//showInterpolatedSamples = so.FindProperty("m_ShowInterpolatedSamples");
		backgroundFade = so.FindProperty("m_ShowSamplesBackgroundFade");

		attenuationCurveOn = so.FindProperty("m_AttenuationCurveOn");
		attenuationCurve = so.FindProperty("m_AttenuationCurve");
		if (attenuationCurve.animationCurveValue.length == 0)
		{
			attenuationCurve.animationCurveValue = new AnimationCurve(new Keyframe(0, 1.0f),new Keyframe(1, 0.0f));
			so.ApplyModifiedProperties ();
			(so.targetObject as LightShafts).gameObject.SendMessage ("UpdateLUTs");
		}
	}
        public override void DrawCommandGUI()
        {
            base.DrawCommandGUI();

            targetMethod = target as InvokeMethod;

            if (targetMethod == null || targetMethod.targetObject == null)
                return;

            SerializedObject objSerializedTarget = new SerializedObject(targetMethod);

            string component = ShowComponents(objSerializedTarget, targetMethod.targetObject);

            // show component methods if selected
            if (!string.IsNullOrEmpty(component))
            {
                var method = ShowMethods(objSerializedTarget, targetMethod.targetObject, component);

                // show method parameters if selected
                if (method != null)
                {
                    objSerializedTarget.ApplyModifiedProperties();
                    ShowParameters(objSerializedTarget, targetMethod.targetObject, method);
                    ShowReturnValue(objSerializedTarget, method);
                }
            }
        }
    //Change Color
    private void applyColor()
    {
        foreach(GameObject go in Selection.gameObjects)
        {
            ParticleSystem[] systems;
            if(IncludeChildren)		systems = go.GetComponentsInChildren<ParticleSystem>(true);
            else 					systems = go.GetComponents<ParticleSystem>();

            foreach(ParticleSystem ps in systems)
            {
                SerializedObject psSerial = new SerializedObject(ps);
                if(!AffectAlpha)
                {
                    psSerial.FindProperty("InitialModule.startColor.maxColor").colorValue = new Color(ColorValue.r, ColorValue.g, ColorValue.b, psSerial.FindProperty("InitialModule.startColor.maxColor").colorValue.a);
                    psSerial.FindProperty("InitialModule.startColor.minColor").colorValue = new Color(ColorValue2.r, ColorValue2.g, ColorValue2.b, psSerial.FindProperty("InitialModule.startColor.minColor").colorValue.a);
                }
                else
                {
                    psSerial.FindProperty("InitialModule.startColor.maxColor").colorValue = ColorValue;
                    psSerial.FindProperty("InitialModule.startColor.minColor").colorValue = ColorValue2;
                }
                psSerial.ApplyModifiedProperties();
            }
        }
    }
Exemple #11
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 ();

		}
        void OnEnable () {
            serObj = new SerializedObject (target);

            mode = serObj.FindProperty ("mode");

            saturation = serObj.FindProperty ("saturation");

            redChannel = serObj.FindProperty ("redChannel");
            greenChannel = serObj.FindProperty ("greenChannel");
            blueChannel = serObj.FindProperty ("blueChannel");

            useDepthCorrection = serObj.FindProperty ("useDepthCorrection");

            zCurveChannel = serObj.FindProperty ("zCurve");

            depthRedChannel = serObj.FindProperty ("depthRedChannel");
            depthGreenChannel = serObj.FindProperty ("depthGreenChannel");
            depthBlueChannel = serObj.FindProperty ("depthBlueChannel");

            serObj.ApplyModifiedProperties ();

            selectiveCc = serObj.FindProperty ("selectiveCc");
            selectiveFromColor = serObj.FindProperty ("selectiveFromColor");
            selectiveToColor = serObj.FindProperty ("selectiveToColor");
        }
Exemple #13
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();
		}
        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();
        }
Exemple #15
0
    void ScaleShurikenSystems(float scaleFactor)
    {
        //get all shuriken systems we need to do scaling on
        ParticleSystem[] systems = GetComponentsInChildren<ParticleSystem>();

        foreach (ParticleSystem system in systems)
        {
            system.startSpeed *= scaleFactor;
            system.startSize *= scaleFactor;
            system.gravityModifier *= scaleFactor;

            //some variables cannot be accessed through regular script, we will acces them through a serialized object
            SerializedObject so = new SerializedObject(system);

            so.FindProperty("ShapeModule.radius").floatValue *= scaleFactor;
            so.FindProperty("ShapeModule.boxX").floatValue *= scaleFactor;
            so.FindProperty("ShapeModule.boxY").floatValue *= scaleFactor;
            so.FindProperty("ShapeModule.boxZ").floatValue *= scaleFactor;
            so.FindProperty("VelocityModule.x.scalar").floatValue *= scaleFactor;
            so.FindProperty("VelocityModule.y.scalar").floatValue *= scaleFactor;
            so.FindProperty("VelocityModule.z.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.magnitude.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.x.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.y.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.z.scalar").floatValue *= scaleFactor;
            so.FindProperty("ForceModule.x.scalar").floatValue *= scaleFactor;
            so.FindProperty("ForceModule.y.scalar").floatValue *= scaleFactor;
            so.FindProperty("ForceModule.z.scalar").floatValue *= scaleFactor;
            so.FindProperty("ColorBySpeedModule.range").vector2Value *= scaleFactor;
            so.FindProperty("SizeBySpeedModule.range").vector2Value *= scaleFactor;
            so.FindProperty("RotationBySpeedModule.range").vector2Value *= scaleFactor;

            so.ApplyModifiedProperties();
        }
    }
    //OnInspectorGUI///////////////////////////////////////////////////////////
    public override void OnInspectorGUI()
    {
        SerializedObject soTarget = new SerializedObject(target);
        SerializedProperty spColSiz = soTarget.FindProperty("m_AnchorCollSize");
        SerializedProperty spAncArr = soTarget.FindProperty("m_AnchorArr");
        SerializedProperty spSpaArr = soTarget.FindProperty("m_SpawnArr");
        SerializedProperty spGizmoLine = soTarget.FindProperty("onDrawGizmosLine");
        SerializedProperty spGizmoColl = soTarget.FindProperty("onDrawGizmosColl");
        SerializedProperty spGizmoSpDr = soTarget.FindProperty("onDrawGizmosSpDr");

        this.GroupEditBox(spAncArr, spSpaArr);

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
        GUILayout.Label("isDrowGimo", GUILayout.Width(76f));
        GUILayout.Label("Line");
        spGizmoLine.boolValue = EditorGUILayout.Toggle(spGizmoLine.boolValue);
        GUILayout.Label("Coll");
        spGizmoColl.boolValue = EditorGUILayout.Toggle(spGizmoColl.boolValue);
        GUILayout.Label("Spaw");
        spGizmoSpDr.boolValue = EditorGUILayout.Toggle(spGizmoSpDr.boolValue);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        spColSiz.floatValue = EditorGUILayout.FloatField( "AnchorCollSize", spColSiz.floatValue);

        this.ClassArrField(spAncArr, "AnchorData", ref sta_fAncFoldut, AnchorDataField);
        this.ClassArrField(spSpaArr, "SpawnPoint", ref sta_fSpaFoldut, SpawnPointField);

        //適用-----------------------------------------------------------------
        soTarget.ApplyModifiedProperties();
    }
	static void createLayer(){
		SerializedObject SerializedObjectTagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
		SerializedProperty it = SerializedObjectTagManager.GetIterator();

		bool showChildren = true;

#if UNITY_5

		while(it.NextVisible (showChildren)){
			Debug.Log(it.displayName);


			if(it.displayName == "Element 8"){
//				it.stringValue = "ShadowLayer";
			}

		}



#else
		while(it.NextVisible (showChildren)){
			
			if(it.name == "User Layer 8"){
//				it.stringValue = "ShadowLayer";
			}
			
		}
		//mmmm
#endif

		SerializedObjectTagManager.ApplyModifiedProperties();

	}
 internal override void Apply()
 {
     MappingRelevantSettings[] sourceArray = new MappingRelevantSettings[base.targets.Length];
     for (int i = 0; i < base.targets.Length; i++)
     {
         SerializedObject obj2 = new SerializedObject(base.targets[i]);
         SerializedProperty property = obj2.FindProperty("m_AnimationType");
         SerializedProperty property2 = obj2.FindProperty("m_CopyAvatar");
         sourceArray[i].humanoid = property.intValue == 3;
         sourceArray[i].hasNoAnimation = property.intValue == 0;
         sourceArray[i].copyAvatar = property2.boolValue;
     }
     MappingRelevantSettings[] destinationArray = new MappingRelevantSettings[base.targets.Length];
     Array.Copy(sourceArray, destinationArray, base.targets.Length);
     for (int j = 0; j < base.targets.Length; j++)
     {
         if (!this.m_AnimationType.hasMultipleDifferentValues)
         {
             destinationArray[j].humanoid = this.m_AnimationType.intValue == 3;
         }
         if (!this.m_CopyAvatar.hasMultipleDifferentValues)
         {
             destinationArray[j].copyAvatar = this.m_CopyAvatar.boolValue;
         }
     }
     base.serializedObject.ApplyModifiedProperties();
     for (int k = 0; k < base.targets.Length; k++)
     {
         if (sourceArray[k].usesOwnAvatar && !destinationArray[k].usesOwnAvatar)
         {
             SerializedObject serializedObject = new SerializedObject(base.targets[k]);
             AvatarSetupTool.ClearAll(serializedObject);
             serializedObject.ApplyModifiedProperties();
         }
         if (!sourceArray[k].usesOwnAvatar && destinationArray[k].usesOwnAvatar)
         {
             ModelImporter importer = base.targets[k] as ModelImporter;
             if (sourceArray[k].hasNoAnimation)
             {
                 AssetDatabase.ImportAsset(importer.assetPath);
             }
             SerializedObject modelImporterSerializedObject = new SerializedObject(base.targets[k]);
             GameObject original = AssetDatabase.LoadMainAssetAtPath(importer.assetPath) as GameObject;
             Animator component = original.GetComponent<Animator>();
             bool flag = (component != null) && !component.hasTransformHierarchy;
             if (flag)
             {
                 original = UnityEngine.Object.Instantiate<GameObject>(original);
                 AnimatorUtility.DeoptimizeTransformHierarchy(original);
             }
             AvatarSetupTool.AutoSetupOnInstance(original, modelImporterSerializedObject);
             this.m_IsBiped = AvatarBipedMapper.IsBiped(original.transform);
             if (flag)
             {
                 UnityEngine.Object.DestroyImmediate(original);
             }
             modelImporterSerializedObject.ApplyModifiedProperties();
         }
     }
 }
    void ScaleLegacySystems(float scaleFactor)
    {
        //get all emitters we need to do scaling on
        ParticleEmitter[] emitters = GetComponentsInChildren<ParticleEmitter>();

        //get all animators we need to do scaling on
        ParticleAnimator[] animators = GetComponentsInChildren<ParticleAnimator>();

        //apply scaling to emitters
        foreach (ParticleEmitter emitter in emitters)
        {
            emitter.minSize *= scaleFactor;
            emitter.maxSize *= scaleFactor;
            emitter.worldVelocity *= scaleFactor;
            emitter.localVelocity *= scaleFactor;
            emitter.rndVelocity *= scaleFactor;

            //some variables cannot be accessed through regular script, we will acces them through a serialized object
            SerializedObject so = new SerializedObject(emitter);

            so.FindProperty("m_Ellipsoid").vector3Value *= scaleFactor;
            so.FindProperty("tangentVelocity").vector3Value *= scaleFactor;
            so.ApplyModifiedProperties();
        }

        //apply scaling to animators
        foreach (ParticleAnimator animator in animators)
        {
            animator.force *= scaleFactor;
            animator.rndForce *= scaleFactor;
        }
    }
    public override void OnInspectorGUI()
    {
        SerializedObject myScript = new SerializedObject(target);
        SerializedProperty SpawnGameObject = myScript.FindProperty("SpawnGameObject");
        SerializedProperty SpawnTime = myScript.FindProperty("SpawnTime");
        SerializedProperty DependOnThisState = myScript.FindProperty("DependOnThisState");
        SerializedProperty DestroyTime = myScript.FindProperty("DestroyTime");
        SerializedProperty OffsetDueDirection = myScript.FindProperty("OffsetDueDirection");

        EditorGUILayout.Space(); EditorGUILayout.Space();
        SpawnGameObject.objectReferenceValue =
            EditorGUILayout.ObjectField(new GUIContent("Spawn Game Object"), SpawnGameObject.objectReferenceValue, typeof(GameObject), true) as GameObject;

        if (SpawnGameObject.objectReferenceValue == null) {
            EditorGUILayout.HelpBox(_spawnError, MessageType.Error);
        }

        EditorGUILayout.Slider(SpawnTime, 0.0f, 1.0f, new GUIContent("Spawn Time (%)"));

        EditorGUILayout.Space(); EditorGUILayout.Space();
        EditorGUILayout.PropertyField(DependOnThisState);

        if (DependOnThisState.boolValue) {
            EditorGUILayout.Slider(DestroyTime, 0.0f, 1.0f, new GUIContent("Destroy Time (%)"));
        }

        EditorGUILayout.Space(); EditorGUILayout.Space();
        EditorGUILayout.LabelField("Player Base Setup", EditorStyles.boldLabel);

        EditorGUILayout.HelpBox(_offsetDueDirectionInfo, MessageType.Info);

        EditorGUILayout.PropertyField(OffsetDueDirection);

        myScript.ApplyModifiedProperties();
    }
Exemple #21
0
    void AddTag( string tag2add )
    {
        SerializedObject tagManager = new SerializedObject (AssetDatabase.LoadAllAssetsAtPath ("ProjectSettings/TagManager.asset")[0]);
        SerializedProperty it = tagManager.FindProperty ("tags");
        bool set = false;
        for( int i = 0; i < it.arraySize; ++i )
        {
            SerializedProperty t = it.GetArrayElementAtIndex( i );
            if( t.stringValue == tag2add )
            {
                set = true;
                break;
            }
            if( t.stringValue == string.Empty )
            {
                t.stringValue = tag2add;
                set = true;
                break;
            }
        }
        if( !set )
        {
            it.InsertArrayElementAtIndex (it.arraySize - 1);
            it.GetArrayElementAtIndex (it.arraySize - 1).stringValue = tag2add;
        }

        tagManager.ApplyModifiedProperties ();
    }
Exemple #22
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();
    }
        public override void OnInspectorGUI()
        {
            var sortingGroup = target as SortingGroup;

            serializedObject.Update();

            EditorGUILayout.PropertyField (sortingMode);

            var mode = (SortingGroup.SortingMode)sortingMode.intValue;
            showManualMode.target = mode == SortingGroup.SortingMode.Manual;

            if (EditorGUILayout.BeginFadeGroup (showManualMode.faded))
                list.DoLayoutList();
            EditorGUILayout.EndFadeGroup ();

            EditorGUI.BeginChangeCheck();
            SortingLayerField (new GUIContent("Sorting Layer"), sortingLayerID, EditorStyles.popup);
            if (EditorGUI.EndChangeCheck())
            {
                foreach (var renderer in sortingGroup.GetComponentsInChildren<Renderer>())
                {
                    var so = new SerializedObject(renderer);
                    so.FindProperty("m_SortingLayerID").intValue = sortingLayerID.intValue;
                    so.ApplyModifiedProperties();
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
    public void LegacyEffectScaleChange(float Value)
    {
        ParticleEmitter[] ParticleEmitters = GetComponentsInChildren<ParticleEmitter>();
        ParticleAnimator[] ParticleAnimators = GetComponentsInChildren<ParticleAnimator>();
        ParticleRenderer[] ParticleRenderers = GetComponentsInChildren<ParticleRenderer>();

        transform.localScale *= Value;

        foreach (ParticleEmitter _ParticleEmitter in ParticleEmitters)
        {
            _ParticleEmitter.minSize *= Value;
            _ParticleEmitter.maxSize *= Value;
            _ParticleEmitter.localVelocity *= Value;
            _ParticleEmitter.rndAngularVelocity *= Value;
            _ParticleEmitter.rndVelocity *= Value;
            SerializedObject _SerializedObject = new SerializedObject(_ParticleEmitter);
            _SerializedObject.FindProperty("m_Ellipsoid").vector3Value *= Value;
            _SerializedObject.FindProperty("tangentVelocity").vector3Value *= Value;
            _SerializedObject.ApplyModifiedProperties();

        }

        foreach (ParticleAnimator _ParticleAnimator in ParticleAnimators)
        {
            _ParticleAnimator.sizeGrow *= Value;
            _ParticleAnimator.force *= Value;
            _ParticleAnimator.rndForce *= Value;

        }

        foreach (ParticleRenderer _ParticleRenderer in ParticleRenderers)
        {
            _ParticleRenderer.maxParticleSize *= Value;
        }
    }
	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();
	}
    // Scale Shuriken particle system 
    void ScaleShurikenSystems(float scaleFactor)
    {
        #if UNITY_EDITOR
        ParticleSystem[] systems = GetComponentsInChildren<ParticleSystem>();

        foreach (ParticleSystem system in systems)
        {
            system.startSpeed *= scaleFactor;
            system.startSize *= scaleFactor;
            system.gravityModifier *= scaleFactor;

            SerializedObject so = new SerializedObject(system);

            so.FindProperty("VelocityModule.x.scalar").floatValue *= scaleFactor;
            so.FindProperty("VelocityModule.y.scalar").floatValue *= scaleFactor;
            so.FindProperty("VelocityModule.z.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.magnitude.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.x.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.y.scalar").floatValue *= scaleFactor;
            so.FindProperty("ClampVelocityModule.z.scalar").floatValue *= scaleFactor;
            so.FindProperty("ForceModule.x.scalar").floatValue *= scaleFactor;
            so.FindProperty("ForceModule.y.scalar").floatValue *= scaleFactor;
            so.FindProperty("ForceModule.z.scalar").floatValue *= scaleFactor;
            so.FindProperty("ColorBySpeedModule.range").vector2Value *= scaleFactor;
            so.FindProperty("SizeBySpeedModule.range").vector2Value *= scaleFactor;
            so.FindProperty("RotationBySpeedModule.range").vector2Value *= scaleFactor;          

            so.ApplyModifiedProperties();
        }
        #endif
    }
    public override void OnInspectorGUI()
    {
        aap = serializedObject;
        SerializedProperty movementActions = aap.FindProperty ("actions");
        SerializedProperty fireTags = aap.FindProperty ("fireTags");
        SerializedProperty bulletTags = aap.FindProperty ("bulletTags");

        DanmakuEditorUtils.AttackPatternPropertiesGUI (aap);
        if(EditorGUILayout.PropertyField (movementActions, new GUIContent("Movement Pattern")))
        {
            CommonActionDrawer.attackPattern = target as ActionAttackPattern;
            DanmakuEditorUtils.ActionGroupField(movementActions, this, true);
        }
        if(EditorGUILayout.PropertyField (fireTags))
        {
            CommonActionDrawer.attackPattern = target as ActionAttackPattern;
            DanmakuEditorUtils.TagGroupField(fireTags, this, false);
        }
        if(EditorGUILayout.PropertyField (bulletTags))
        {
            CommonActionDrawer.attackPattern = target as ActionAttackPattern;
            DanmakuEditorUtils.TagGroupField(bulletTags, this, false);
        }
        aap.ApplyModifiedProperties ();
    }
	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();
		}
	}
	private static void CreateAudioAssets()
	{
		if(Selection.objects.Length > 0)
		{
			foreach(Object obj in Selection.objects)
			{
				if(obj.GetType() == typeof(AudioClip))
				{
					string path = AssetDatabase.GetAssetPath(obj);

					if(!string.IsNullOrEmpty(path))
					{
						path = Path.ChangeExtension(path, ".asset");

						SerializedObject asset = new SerializedObject(CreateAudioAssetAtPath(path));

						asset.FindProperty("audioClip").objectReferenceValue = obj;
						asset.ApplyModifiedProperties();
						asset.Dispose();
					}
				}
			}

			AssetDatabase.SaveAssets();
		}
	}
Exemple #30
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 ();
                }
            }
        }
    }
Exemple #31
0
	///*

	//[MenuItem("2DDL/Create/Changes")]
	public static void cancgeVal (){
		SerializedObject profile = new SerializedObject(AssetDatabase.LoadAssetAtPath<DynamicLightSetting>("Assets/2DDL/2DLight/Core/2ddlSettings.asset"));
		SerializedProperty prop = profile.FindProperty ("version");
		prop.stringValue = "12323";
		profile.ApplyModifiedProperties ();
		//profile.Update ();
	}
Exemple #32
0
 public void Sort()
 {
     UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(this);
     data.Sort(new ReferenceCollectorDataComparer());
     UnityEditor.EditorUtility.SetDirty(this);
     serializedObject.ApplyModifiedProperties();
     serializedObject.UpdateIfRequiredOrScript();
 }
Exemple #33
0
 protected void SetPoints(Path path, Point[] points)
 {
     #if UNITY_EDITOR
     var so = new UnityEditor.SerializedObject(this);
     path._points = points;
     so.ApplyModifiedProperties();
     #endif
 }
Exemple #34
0
    public void Clear()
    {
        UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(this);
        //根据PropertyPath读取prefab文件中的数据
        //如果不知道具体的格式,可以直接右键用文本编辑器打开,搜索data就能找到
        var dataProperty = serializedObject.FindProperty("data");

        dataProperty.ClearArray();
        UnityEditor.EditorUtility.SetDirty(this);
        serializedObject.ApplyModifiedProperties();
        serializedObject.UpdateIfRequiredOrScript();
    }
Exemple #35
0
    private void SetParticleSystemPropertiesInEditor()
    {
        UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(myStarfieldPS);
        serializedObject.FindProperty("lengthInSec").floatValue = Mathf.Infinity;
        serializedObject.ApplyModifiedProperties();

        myStarfieldPS.loop            = false;
        myStarfieldPS.playOnAwake     = false;
        myStarfieldPS.simulationSpace = ParticleSystemSimulationSpace.World;

        ParticleSystem.EmissionModule em = myStarfieldPS.emission;
        em.enabled = false;
    }
Exemple #36
0
        internal static void CreatePopupMenu(SerializedObject obj, string title, GUIContent content, PopupElement[] elements, int selectedIndex, GenericMenu.MenuFunction2 func)
        {
            var popupRect = GUILayoutUtility.GetRect(content, EditorStyles.popup);

            popupRect = EditorGUI.PrefixLabel(popupRect, 0, new GUIContent(title));
            if (EditorGUI.DropdownButton(popupRect, content, FocusType.Passive, EditorStyles.popup))
            {
                DoPopup(popupRect, elements, selectedIndex, data =>
                {
                    func(data);
                    obj?.ApplyModifiedProperties();
                });
            }
        }
Exemple #37
0
        public static bool AddLayer(string _name)
        {
#if UNITY_EDITOR
            if (LayerMask.NameToLayer(_name) != -1)
            {
                return(true);
            }

            UnityEditor.SerializedObject _tag_manager = new UnityEditor.SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);

            UnityEditor.SerializedProperty _layers = _tag_manager.FindProperty("layers");
            if (_layers == null || !_layers.isArray)
            {
                Debug.LogWarning("Sorry, can't set up the layers! It's possible the format of the layers and tags data has changed in this version of Unity. Please add the required layer '" + _name + "' by hand!");
                return(false);
            }

            int _layer_index = -1;
            for (int _i = 8; _i < 32; _i++)
            {
                _layer_index = _i;
                UnityEditor.SerializedProperty _layer = _layers.GetArrayElementAtIndex(_i);

                //Debug.Log( _layer_index + " - " + _layer.stringValue );

                if (_layer.stringValue == "")
                {
                    Debug.Log("Setting up layers.  Layer " + _layer_index + " is now called " + _name);
                    _layer.stringValue = _name;
                    break;
                }
            }

            _tag_manager.ApplyModifiedProperties();

            if (LayerMask.NameToLayer(_name) != -1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
#else
            return(true);
#endif
        }
Exemple #38
0
        private static void SetupGeographicsTransforms(WRLDARCoreSetupHelper wrldARCoreSetupHelper)
        {
            WRLDARCoreSetupHelper.CubeInfo[] cubes;
            foreach (WRLDARCoreSetupHelper.CubeInfo cubeInfo in wrldARCoreSetupHelper.cubeInfos)
            {
                // Please import WRLD3D plugin if you are seeing a compiler error here.
                GeographicTransform geographicTransform = cubeInfo.cubeGameObject.AddComponent <GeographicTransform> ();
                SerializedObject    serializedObject    = new UnityEditor.SerializedObject(geographicTransform);
                SerializedProperty  latitudeProperty    = serializedObject.FindProperty("InitialLatitude");
                SerializedProperty  longitudeProperty   = serializedObject.FindProperty("InitialLongitude");

                latitudeProperty.doubleValue  = cubeInfo.latitudeDegrees;
                longitudeProperty.doubleValue = cubeInfo.longitudeDegrees;

                serializedObject.ApplyModifiedProperties();
            }
        }
Exemple #39
0
        private static void SetupWRLDMap(WRLDARCoreSetupHelper wrldARCoreSetupHelper)
        {
            // Please import WRLD3D plugin if you are seeing a compiler error here.
            WrldMap            wrldMap = wrldARCoreSetupHelper.wrldMapGameObject.AddComponent <WrldMap> ();
            SerializedObject   serializedWrldMapObject   = new UnityEditor.SerializedObject(wrldMap);
            SerializedProperty streamingCameraProperty   = serializedWrldMapObject.FindProperty("m_streamingCamera");
            SerializedProperty latitudeDegreesProperty   = serializedWrldMapObject.FindProperty("m_latitudeDegrees");
            SerializedProperty longitudeDegreesProperty  = serializedWrldMapObject.FindProperty("m_longitudeDegrees");
            SerializedProperty materialDirectoryProperty = serializedWrldMapObject.FindProperty("m_materialDirectory");

            streamingCameraProperty.objectReferenceValue = wrldARCoreSetupHelper.streamingCamera;
            latitudeDegreesProperty.doubleValue          = wrldARCoreSetupHelper.wrldStartLatitudeDegrees;
            longitudeDegreesProperty.doubleValue         = wrldARCoreSetupHelper.wrldStartLongitudeDegrees;
            materialDirectoryProperty.stringValue        = wrldARCoreSetupHelper.wrldMaterialDirectory;

            serializedWrldMapObject.ApplyModifiedProperties();
        }
    /// <summary>
    /// Updates the preview if it is missing or out of date.
    /// </summary>
    void UpdatePreview()
    {
        var prefabType = UnityEditor.PrefabUtility.GetPrefabType(gameObject);

        if (prefabType == UnityEditor.PrefabType.Prefab)
        {
            return;
        }

        if (m_previewInstance == null || IsPreviewOutOfDate())
        {
            DestroyPreview();
            var so = new UnityEditor.SerializedObject(this);
            so.FindProperty("m_previewInstance").objectReferenceValue = CreatePreviewInstance();
            so.ApplyModifiedProperties();
        }
    }
Exemple #41
0
        // Method to apply the changes
        void Validate()
        {
            foreach (Rotator rotator in rotatorsToEdit)
            {
                Rotator          component        = rotator.GetComponent <Rotator>();
                SerializedObject serializedObject = new UnityEditor.SerializedObject(rotator);
                if (identifierBool)
                {
                    SerializedProperty serializedProperty = serializedObject.FindProperty("_identifier");
                    serializedProperty.stringValue = identifier;
                }
                if (timeBool)
                {
                    SerializedProperty serializedProperty2 = serializedObject.FindProperty("_timeBeforeStoppingInSeconds");
                    serializedProperty2.floatValue = timeBeforeStoppingInSeconds;
                }
                if (reverseBool)
                {
                    SerializedProperty serializedProperty3 = serializedObject.FindProperty("_shouldReverseRotation");
                    serializedProperty3.boolValue = shouldReverseRotation;
                }
                if (settingsBool)
                {
                    SerializedProperty serializedProperty4 = serializedObject.FindProperty("_rotationsSettings");


                    foreach (SerializedProperty p in serializedProperty4)
                    {
                        if (objectToRotateBool && p.name == "ObjectToRotate")
                        {
                            p.objectReferenceValue = objectToRotate;
                        }
                        if (angleRotationBool && p.name == "AngleRotation")
                        {
                            p.vector3Value = angleRotation;
                        }
                        if (timeToRotateBool && p.name == "TimeToRotateInSeconds")
                        {
                            p.floatValue = timeBeforeStoppingInSeconds;
                        }
                    }
                }
                serializedObject.ApplyModifiedProperties();
            }
        }
        void OnGUI()
        {
            var serializedTable = new UnityEditor.SerializedObject(_table);

            EditorGUILayout.BeginVertical();

            // Screen num box
            var viewCount = serializedTable.FindProperty("viewCount");

            EditorGUILayout.PropertyField(viewCount, _textViewCount);

            EditorGUILayout.Space();

            // View-display table
            var viewTable = serializedTable.FindProperty("viewTable");

            for (var i = 0; i < viewCount.intValue; i++)
            {
                EditorGUILayout.IntPopup(
                    viewTable.GetArrayElementAtIndex(i),
                    _optionLabels, _optionValues, _viewLabels[i]
                    );
            }

            EditorGUILayout.Space();

            // Function buttons
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            if (GUILayout.Button("Layout"))
            {
                LayoutViews();
            }
            EditorGUILayout.Space();
            if (GUILayout.Button("Close All"))
            {
                CloseAllViews();
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            serializedTable.ApplyModifiedProperties();
        }
Exemple #43
0
        public static void ShowRelativeProperty(UnityEditor.SerializedObject serializedObject, UnityEditor.SerializedProperty parentProperty, string propertyName)
        {
            UnityEditor.SerializedProperty property = parentProperty.FindPropertyRelative(propertyName);
            if (property != null)
            {
                UnityEditor.EditorGUI.indentLevel++;
                UnityEditor.EditorGUI.BeginChangeCheck();
                UnityEditor.EditorGUILayout.PropertyField(property, true);

                if (UnityEditor.EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                UnityEditor.EditorGUIUtility.labelWidth = 0f;
                UnityEditor.EditorGUI.indentLevel--;
            }
        }
    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();
    }
Exemple #45
0
    private static void Execute(string path)
    {
        var data = AssetDatabase.LoadAssetAtPath(path, typeof(SpriteAtlas));

        SerializedObject serializedObject = new UnityEditor.SerializedObject(data);
        var packing  = serializedObject.FindProperty("m_EditorData.packingSettings.enableTightPacking");
        var rotating = serializedObject.FindProperty("m_EditorData.packingSettings.enableRotation");

        bool originPacking  = packing.boolValue;
        bool originRotating = rotating.boolValue;

        packing.boolValue  = false;
        rotating.boolValue = false;
        serializedObject.ApplyModifiedProperties();
        if (originPacking || originRotating)
        {
            AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
        }
    }
        public void SetLegStretch(Avatar avatar, float value)
        {
            if (avatar == null)
            {
                return;
            }
            var serializedObject = new UnityEditor.SerializedObject(avatar);

            {
                var pLegStretch = serializedObject.FindProperty("m_Avatar.m_Human.data.m_LegStretch");
                pLegStretch.floatValue = value;
            }
#if UNITY_2019_1_OR_NEWER
            {
                var pLegStretch = serializedObject.FindProperty("m_HumanDescription.m_LegStretch");
                pLegStretch.floatValue = value;
            }
#endif
            serializedObject.ApplyModifiedProperties();
        }
    private SerializedObject GeneratePropetiesFields(SerializedProperty a_property, Rect a_position, GUIContent a_label)
    {
        SerializedObject serializedObj = new UnityEditor.SerializedObject(a_property.objectReferenceValue);


        SerializedProperty property = serializedObj.GetIterator();


        while (property.NextVisible(true))
        {
            Rect rect = GetNextRect(a_position, property, a_label);

            EditorGUI.PropertyField(rect, property, true);
        }


        serializedObj.ApplyModifiedProperties();

        return(serializedObj);
    }
        public override void ShowGUI()
        {
            var serializedObject = new UnityEditor.SerializedObject(this);

            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();

            AfterRunningOption();
        }
Exemple #49
0
    private void Update()
    {
        if (Mathf.Abs(m_OldScale - particlesScale) > 0.0001f && particlesScale > 0)
        {
            transform.localScale = new Vector3(particlesScale, particlesScale, particlesScale);
            float scale = particlesScale / m_OldScale;
            var   ps    = GetComponentsInChildren <ParticleSystem>();

            foreach (ParticleSystem particles in ps)
            {
                var main = particles.main;
                main.startSizeMultiplier       *= scale;
                main.startSpeedMultiplier      *= scale;
                main.gravityModifierMultiplier *= scale;
                var serializedObject = new UnityEditor.SerializedObject(particles);
                serializedObject.FindProperty("ClampVelocityModule.magnitude.scalar").floatValue *= scale;
                serializedObject.FindProperty("ClampVelocityModule.x.scalar").floatValue         *= scale;
                serializedObject.FindProperty("ClampVelocityModule.y.scalar").floatValue         *= scale;
                serializedObject.FindProperty("ClampVelocityModule.z.scalar").floatValue         *= scale;
                serializedObject.FindProperty("VelocityModule.x.scalar").floatValue       *= scale;
                serializedObject.FindProperty("VelocityModule.y.scalar").floatValue       *= scale;
                serializedObject.FindProperty("VelocityModule.z.scalar").floatValue       *= scale;
                serializedObject.FindProperty("ColorBySpeedModule.range").vector2Value    *= scale;
                serializedObject.FindProperty("RotationBySpeedModule.range").vector2Value *= scale;
                serializedObject.FindProperty("ForceModule.x.scalar").floatValue          *= scale;
                serializedObject.FindProperty("ForceModule.y.scalar").floatValue          *= scale;
                serializedObject.FindProperty("ForceModule.z.scalar").floatValue          *= scale;
                serializedObject.FindProperty("SizeBySpeedModule.range").vector2Value     *= scale;

                serializedObject.ApplyModifiedProperties();
            }

            var trails = GetComponentsInChildren <TrailRenderer>();
            foreach (TrailRenderer trail in trails)
            {
                trail.startWidth *= scale;
                trail.endWidth   *= scale;
            }
            m_OldScale = particlesScale;
        }
    }
    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);
        }
    }
Exemple #51
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"))
            {
            }
        }
    }
Exemple #52
0
    //删除元素,知识点与上面的添加相似
    public void Remove(string key)
    {
        UnityEditor.SerializedObject   serializedObject = new UnityEditor.SerializedObject(this);
        UnityEditor.SerializedProperty dataProperty     = serializedObject.FindProperty("data");
        int i;

        for (i = 0; i < data.Count; i++)
        {
            if (data[i].key == key)
            {
                break;
            }
        }
        if (i != data.Count)
        {
            dataProperty.DeleteArrayElementAtIndex(i);
        }
        UnityEditor.EditorUtility.SetDirty(this);
        serializedObject.ApplyModifiedProperties();
        serializedObject.UpdateIfRequiredOrScript();
    }
        /// <summary>
        /// Renders the DatabaseSettings fields
        /// </summary>
        private void OnGUI()
        {
            var serializedObject = new UnityEditor.SerializedObject(DatabaseSettings.Settings);

            //DatabaseSettings.Settings.ViewingDatabase = EditorGUILayout.TextField("Viewing Database", DatabaseSettings.Settings.ViewingDatabase);
            foreach (FieldInfo field in typeof(DatabaseSettings).GetFields().Where(x => !x.IsPrivate).ToList())
            {
                var serializedField = serializedObject.FindProperty(field.Name);
                if (serializedField != null)
                {
                    EditorGUILayout.PropertyField(serializedField);
                }
            }

            serializedObject.ApplyModifiedProperties();

            EditorPrefs.SetString(
                DatabaseSettings.EditorPrefsKey,
                JsonSerialization.Serialize(typeof(DatabaseSettings), DatabaseSettings.Settings)
                );
        }
Exemple #54
0
        public override void ShowGUI()
        {
            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();
        }
        private static void Run()
        {
            UnityEditor.EditorApplication.playModeStateChanged += state =>
            {
                switch (state)
                {
                case UnityEditor.PlayModeStateChange.ExitingPlayMode:
                    //var targets = FindObjectsOfType(typeof(Inner_PlayModeSave).DeclaringType); // 비활성 오브젝트 제외
                    var targets = Resources.FindObjectsOfTypeAll(typeof(Inner_PlayModeSave).DeclaringType);     // 비활성 오브젝트 포함
                    targetSoArr = new UnityEditor.SerializedObject[targets.Length];
                    for (int i = 0; i < targets.Length; i++)
                    {
                        targetSoArr[i] = new UnityEditor.SerializedObject(targets[i]);
                    }
                    break;

                case UnityEditor.PlayModeStateChange.EnteredEditMode:
                    if (targetSoArr == null)
                    {
                        break;
                    }
                    foreach (var oldSO in targetSoArr)
                    {
                        if (oldSO.targetObject == null)
                        {
                            continue;
                        }
                        var oldIter = oldSO.GetIterator();
                        var newSO   = new UnityEditor.SerializedObject(oldSO.targetObject);
                        while (oldIter.NextVisible(true))
                        {
                            newSO.CopyFromSerializedProperty(oldIter);
                        }
                        newSO.ApplyModifiedProperties();
                    }
                    break;
                }
            };
        }
Exemple #56
0
        /// <summary>
        /// sets mesh asset readability.
        /// </summary>
        /// <param name="mesh">extension method - this mesh</param>
        /// <param name="state">new state</param>
        /// <returns>false if state did not change. returns true if state changed.</returns>
        public static bool SetReadable(this Mesh mesh, ReadableState state)
        {
            bool isStateReadable = (state == ReadableState.Readable);

            if (!mesh || (isStateReadable == mesh.isReadable))
            {
                return(false);
            }

            if (state == ReadableState.UnreadableAndUploadedToGPU)
            {
                mesh.UploadMeshData(true);
            }
            else
            {
                var serializedObject = new UnityEditor.SerializedObject(mesh);
                serializedObject.FindProperty("m_IsReadable").boolValue = (state == ReadableState.Readable);
                serializedObject.ApplyModifiedProperties();
            }

            return(true);
        }
Exemple #57
0
    //添加新的元素
    public void Add(string key, Object obj)
    {
        UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(this);
        //根据PropertyPath读取数据
        //如果不知道具体的格式,可以右键用文本编辑器打开一个prefab文件(如Bundles/UI目录中的几个)
        //因为这几个prefab挂载了ReferenceCollector,所以搜索data就能找到存储的数据
        UnityEditor.SerializedProperty dataProperty = serializedObject.FindProperty("data");
        int i;

        //遍历data,看添加的数据是否存在相同key
        for (i = 0; i < data.Count; i++)
        {
            if (data[i].key == key)
            {
                break;
            }
        }
        //不等于data.Count意为已经存在于data List中,直接赋值即可
        if (i != data.Count)
        {
            //根据i的值获取dataProperty,也就是data中的对应ReferenceCollectorData,不过在这里,是对Property进行的读取,有点类似json或者xml的节点
            UnityEditor.SerializedProperty element = dataProperty.GetArrayElementAtIndex(i);
            //对对应节点进行赋值,值为gameobject相对应的fileID
            //fileID独一无二,单对单关系,其他挂载在这个gameobject上的script或组件会保存相对应的fileID
            element.FindPropertyRelative("gameObject").objectReferenceValue = obj;
        }
        else
        {
            //等于则说明key在data中无对应元素,所以得向其插入新的元素
            dataProperty.InsertArrayElementAtIndex(i);
            UnityEditor.SerializedProperty element = dataProperty.GetArrayElementAtIndex(i);
            element.FindPropertyRelative("key").stringValue = key;
            element.FindPropertyRelative("gameObject").objectReferenceValue = obj;
        }
        //应用与更新
        UnityEditor.EditorUtility.SetDirty(this);
        serializedObject.ApplyModifiedProperties();
        serializedObject.UpdateIfRequiredOrScript();
    }
Exemple #58
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);
            }
        }
Exemple #59
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;
            }
        }
    }
Exemple #60
0
        public override void OnInspectorGUI()
        {
            TransitionDataHolder transitionData = (TransitionDataHolder)target;

            GUILayout.Label("Transition to: " + transitionData.TransitionsForState[0].NextState.StateName);

            for (int i = 0; i < transitionData.TransitionsForState.Count; i++)
            {
                // Get the decisions array
                SerializedObject   obj       = new UnityEditor.SerializedObject(transitionData.TransitionsForState[i]);
                SerializedProperty decisions = obj.FindProperty("decisions");

                // Display array and edit it
                EditorGUILayout.PropertyField(decisions, true);
                obj.ApplyModifiedProperties();

                // Create button to remove transitions
                if (GUILayout.Button("Remove this transition"))
                {
                    // If there is more than one transition, remove only the single transition
                    // If there is only one transition, remove the transition and destroy the state connection
                    if (transitionData.TransitionsForState.Count > 1)
                    {
                        if (transitionData.RemoveIndividualAction != null)
                        {
                            transitionData.RemoveIndividualAction(transitionData.TransitionsForState[i], transitionData);
                        }
                    }
                    else
                    {
                        if (transitionData.RemoveAction != null)
                        {
                            transitionData.RemoveAction(transitionData);
                        }
                    }
                }
            }
        }