public FindProperty ( string propertyPath ) : UnityEditor.SerializedProperty | ||
propertyPath | string | |
return | UnityEditor.SerializedProperty |
public void OnEnable() { disableBehaviour = new SerializedObject(this.target); this.fireTime = disableBehaviour.FindProperty("firetime"); this.componentsProperty = disableBehaviour.FindProperty("Behaviour"); this.editorRevert = disableBehaviour.FindProperty("editorRevertMode"); this.runtimeRevert = disableBehaviour.FindProperty("runtimeRevertMode"); Component currentComponent = componentsProperty.objectReferenceValue as Component; DisableBehaviour behaviour = (target as DisableBehaviour); if (behaviour == null || behaviour.ActorTrackGroup == null || behaviour.ActorTrackGroup.Actor == null) { return; } GameObject actor = behaviour.ActorTrackGroup.Actor.gameObject; Component[] behaviours = DirectorHelper.getEnableableComponents(actor); for (int j = 0; j < behaviours.Length; j++) { if (behaviours[j] == currentComponent) { componentSelection = j; } } }
void OnEnable() { srcObj = new SerializedObject(target); displace = srcObj.FindProperty("displace"); amount = srcObj.FindProperty("amount"); }
void OnEnable() { srcObj = new SerializedObject(target); scale = srcObj.FindProperty("scale"); brightness = srcObj.FindProperty("brightness"); }
public void OnEnable() { movingPlatform = (StationaryMovingPlatform)target; mObj = new SerializedObject(target); mDuration = mObj.FindProperty("duration"); mStationsList = mObj.FindProperty("stationList"); }
public void OnEnable() { serObj = new SerializedObject (target); sharedMaterial = serObj.FindProperty("sharedMaterial"); waterQuality = serObj.FindProperty("waterQuality"); edgeBlend = serObj.FindProperty("edgeBlend"); }
void OnEnable() { m_soTarget = new SerializedObject(target); m_soRadiusFront = m_soTarget.FindProperty("radiusFront"); m_soRadiusBack = m_soTarget.FindProperty("radiusBack"); m_soMirrorWheels = m_soTarget.FindProperty("mirrorWheels"); }
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(); }
void OnEnable() { serObj = new SerializedObject (target); visualizeFocus = serObj.FindProperty ("visualizeFocus"); focalLength = serObj.FindProperty ("focalLength"); focalSize = serObj.FindProperty ("focalSize"); aperture = serObj.FindProperty ("aperture"); focalTransform = serObj.FindProperty ("focalTransform"); maxBlurSize = serObj.FindProperty ("maxBlurSize"); highResolution = serObj.FindProperty ("highResolution"); blurType = serObj.FindProperty ("blurType"); blurSampleCount = serObj.FindProperty ("blurSampleCount"); nearBlur = serObj.FindProperty ("nearBlur"); foregroundOverlap = serObj.FindProperty ("foregroundOverlap"); dx11BokehThreshhold = serObj.FindProperty ("dx11BokehThreshhold"); dx11SpawnHeuristic = serObj.FindProperty ("dx11SpawnHeuristic"); dx11BokehTexture = serObj.FindProperty ("dx11BokehTexture"); dx11BokehScale = serObj.FindProperty ("dx11BokehScale"); dx11BokehIntensity = serObj.FindProperty ("dx11BokehIntensity"); }
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; }
//--> checkIfIDExist private void checkIfIDExist(SerializedProperty selectedID) { string objectPath2 = "Assets/AP/Assets/Datas/ProjectManagerDatas.asset"; datasProjectManager _datasProjectManager = AssetDatabase.LoadAssetAtPath(objectPath2, typeof(UnityEngine.Object)) as datasProjectManager; string objectPath = "Assets/AP/Assets/Resources/" + _datasProjectManager.currentDatasProjectFolder + "/TextList/wItem.asset"; TextList _textList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(UnityEngine.Object)) as TextList; if (_textList) { SerializedObject serializedObject2 = new UnityEditor.SerializedObject(_textList); if (selectedID.intValue < serializedObject2.FindProperty("diaryList").GetArrayElementAtIndex(0).FindPropertyRelative("_languageSlot").arraySize && selectedID.intValue >= 0) { SerializedProperty _Title = serializedObject2.FindProperty("diaryList").GetArrayElementAtIndex(0).FindPropertyRelative("_languageSlot").GetArrayElementAtIndex(selectedID.intValue).FindPropertyRelative("diaryTitle").GetArrayElementAtIndex(0); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Item :", GUILayout.Width(40)); EditorGUILayout.LabelField(_Title.stringValue.ToString()); EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("This ID doesn't exist", MessageType.Warning); } } }
void OnEnable() { serObj = new SerializedObject(target); bloomIntensity = serObj.FindProperty("bloomIntensity"); lensDirtIntensity = serObj.FindProperty("lensDirtIntensity"); lensDirtTexture = serObj.FindProperty("lensDirtTexture"); }
private static void SetupWrldMap(GameObject wrldMapGameobject, Camera streamingCamera, double latitudeDegrees, double longitudeDegrees, string materialDirectory) { if (wrldMapGameobject != null) { WrldMap wrldMap = 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"); SerializedProperty useBuiltInCameraControlsProperty = serializedWrldMapObject.FindProperty("m_useBuiltInCameraControls"); streamingCameraProperty.objectReferenceValue = streamingCamera; latitudeDegreesProperty.doubleValue = latitudeDegrees; longitudeDegreesProperty.doubleValue = longitudeDegrees; materialDirectoryProperty.stringValue = materialDirectory; useBuiltInCameraControlsProperty.boolValue = false; serializedWrldMapObject.ApplyModifiedProperties(); } else { Debug.LogError("WrldMap gameobject not referenced in WRLDARKitSetupHelper."); } }
void OnEnable() { srcObj = new SerializedObject(target); strength = srcObj.FindProperty("strength"); clamp = srcObj.FindProperty("clamp"); }
void Update() { if (dlb_GameManager.dlb_state == dlb_GameManager.States.play) { dlb_Move(); dlb_Fire(); } else if (dlb_GameManager.dlb_state == dlb_GameManager.States.wait || dlb_GameManager.dlb_state == dlb_GameManager.States.nextWave) { dlb_Move(); //peut bouger pour attraper la capsule dans l'attente d'une nouvelle vague } // vérifie si un bonus est appliqué if (dlb_bonus) { dlb_delaiBonus += Time.deltaTime; // vérifie si le délai du bonus obtenu est dépassé if (dlb_delaiBonus > dlb_capsule.dlb_delai) { // remise des valeurs par défaut du joueur dlb_speed = 5f; dlb_fireRate = .50f; dlb_invincible = false; dlb_bonus = false; dlb_delaiBonus = 0; dlb_halo.FindProperty("m_Enabled").boolValue = dlb_bonus; // dlb_halo.enabled = dlb_bonus; dlb_halo.ApplyModifiedProperties(); print("Fin du bonus"); } } }
void OnEnable() { t = (IpcIrcEventHandler)target; GetTarget = new SerializedObject(t); ThisString = GetTarget.FindProperty("triggerPhrase"); // Find the triggerphrase string ThisList = GetTarget.FindProperty("myEventList"); // Find the List in our script and create a refrence of it }
void OnEnable() { playerId = serializedObject.FindProperty("playerId"); bodyTrackingDevice = serializedObject.FindProperty("bodyTrackingDevice"); // gestureSelectionMethod = serializedObject.FindProperty("gestureSelectionMethod"); wandStart = serializedObject.FindProperty("wandStart"); wandEnd = serializedObject.FindProperty("wandEnd"); rotationNoiseCovariance = serializedObject.FindProperty("rotationNoiseCovariance"); visualizerThreshold = serializedObject.FindProperty("visualizerThreshold"); visualizerWidth = serializedObject.FindProperty("visualizerWidth"); visualizerHeight = serializedObject.FindProperty("visualizerHeight"); wandColor = serializedObject.FindProperty("wandColor"); // gestureRecognizer = serializedObject.FindProperty("gestureRecognizer"); wandPositionVisualizer = serializedObject.FindProperty("wandPositionVisualizer"); showVisualizer = serializedObject.FindProperty("showVisualizer"); switchToAvailableKinect = serializedObject.FindProperty("switchToAvailableKinect"); skeletonWand = target as RUISSkeletonWand; if(skeletonWand) { gestureSelectionMethodLink = new SerializedObject(skeletonWand); guiGestureSelectionMethodChoiceLink = gestureSelectionMethodLink.FindProperty("gestureSelectionMethod"); gestureScriptLink = gestureSelectionMethodLink.FindProperty("gestureSelectionScriptName"); } }
void OnEnable() { srcObj = new SerializedObject(target); rampTexture = srcObj.FindProperty("rampTexture"); amount = srcObj.FindProperty("amount"); }
// =========================================================== // 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(); }
// Use this for initialization void OnEnable() { waypoint = new SerializedObject(target); lanesCount = waypoint.FindProperty("waypointsCount"); laneid = waypoint.FindProperty("pathID"); objectsCount = (GameObject.FindObjectOfType(typeof(Lane)) as Lane).gameObject.GetComponentsInChildren<WayPoint>().Length; }
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); } }
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 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 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; } }
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(); } } }
public void OnEnable(SerializedObject serializedObject) { this.m_WidthMultiplier = serializedObject.FindProperty("m_Parameters.widthMultiplier"); this.m_WidthCurve = serializedObject.FindProperty("m_Parameters.widthCurve"); this.m_Settings.hRangeMin = 0f; this.m_Settings.vRangeMin = 0f; this.m_Settings.vRangeMax = 1f; this.m_Settings.hRangeMax = 1f; this.m_Settings.vSlider = false; this.m_Settings.hSlider = false; TickStyle style = new TickStyle { tickColor = { color = new Color(0f, 0f, 0f, 0.15f) }, distLabel = 30 }; this.m_Settings.hTickStyle = style; TickStyle style2 = new TickStyle { tickColor = { color = new Color(0f, 0f, 0f, 0.15f) }, distLabel = 20 }; this.m_Settings.vTickStyle = style2; this.m_Settings.undoRedoSelection = true; this.m_Editor = new CurveEditor(new Rect(0f, 0f, 1000f, 100f), new CurveWrapper[0], false); this.m_Editor.settings = this.m_Settings; this.m_Editor.margin = 25f; this.m_Editor.SetShownHRangeInsideMargins(0f, 1f); this.m_Editor.SetShownVRangeInsideMargins(0f, 1f); this.m_Editor.ignoreScrollWheelUntilClicked = true; Undo.undoRedoPerformed = (Undo.UndoRedoCallback) Delegate.Combine(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.UndoRedoPerformed)); }
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 (); }
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(); }
public void OnEnable () { serObj = new SerializedObject (target); reflectionMask = serObj.FindProperty("reflectionMask"); reflectSkybox = serObj.FindProperty("reflectSkybox"); clearColor = serObj.FindProperty("clearColor"); }
/// <summary> /// On inspector enable, load serialized objects /// </summary> public void OnEnable() { dialogueTrack = new SerializedObject(this.target); canOptimize = dialogueTrack.FindProperty("canOptimize"); anchor = dialogueTrack.FindProperty("anchor"); playbackMode = dialogueTrack.FindProperty("PlaybackMode"); }
void OnEnable() { srcObj = new SerializedObject(target); color = srcObj.FindProperty("color"); density = srcObj.FindProperty("density"); }
void OnEnable() { srcObj = new SerializedObject(target); sharpness = srcObj.FindProperty("sharpness"); darkness = srcObj.FindProperty("darkness"); }
protected virtual void OnEnable() { myObject = new SerializedObject(target); attackInput = myObject.FindProperty("attackInput"); attackName = myObject.FindProperty("attackName"); }
public void DrawGeneralFunction() { AmplifyShaderFunction function = ParentWindow.CurrentGraph.CurrentShaderFunction; if (function == null) { return; } float cacheWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 115; SerializedObject serializedObject = new UnityEditor.SerializedObject(function); if (serializedObject != null) { SerializedProperty temo = serializedObject.FindProperty("m_description"); EditorGUILayout.PropertyField(temo, new GUIContent(" Description")); SerializedProperty cat = serializedObject.FindProperty("m_nodeCategory"); SerializedProperty ppos = serializedObject.FindProperty("m_previewPosition"); EditorGUILayout.PropertyField(ppos, new GUIContent("Preview Position")); cat.intValue = ParentWindow.CurrentGraph.CurrentOutputNode.EditorGUILayoutPopup("Category", cat.intValue, UIUtils.CategoryPresets); if (cat.enumValueIndex == 0) { SerializedProperty custCat = serializedObject.FindProperty("m_customNodeCategory"); EditorGUILayout.PropertyField(custCat, new GUIContent("Custom")); } serializedObject.ApplyModifiedProperties(); } EditorGUIUtility.labelWidth = cacheWidth; }
// 导出ExportAudioTrack private int ExportAudioTrack(AudioTrack audioTrack, JSONObject trackListArr, JSONObject clipListArr) { JSONObject trackJSON = GenerateBaseTrack(audioTrack, PlaybaleTrackTypeMap["AudioTrack"]); #if UNITY_2019_1_OR_NEWER UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(audioTrack); UnityEditor.SerializedProperty propertiesserializedObject = serializedObject.FindProperty("m_TrackProperties"); float volume = propertiesserializedObject.FindPropertyRelative("volume").floatValue; float stereoPan = propertiesserializedObject.FindPropertyRelative("stereoPan").floatValue; float spatialBlend = propertiesserializedObject.FindPropertyRelative("spatialBlend").floatValue; trackJSON.AddField("volume", volume); trackJSON.AddField("stereoPan", stereoPan); trackJSON.AddField("spatialBlend", spatialBlend); #else trackJSON.AddField("volume", 1); trackJSON.AddField("stereoPan", 0); trackJSON.AddField("spatialBlend", 0); #endif JSONObject clipsIndexArr = trackJSON.GetField("clips"); IEnumerable <TimelineClip> timelineClipList = audioTrack.GetClips(); int num = 0; foreach (TimelineClip timelineClip in timelineClipList) { JSONObject clipJSON = GenerateBaseTimelineClip(timelineClip, PlaybaleClipTypeMap["Audio"]); JSONObject clipData = new JSONObject(JSONObject.Type.OBJECT); clipJSON.AddField("data", clipData); AudioPlayableAsset asset = (AudioPlayableAsset)timelineClip.asset; if ((UnityEngine.Object)asset.clip != (UnityEngine.Object)null) { WXAudioClip converter = new WXAudioClip(asset.clip, gameObject); string clipPath = AddDependencies(converter); clipData.AddField("clip", clipPath); } else { clipData.AddField("clip", JSONObject.nullJO); } // clipData.AddField("clipCaps", ClipCapsMap.ContainsKey(timelineClip.clipCaps) ? ClipCapsMap[timelineClip.clipCaps] : ClipCapsMap[ClipCaps.None]); // clipData.AddField("duration", (float)asset.duration); // 兼容2017没有loop UnityEditor.SerializedObject assetSerializedObject = new UnityEditor.SerializedObject(asset); bool loop = assetSerializedObject.FindProperty("m_Loop").boolValue; clipData.AddField("loop", loop); #if UNITY_2019_1_OR_NEWER UnityEditor.SerializedProperty clipProperties = assetSerializedObject.FindProperty("m_ClipProperties"); float clipVolume = clipProperties.FindPropertyRelative("volume").floatValue; clipData.AddField("volume", clipVolume); #else clipData.AddField("volume", 1); #endif clipsIndexArr.Add(ExportTimelineClip(clipJSON, clipListArr)); num++; } return(ExportTrack(trackJSON, trackListArr)); }
public static void CreateNewGameLevel() { // Ask the user if they would like to save the current scene if need be, if they do not press cancel... if (EditorApplication.SaveCurrentSceneIfUserWantsTo()) { // ... then load a new scene. EditorApplication.NewScene(); // We do not want the default `Main Camera` object do destroy that. Object.DestroyImmediate(GameObject.Find("Main Camera")); // For each required prefab file name... foreach (string levelRequirement in LevelRequirementPrefabs) { // ... load the prefab from the asset database. GameObject requiredPrefab = AssetDatabase.LoadAssetAtPath<GameObject>(RootLevelRequirements + levelRequirement); // Instantiate it within the new scene connected to the prefab. PrefabUtility.InstantiatePrefab(requiredPrefab); } // Reference the objects that need connecting to each other. EndOfLevel endOfLevel = Object.FindObjectOfType<EndOfLevel>(); LevelController levelController = Object.FindObjectOfType<LevelController>(); CameraController cameraController = Object.FindObjectOfType<CameraController>(); Player player = Object.FindObjectOfType<Player>(); // Disconect required objects from prefabs if appropriate to do so. PrefabUtility.DisconnectPrefabInstance(endOfLevel); // Create a new serialized object of the end of level. SerializedObject serializedEndOfLevel = new SerializedObject(endOfLevel); // Set the appropriate properties to their correct values. serializedEndOfLevel.FindProperty("menuSwitcher").objectReferenceValue = Object.FindObjectOfType<MenuSwitcher>(); // Apply the changed properties without an undo. serializedEndOfLevel.ApplyModifiedPropertiesWithoutUndo(); // Create a new serialized object of the level controller. SerializedObject serializedLevelController = new SerializedObject(levelController); // Set the appropriate properties to their correct values. serializedLevelController.FindProperty("cameraController").objectReferenceValue = cameraController; serializedLevelController.FindProperty("player").objectReferenceValue = player; // Apply the changed properties without an undo. serializedLevelController.ApplyModifiedPropertiesWithoutUndo(); // Create a new serialized object of the camera controller. SerializedObject serializedCameraController = new SerializedObject(cameraController); // Set the appropriate properties to their correct values. serializedCameraController.FindProperty("target").objectReferenceValue = player.GetComponent<CameraTarget>(); // Apply the changed properties without an undo. serializedCameraController.ApplyModifiedPropertiesWithoutUndo(); } }
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"); }; }
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(); } }
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(); }
public bool[] GetHumanoidBonesSet(Avatar avatar) { bool[] result = new bool[(int)HumanBodyBones.LastBone]; var serializedObject = new UnityEditor.SerializedObject(avatar); for (var humanoidIndex = (HumanBodyBones)0; humanoidIndex < HumanBodyBones.LastBone; humanoidIndex++) { int skeletonIndex = -1; if (humanoidIndex <= HumanBodyBones.Jaw || humanoidIndex == HumanBodyBones.UpperChest) { int humanId = -1; if (humanoidIndex <= HumanBodyBones.Chest) { humanId = (int)humanoidIndex; } else if (humanoidIndex <= HumanBodyBones.Jaw) { humanId = (int)humanoidIndex + 1; } else { humanId = 9; } var pHumanBoneIndexArray = serializedObject.FindProperty("m_Avatar.m_Human.data.m_HumanBoneIndex"); if (pHumanBoneIndexArray == null || !pHumanBoneIndexArray.isArray || humanId < 0 || humanId >= pHumanBoneIndexArray.arraySize) { continue; } skeletonIndex = pHumanBoneIndexArray.GetArrayElementAtIndex(humanId).intValue; } else if (humanoidIndex <= HumanBodyBones.LeftLittleDistal) { int handId = (int)humanoidIndex - (int)HumanBodyBones.LeftThumbProximal; var pHandBoneIndexArray = serializedObject.FindProperty("m_Avatar.m_Human.data.m_LeftHand.data.m_HandBoneIndex"); if (pHandBoneIndexArray == null || !pHandBoneIndexArray.isArray || handId < 0 || handId >= pHandBoneIndexArray.arraySize) { continue; } skeletonIndex = pHandBoneIndexArray.GetArrayElementAtIndex(handId).intValue; } else if (humanoidIndex <= HumanBodyBones.RightLittleDistal) { int handId = (int)humanoidIndex - (int)HumanBodyBones.RightThumbProximal; var pHandBoneIndexArray = serializedObject.FindProperty("m_Avatar.m_Human.data.m_RightHand.data.m_HandBoneIndex"); if (pHandBoneIndexArray == null || !pHandBoneIndexArray.isArray || handId < 0 || handId >= pHandBoneIndexArray.arraySize) { continue; } skeletonIndex = pHandBoneIndexArray.GetArrayElementAtIndex(handId).intValue; } result[(int)humanoidIndex] = skeletonIndex >= 0; } return(result); }
private static void SetupGeographicsTransforms(WRLDARKitSetupHelper.CubeInfo[] cubes) { foreach (var cube in cubes) { GeographicTransform geographicTransform = cube.cubeGameObject.AddComponent <GeographicTransform> (); SerializedObject serializedObject = new UnityEditor.SerializedObject(geographicTransform); SerializedProperty latitudeProperty = serializedObject.FindProperty("InitialLatitude"); SerializedProperty longitudeProperty = serializedObject.FindProperty("InitialLongitude"); latitudeProperty.doubleValue = cube.latitudeDegrees; longitudeProperty.doubleValue = cube.longitudeDegrees; serializedObject.ApplyModifiedProperties(); } }
//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); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float totalHeight = 0; SerializedProperty isList = property.FindPropertyRelative("m_isList"); totalHeight += EditorGUI.GetPropertyHeight(property, label, true) + EditorGUIUtility.standardVerticalSpacing; totalHeight += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("m_isList"), label, true) + EditorGUIUtility.standardVerticalSpacing; totalHeight += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("m_isNot"), label, true) + EditorGUIUtility.standardVerticalSpacing; if (!isList.boolValue) { UnityEngine.Object command = property.FindPropertyRelative("m_conditionCommand").objectReferenceValue; if (command != null) { SerializedObject commandObject = new UnityEditor.SerializedObject(command as ConditionCommand); SerializedProperty propertyIterator = commandObject.GetIterator(); while (propertyIterator.NextVisible(true)) { totalHeight += EditorGUI.GetPropertyHeight(propertyIterator, label, true) + EditorGUIUtility.standardVerticalSpacing; } SerializedProperty methodProperty = commandObject.FindProperty("m_method"); totalHeight += EditorGUI.GetPropertyHeight(methodProperty, label, true) + EditorGUIUtility.standardVerticalSpacing; MethodInfo methodInfo = (command as ConditionCommand).GetType().GetMethod(methodProperty.stringValue); if (methodInfo != null) { for (int i = 0; i < methodInfo.GetParameters().Length; i++) { ParameterInfo parametter = methodInfo.GetParameters()[i]; propertyIterator = commandObject.GetIterator(); while (propertyIterator.Next(true)) { if (propertyIterator.name == parametter.Name) { totalHeight += EditorGUI.GetPropertyHeight(propertyIterator, label, true) + EditorGUIUtility.standardVerticalSpacing; break; } } } } } } else { totalHeight += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("m_isOr"), label, true) + EditorGUIUtility.standardVerticalSpacing; totalHeight += EditorGUI.GetPropertyHeight(property.FindPropertyRelative("m_conditions"), label, true) + EditorGUIUtility.standardVerticalSpacing; } totalHeight += EditorGUIUtility.standardVerticalSpacing * 3; return(totalHeight); }
private static void HandleTag(StringBuilder sb) { sb.AppendLine("public class TagDefine"); sb.AppendLine("{"); //处理预定义部分 sb.AppendLine("\tpublic const string " + "TAG_Untagged".ToUpper() + " = " + "\"Untagged\";"); sb.AppendLine("\tpublic const string " + "TAG_Respawn".ToUpper() + " = " + "\"Respawn\";"); sb.AppendLine("\tpublic const string " + "TAG_Finish".ToUpper() + " = " + "\"Finish\";"); sb.AppendLine("\tpublic const string " + "TAG_EditorOnly".ToUpper() + " = " + "\"EditorOnly\";"); sb.AppendLine("\tpublic const string " + "TAG_MainCamera".ToUpper() + "= " + "\"MainCamera\";"); sb.AppendLine("\tpublic const string " + "TAG_Player".ToUpper() + " = " + "\"Player\";"); sb.AppendLine("\tpublic const string " + "TAG_GameController".ToUpper() + " = " + "\"GameController\";"); //把一部分内置Tag先写死 var asset = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset"); if ((asset != null) && (asset.Length > 0)) { for (int i = 0; i < asset.Length; i++) { //创建序列化对象 var so = new UnityEditor.SerializedObject(asset[i]); var tags = so.FindProperty("tags"); //读取具体字段 for (int j = 0; j < tags.arraySize; ++j) { var item = tags.GetArrayElementAtIndex(j).stringValue; sb.AppendLine("\tpublic const string TAG_" + item.ToUpper() + " = \"" + item + "\";"); //添加到模板 } } } sb.AppendLine("}"); }
public static SerializedProperty GetSerializedProperty(object p_object, string p_propertyName) { SerializedObject _obj = new UnityEditor.SerializedObject((Object)p_object); SerializedProperty _property = _obj.FindProperty(p_propertyName); return(_property); }
//--> 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(); } }
public void DrawGeneralFunction() { AmplifyShaderFunction function = ParentWindow.CurrentGraph.CurrentShaderFunction; if (function == null) { return; } string oldName = function.FunctionName; //oldName = EditorGUILayout.TextField( "Name", oldName ); //if ( oldName != function.FunctionName ) //{ // function.FunctionName = oldName; // EditorUtility.SetDirty( function ); //} SerializedObject serializedObject = new UnityEditor.SerializedObject(function); if (serializedObject != null) { SerializedProperty temo = serializedObject.FindProperty("m_description"); oldName = temo.stringValue; EditorGUILayout.PropertyField(temo, new GUIContent(" Description")); if (!oldName.Equals(temo.stringValue)) { function.Description = temo.stringValue; oldName = temo.stringValue; } } }
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(); }
private static void HandleSortingLayer(StringBuilder sb) { sb.AppendLine("public class SortingDefine"); sb.AppendLine("{"); //处理预定义部分 sb.AppendLine("\tpublic const string " + "SORTING_Default".ToUpper() + " = " + "\"Default\";"); var asset = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset"); if ((asset != null) && (asset.Length > 0)) { for (int i = 0; i < asset.Length; i++) { var so = new UnityEditor.SerializedObject(asset[i]); var sortings = so.FindProperty("m_SortingLayers"); for (int j = 0; j < sortings.arraySize; ++j) { var item = sortings.GetArrayElementAtIndex(j).stringValue; sb.AppendLine("\tpublic const string SORTING_" + item.ToUpper() + " = " + item + ";"); } } } sb.AppendLine("}"); }
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(); }
/// <summary> /// Called when the inspector needs to draw /// </summary> public override bool OnInspectorGUI(UnityEditor.SerializedObject rTargetSO, UnityEngine.Object rTarget) { bool lIsDirty = base.OnInspectorGUI(rTargetSO, rTarget); if (mActorCore == null && mOwner != null) { mActorCore = mOwner.GetComponent <ActorCore>(); } if (_StoredUnityEventIndex < 0) { lIsDirty = true; _StoredUnityEventIndex = mActorCore.StoreUnityEvent(-1, new ReactorActionEvent()); } //EditorGUILayout.LabelField(_StoredUnityEventIndex.ToString() + " of " + mActorCore._StoredUnityEvents.Count); SerializedProperty lArray = rTargetSO.FindProperty("_StoredUnityEvents"); if (lArray.isArray && lArray.arraySize > _StoredUnityEventIndex) { SerializedProperty lItem = lArray.GetArrayElementAtIndex(_StoredUnityEventIndex); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(lItem); if (EditorGUI.EndChangeCheck()) { lIsDirty = true; } } return(lIsDirty); }
public static void FixByOneKey(string projectCode, string folder, bool isCombProj = false) { string root = Path.GetFullPath(".") + Path.DirectorySeparatorChar + "Assets" + Path.DirectorySeparatorChar; string searchPath = root + folder + (isCombProj ? Path.DirectorySeparatorChar + projectCode : ""); if (!Directory.Exists(searchPath)) { return; } List <string> filePath = new List <string>(); filePath.AddRange( Directory.GetFiles(searchPath, "*.*", SearchOption.AllDirectories) ); int counter = -1; foreach (string file in filePath) { string tempFolder = file.Substring(root.Length); EditorUtility.DisplayProgressBar("Search File", tempFolder, counter / (float)filePath.Count); counter++; string ext = Path.GetExtension(file).ToLower(); if (ext.Equals(".mp3") || ext.Equals(".wav") || ext.Equals(".ogg") || ext.Equals(".m4a")) { string path = file.Substring(file.IndexOf("Assets/")); AudioClip audio = AssetDatabase.LoadAssetAtPath <AudioClip>(path); var audioImporter = (AudioImporter)AudioImporter.GetAtPath(path); var isDirty = false; if (audio && audio.length > MAX_LENGTH && audioImporter.defaultSampleSettings.loadType != AudioClipLoadType.Streaming) { var setting = audioImporter.defaultSampleSettings; setting.loadType = AudioClipLoadType.Streaming; audioImporter.defaultSampleSettings = setting; isDirty = true; } if (audio && audioImporter.forceToMono == false) { audioImporter.forceToMono = true; isDirty = true; SerializedObject serializedObject = new UnityEditor.SerializedObject(audioImporter); SerializedProperty normalize = serializedObject.FindProperty("m_Normalize"); normalize.boolValue = false; serializedObject.ApplyModifiedProperties(); } if (isDirty) { audioImporter.SaveAndReimport(); EditorUtility.SetDirty(audio); } } } EditorUtility.ClearProgressBar(); AssetDatabase.Refresh(); }
private void DisconnectTeleporter(TelportVrScript teleporter) { SerializedObject serializedObject = new UnityEditor.SerializedObject(teleporter); SerializedProperty serializedProperty = serializedObject.FindProperty("destinationSphereName"); serializedProperty.stringValue = ""; SerializedProperty serializedAllignment = serializedObject.FindProperty("alligned"); serializedAllignment.boolValue = false; serializedProperty.serializedObject.ApplyModifiedProperties(); serializedProperty.serializedObject.Update(); teleporter.gameObject.SetActive(false); }
/// <summary> /// Add the observer to the outfit with proper change tracking. /// </summary> /// <remarks> /// <para> /// It is safe to use this method to add an existing observer. In this case the update will force a /// change record. (Useful when the observer has already been added, but wasn't properly recorded /// for serialization.) /// </para> /// </remarks> /// <param name="outfit">The outfit. (Required)</param> /// <param name="observer">The observer to add, or to update so it has change tracking. (Required)</param> public static void AddObserverWithUndo(Outfit outfit, IOutfitObserver observer) { // Design note: Adding an observer can sometimes fail when added using the standard method. // Don't know why yet. This method works in all cases. var obj = (Object)observer; var so = new UnityEditor.SerializedObject(outfit); var prop = so.FindProperty("m_Observers.m_Items"); int idx = -1; for (int i = 0; i < prop.arraySize; i++) { if (prop.GetArrayElementAtIndex(i).objectReferenceValue == obj) { prop.GetArrayElementAtIndex(idx).objectReferenceValue = null; idx = i; break; } } if (idx == -1) { idx = prop.arraySize; prop.arraySize++; } prop.GetArrayElementAtIndex(idx).objectReferenceValue = obj; so.ApplyModifiedProperties(); }
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; } }
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(); }
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(); } }
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(); }
// 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(); } }
public virtual void OnDrawEditSettings() { //Poly SerializedObject serializedObject = new UnityEditor.SerializedObject(area2d); SerializedProperty serializedLine = serializedObject.FindProperty("_poly"); EditorGUILayout.PropertyField(serializedLine); serializedObject.ApplyModifiedProperties(); }
public static int GetLocalIdentfierInFile(Object comp) { var inspectorModeInfo = typeof(UnityEditor.SerializedObject).GetProperty("inspectorMode", BindingFlags.NonPublic | BindingFlags.Instance); UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(comp); inspectorModeInfo.SetValue(serializedObject, UnityEditor.InspectorMode.Debug, null); UnityEditor.SerializedProperty localIdProp = serializedObject.FindProperty("m_LocalIdentfierInFile"); return(localIdProp.intValue); }