Example #1
0
    protected override void OnCreateClip(TimelineClip clip)
    {
        clip.duration = 2f;
        base.OnCreateClip(clip);
        BoneFxAsset asset = clip.asset as BoneFxAsset;

        asset.track = this.parent as TrackAsset;
    }
Example #2
0
        public override void OnInspectorGUI()
        {
            BoneFxAsset asset = target as BoneFxAsset;

            if (director == null)
            {
                director = GameObject.FindObjectOfType <PlayableDirector>();
            }
            EditorGUILayout.Space();
            prefabGo = EditorGUILayout.ObjectField("Fx Prefab", prefabGo, typeof(GameObject), true) as GameObject;
            if (prefabGo != null)
            {
                string path = AssetDatabase.GetAssetPath(prefabGo);
                asset.prefab = path.Replace("Assets/BundleRes/", string.Empty).Replace(".prefab", string.Empty);
                if (!path.Contains("BundleRes") || !path.EndsWith(".prefab"))
                {
                    EditorGUILayout.HelpBox("The fx that you selected is invalid", MessageType.Error);
                }
            }
            if (boneGo == null && !string.IsNullOrEmpty(asset.prefab))
            {
                string path = "Assets/BundleRes/" + asset.prefab + ".prefab";
                prefabGo = AssetDatabase.LoadAssetAtPath <GameObject>(path);
                if (prefabGo == null)
                {
                    EditorGUILayout.HelpBox("AssetPath is invalid", MessageType.Error);
                }
            }
            EditorGUILayout.LabelField(asset.prefab);
            boneGo = EditorGUILayout.ObjectField("Select Bone", boneGo, typeof(GameObject), true) as GameObject;
            EditorGUILayout.LabelField(asset.fxPath);
            if (boneGo != null)
            {
                asset.fxPath = GetRootFullPath(boneGo.transform);
                if (string.IsNullOrEmpty(asset.fxPath) || !asset.fxPath.StartsWith("root"))
                {
                    EditorGUILayout.HelpBox("Avatar bone transform is invalid", MessageType.Error);
                }
            }
            else if (!string.IsNullOrEmpty(asset.fxPath))
            {
                if (asset.track != null)
                {
                    var       binding = director.GetGenericBinding(asset.track);
                    Transform tf      = ExternalHelp.FetchAttachOfTrack(director, asset.track);
                    if (tf)
                    {
                        tf = tf.GetChild(0).Find(asset.fxPath);
                        if (tf)
                        {
                            boneGo = tf.gameObject;
                        }
                    }
                }
            }
            DrawTransform();
            PreviewFx();
        }
Example #3
0
        void DrawTransform()
        {
            BoneFxAsset asset = target as BoneFxAsset;

            EditorGUILayout.LabelField("Fx transform:");
            asset.pos   = EditorGUILayout.Vector3Field(" Position", asset.pos);
            asset.rot   = EditorGUILayout.Vector3Field(" Rotation", asset.rot);
            asset.scale = EditorGUILayout.Vector3Field(" Scale", asset.scale);
        }